Skip to content

Commit

Permalink
Merge branch 'master' into feat/#809-vanilla-rserve
Browse files Browse the repository at this point in the history
  • Loading branch information
marikaris authored Oct 31, 2024
2 parents 434a48b + 937ff62 commit 47a8a1c
Show file tree
Hide file tree
Showing 17 changed files with 172 additions and 112 deletions.
2 changes: 1 addition & 1 deletion armadillo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jacocoTestReport {

spotless {
java {
googleJavaFormat('1.15.0')
googleJavaFormat('1.17.0')
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
@ResponseStatus(BAD_REQUEST)
public class InvalidObjectNameException extends RuntimeException {

public InvalidObjectNameException(String objectName) {
super(
format(
"Object name '%s' is invalid. Object format should be in the following format: folder/file.",
objectName));
}
public InvalidObjectNameException(String objectName) {
super(
format(
"Object name '%s' is invalid. Object format should be in the following format: folder/file.",
objectName));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@Component
public class ProfileScope implements Scope {
private static final Logger LOGGER = LoggerFactory.getLogger(ProfileScope.class);

/** Contains all profile scoped beans for all profiles */
private final ConcurrentHashMap<String, Object> scopedBeans = new ConcurrentHashMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ public void createLinkedObject(
}
try {
ArmadilloLinkFile armadilloLinkFile =
createLinkFileFromSource(sourceProject, sourceObject, variables, linkName, linkProject);
createLinkFileFromSource(sourceProject, sourceObject, variables, linkName, linkProject);
InputStream is = armadilloLinkFile.toStream();
storageService.save(
is, SHARED_PREFIX + linkProject, armadilloLinkFile.getFileName(), APPLICATION_JSON);
is, SHARED_PREFIX + linkProject, armadilloLinkFile.getFileName(), APPLICATION_JSON);
} catch (IllegalArgumentException e) {
throw new InvalidObjectNameException(linkName);
}
Expand Down Expand Up @@ -230,14 +230,15 @@ private static Workspace toWorkspace(ObjectMetadata item) {
private void trySaveWorkspace(ArmadilloWorkspace workspace, Principal principal, String id) {
try {
storageService.save(
workspace.createInputStream(),
getUserBucketName(principal),
getWorkspaceObjectName(id),
APPLICATION_OCTET_STREAM);
workspace.createInputStream(),
getUserBucketName(principal),
getWorkspaceObjectName(id),
APPLICATION_OCTET_STREAM);
} catch (StorageException e) {
throw new StorageException(e);
}
}

public void saveWorkspace(InputStream is, Principal principal, String id) {
// Load root dir
File drive = new File("/");
Expand All @@ -249,9 +250,9 @@ public void saveWorkspace(InputStream is, Principal principal, String id) {
trySaveWorkspace(workspace, principal, id);
} else {
throw new StorageException(
format(
"Can't save workspace: workspace too big (%s), not enough space left on device. Try to make your workspace smaller and/or contact the administrator to increase diskspace.",
getHumanReadableByteCount(fileSize)));
format(
"Can't save workspace: workspace too big (%s), not enough space left on device. Try to make your workspace smaller and/or contact the administrator to increase diskspace.",
getHumanReadableByteCount(fileSize)));
}
} catch (StorageException e) {
throw new StorageException(e.getMessage().replace("load", "save"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

public class ArmadilloWorkspace {
byte[] content;
public static final String WORKSPACE_TOO_BIG_ERROR = "Unable to load workspace. Maximum supported workspace size is 2GB";
public static final String WORKSPACE_TOO_BIG_ERROR =
"Unable to load workspace. Maximum supported workspace size is 2GB";

public ArmadilloWorkspace(InputStream is) {
content = toByteArray(is);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public class ArmadilloLinkFileTest {
String linkProject = "view-project";
ArmadilloLinkFile alf = new ArmadilloLinkFile(srcProject, srcObj, vars, linkObj, linkProject);

@Test void testThrowsIllegalArgumentExceptionWhenInvalidLinkObject() {
@Test
void testThrowsIllegalArgumentExceptionWhenInvalidLinkObject() {
try {
new ArmadilloLinkFile(srcProject, srcObj, vars, "broken", linkProject);
} catch (IllegalArgumentException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,11 +520,13 @@ void testSaveWorkspaceReturnsErrorWhenTooBig() {

@Test
void testSaveWorkspaceReturnsErrorWhenBiggerThan2Gbs() {
when(storageService.getWorkSpace(is)).thenThrow(new StorageException(ArmadilloWorkspace.WORKSPACE_TOO_BIG_ERROR));
when(storageService.getWorkSpace(is))
.thenThrow(new StorageException(ArmadilloWorkspace.WORKSPACE_TOO_BIG_ERROR));
try {
armadilloStorage.saveWorkspace(is, principal, "test");
} catch (StorageException e) {
assertEquals("Unable to save workspace. Maximum supported workspace size is 2GB", e.getMessage());
assertEquals(
"Unable to save workspace. Maximum supported workspace size is 2GB", e.getMessage());
}
}

Expand Down Expand Up @@ -617,10 +619,10 @@ void testCreateLinkedObjecInvalidLinkObj() {
mockExistingObject(SHARED_GECKO, "1_0_release_1_1/gecko.parquet");
when(storageService.listBuckets()).thenReturn(List.of(SHARED_DIABETES, SHARED_GECKO));
assertThrows(
InvalidObjectNameException.class,
() ->
armadilloStorage.createLinkedObject(
"gecko", "1_0_release_1_1/gecko", "my_link", "diabetes", "a,b,c"));
InvalidObjectNameException.class,
() ->
armadilloStorage.createLinkedObject(
"gecko", "1_0_release_1_1/gecko", "my_link", "diabetes", "a,b,c"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void testGetByteOfInputStreamThrowsMemoryError() throws IOException {
when(isMock.read(any(byte[].class))).thenThrow(OutOfMemoryError.class);
try {
new ArmadilloWorkspace(isMock);
} catch(StorageException e) {
} catch (StorageException e) {
assertEquals(ArmadilloWorkspace.WORKSPACE_TOO_BIG_ERROR, e.getMessage());
}
}
Expand Down
2 changes: 1 addition & 1 deletion r/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jacocoTestReport {

spotless {
java {
googleJavaFormat('1.15.0')
googleJavaFormat('1.17.0')
}
}

Expand Down
29 changes: 22 additions & 7 deletions ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,20 @@
{{ diskSpaceMessage }}
</Alert>
<Alert v-if="isUnauthorised" type="warning" :dismissible="false">
You are logged in, but you don't have permission to access the Armadillo user interface.
You are logged in, but you don't have permission to access the
Armadillo user interface.
<div>
Don't worry, you can still do your research using the R client.
If you believe you should have permission to access this user interface, please contact an administrator.
If you believe you should have permission to access this user
interface, please contact an administrator.
</div>
</Alert>
{{ errorMessage }}
<Tabs v-if="username && !isUnauthorised" :menu="tabs" :icons="tabIcons" />
<Tabs
v-if="username && !isUnauthorised"
:menu="tabs"
:icons="tabIcons"
/>
</div>
<Login @loginEvent="reloadUser" v-else />
</div>
Expand All @@ -36,10 +42,20 @@ import Tabs from "@/components/Tabs.vue";
import Login from "@/views/Login.vue";
import Alert from "@/components/Alert.vue";
import { defineComponent, onMounted, ref, Ref } from "vue";
import { getPrincipal, getVersion, logout, getFreeDiskSpace, getPermissions } from "@/api/api";
import {
getPrincipal,
getVersion,
logout,
getFreeDiskSpace,
getPermissions,
} from "@/api/api";
import { useRouter } from "vue-router";
import { ApiError } from "@/helpers/errors";
import { diskSpaceBelowThreshold, convertBytes, isEmpty } from "@/helpers/utils";
import {
diskSpaceBelowThreshold,
convertBytes,
isEmpty,
} from "@/helpers/utils";
export default defineComponent({
name: "ArmadilloPortal",
Expand Down Expand Up @@ -77,8 +93,7 @@ export default defineComponent({
if (error.cause == 403) {
isUnauthorised.value = true;
}
})
});
})
.catch((error: ApiError) => {
if (error.cause === 401) {
Expand Down
8 changes: 6 additions & 2 deletions ui/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ import {
Metrics,
} from "@/types/api";

import { ObjectWithStringKey, StringArray, ListOfObjectsWithStringKey } from "@/types/types";
import {
ObjectWithStringKey,
StringArray,
ListOfObjectsWithStringKey,
} from "@/types/types";
import { APISettings } from "./config";

export async function get(url: string, auth: Auth | undefined = undefined) {
Expand Down Expand Up @@ -199,7 +203,7 @@ export async function getProjects(): Promise<Project[]> {
}

export function getPermissions(): Promise<ListOfObjectsWithStringKey> {
return get("/access/permissions")
return get("/access/permissions");
}

export async function getFiles(): Promise<RemoteFileInfo[]> {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/DataPreviewTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<!-- for each value in row -->
<td v-for="(value, key, index) in row" :key="key">
<span v-if="value.toString().length > tableHeader[index].length">
{{ value.toString().slice(0, tableHeader[index].length - 2 ) }}..
{{ value.toString().slice(0, tableHeader[index].length - 2) }}..
</span>
<span v-else>
{{ value }}
Expand Down
22 changes: 12 additions & 10 deletions ui/src/components/FormValidation.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<template>
<div :class="isValidated && validationCondition ? 'invalid-field' : ''" class="p-1">
<div
:class="isValidated && validationCondition ? 'invalid-field' : ''"
class="p-1"
>
<slot></slot>
<div v-if="isValidated && validationCondition" class="feedback">
{{ invalidMessage }}
{{ invalidMessage }}
</div>
</div>
</template>
Expand All @@ -15,17 +18,17 @@ export default defineComponent({
props: {
isValidated: {
type: Boolean,
default: false
default: false,
},
validationCondition: {
type: Boolean,
required: true
required: true,
},
invalidMessage: {
type: String,
required: true
}
}
required: true,
},
},
});
</script>

Expand All @@ -38,9 +41,8 @@ export default defineComponent({
}
.feedback {
color: rgb(220, 53, 69);
color: rgb(220, 53, 69);
font-style: italic;
font-size: 0.9rem;
}
</style>
</style>
Loading

0 comments on commit 47a8a1c

Please sign in to comment.