Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@
"reusability",
"rproj",
"rstudio",
"runai",
"scala",
"scrollable",
"selectautosuggest",
Expand Down
4 changes: 4 additions & 0 deletions client/.prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
build/
public/config.json
# Do not format generated files
*generated-api.ts
.react-router/types
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to keep formatting the generated files: they are checked into git and the formatting makes them easier to read.

Suggested change
.react-router/types
public/config.json
.react-router/types

2 changes: 1 addition & 1 deletion client/scripts/update_api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { parseDocument } from "yaml";

const GH_BASE_URL = "https://raw.githubusercontent.com";
const DATA_SERVICES_REPO = "SwissDataScienceCenter/renku-data-services";
const DATA_SERVICES_RELEASE = "main";
const DATA_SERVICES_RELEASE = "ciyer/amalthea-runai";

async function main() {
argv.forEach((arg) => {
Expand Down
62 changes: 40 additions & 22 deletions client/src/features/admin/AddResourcePoolButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,16 @@ function AddResourcePoolModal({ isOpen, toggle }: AddResourcePoolModalProps) {
clusterId: "",
remote: {
enabled: false,
kind: "firecrest",
providerId: "",
apiUrl: "",
systemName: "",
partition: "",
kind: null,
firecrestConfiguration: {
providerId: "",
apiUrl: "",
systemName: "",
partition: "",
},
runaiConfiguration: {
baseUrl: "",
},
},
},
});
Expand All @@ -136,19 +141,27 @@ function AddResourcePoolModal({ isOpen, toggle }: AddResourcePoolModalProps) {
const clusterId = data.clusterId?.trim()
? data.clusterId.trim()
: undefined;
const remote: RemoteConfiguration | undefined = data.remote.enabled
? {
kind: data.remote.kind,
provider_id: data.remote.providerId?.trim()
? data.remote.providerId.trim()
: undefined,
api_url: data.remote.apiUrl.trim(),
system_name: data.remote.systemName.trim(),
partition: data.remote.partition?.trim()
? data.remote.partition.trim()
: undefined,
}
: undefined;
const remote: RemoteConfiguration | undefined =
data.remote.enabled == null
? undefined
: data.remote.kind == "firecrest"
? {
kind: "firecrest",
provider_id: data.remote.firecrestConfiguration.providerId?.trim()
? data.remote.firecrestConfiguration.providerId.trim()
: undefined,
api_url: data.remote.firecrestConfiguration.apiUrl.trim(),
system_name: data.remote.firecrestConfiguration.systemName.trim(),
partition: data.remote.firecrestConfiguration.partition?.trim()
? data.remote.firecrestConfiguration.partition.trim()
: undefined,
}
: data.remote.kind == "runai"
? {
kind: "runai",
base_url: data.remote.runaiConfiguration.baseUrl.trim(),
}
: undefined;
addResourcePool({
resourcePool: {
classes: populatedClass ? [populatedClass] : [],
Expand Down Expand Up @@ -185,10 +198,15 @@ function AddResourcePoolModal({ isOpen, toggle }: AddResourcePoolModalProps) {
remote: {
enabled: false,
kind: "firecrest",
providerId: "",
apiUrl: "",
systemName: "",
partition: "",
firecrestConfiguration: {
providerId: "",
apiUrl: "",
systemName: "",
partition: "",
},
runaiConfiguration: {
baseUrl: "",
},
},
});
}, [defaultQuota, reset]);
Expand Down
64 changes: 38 additions & 26 deletions client/src/features/admin/UpdateResourcePoolRemoteButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,30 @@ import {
usePatchResourcePoolsByResourcePoolIdMutation,
type ResourcePoolWithId,
} from "../sessionsV2/api/computeResources.api";
import type { ResourcePoolForm } from "./adminComputeResources.types";
import type {
RemoteConfiguration,
ResourcePoolForm,
} from "./adminComputeResources.types";
import ResourcePoolRemoteSection from "./forms/ResourcePoolRemoteSection";

function remoteDefaultValues(
remote: ResourcePoolWithId["remote"]
): RemoteConfiguration {
return {
enabled: remote?.kind != null,
kind: remote?.kind ?? null,
firecrestConfiguration: {
providerId: remote?.provider_id ?? "",
apiUrl: remote?.kind === "firecrest" ? remote?.api_url ?? "" : "",
systemName: remote?.kind === "firecrest" ? remote?.system_name ?? "" : "",
partition: remote?.kind === "firecrest" ? remote?.partition ?? "" : "",
},
runaiConfiguration: {
baseUrl: remote?.kind === "runai" ? remote?.base_url ?? "" : "",
},
};
}

interface UpdateResourcePoolRemoteButtonProps {
resourcePool: ResourcePoolWithId;
}
Expand Down Expand Up @@ -87,31 +108,29 @@ function UpdateResourcePoolRemoteModal({
reset,
} = useForm<UpdateResourcePoolRemoteForm>({
defaultValues: {
remote: {
enabled: remote != null,
kind: remote?.kind ?? "firecrest",
providerId: remote?.provider_id ?? "",
apiUrl: remote?.api_url ?? "",
systemName: remote?.system_name ?? "",
partition: remote?.partition ?? "",
},
remote: remoteDefaultValues(remote),
},
});
const onSubmit = useCallback(
(data: UpdateResourcePoolRemoteForm) => {
const remote = data.remote.enabled
const remote = !data.remote.enabled
? {}
: data.remote.kind === "runai"
? {
kind: data.remote.kind,
provider_id: data.remote.providerId?.trim()
? data.remote.providerId.trim()
base_url: data.remote.runaiConfiguration.baseUrl.trim(),
}
: {
kind: data.remote.kind,
provider_id: data.remote.firecrestConfiguration.providerId?.trim()
? data.remote.firecrestConfiguration.providerId.trim()
: undefined,
api_url: data.remote.apiUrl.trim(),
system_name: data.remote.systemName.trim(),
partition: data.remote.partition?.trim()
? data.remote.partition.trim()
api_url: data.remote.firecrestConfiguration.apiUrl.trim(),
system_name: data.remote.firecrestConfiguration.systemName.trim(),
partition: data.remote.firecrestConfiguration.partition?.trim()
? data.remote.firecrestConfiguration.partition.trim()
: undefined,
}
: {};
};
updateResourcePool({ resourcePoolId: id, resourcePoolPatch: { remote } });
},
[id, updateResourcePool]
Expand All @@ -125,14 +144,7 @@ function UpdateResourcePoolRemoteModal({

useEffect(() => {
reset({
remote: {
enabled: remote != null,
kind: remote?.kind ?? "firecrest",
providerId: remote?.provider_id ?? "",
apiUrl: remote?.api_url ?? "",
systemName: remote?.system_name ?? "",
partition: remote?.partition ?? "",
},
remote: remoteDefaultValues(remote),
});
}, [remote, reset]);

Expand Down
14 changes: 12 additions & 2 deletions client/src/features/admin/adminComputeResources.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* limitations under the License.
*/

import { type RemoteConfiguration as BackendRemoteConfiguration } from "../sessionsV2/api/computeResources.generated-api";

export interface ResourcePoolForm {
name: string;
public: boolean;
Expand All @@ -34,14 +36,22 @@ export interface ResourcePoolFormQuota {

export interface RemoteConfiguration {
enabled: boolean;
/** Kind of remote resource pool */
kind: "firecrest";
kind: BackendRemoteConfiguration["kind"] | null;
firecrestConfiguration: RemoteConfigurationDetailsFirecrest;
runaiConfiguration: RemoteConfigurationDetailsRunai;
}

interface RemoteConfigurationDetailsFirecrest {
providerId?: string;
apiUrl: string;
systemName: string;
partition?: string;
}

interface RemoteConfigurationDetailsRunai {
baseUrl: string;
}

export interface ResourceClassForm {
name: string;
cpu: number;
Expand Down
Loading
Loading