From da26bf9b09d54ca6121fd91ea59c33e31d701cd7 Mon Sep 17 00:00:00 2001 From: John Conroy <62477388+john-conroy@users.noreply.github.com> Date: Wed, 25 Sep 2024 15:57:24 -0400 Subject: [PATCH] John conroy/fix template resource (#3550) * Fix resource option defaults * Add changelog --------- Co-authored-by: John Conroy --- CHANGELOG-fix-template-resource.md | 1 + .../useCreateWorkspaceForm.ts | 18 ++++++++++-------- .../static/js/components/workspaces/types.ts | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) create mode 100644 CHANGELOG-fix-template-resource.md diff --git a/CHANGELOG-fix-template-resource.md b/CHANGELOG-fix-template-resource.md new file mode 100644 index 0000000000..83cdede524 --- /dev/null +++ b/CHANGELOG-fix-template-resource.md @@ -0,0 +1 @@ +- Fix bug where template examples with default resource options would not launch. \ No newline at end of file diff --git a/context/app/static/js/components/workspaces/NewWorkspaceDialog/useCreateWorkspaceForm.ts b/context/app/static/js/components/workspaces/NewWorkspaceDialog/useCreateWorkspaceForm.ts index 4f116c3e12..8929d014ff 100644 --- a/context/app/static/js/components/workspaces/NewWorkspaceDialog/useCreateWorkspaceForm.ts +++ b/context/app/static/js/components/workspaces/NewWorkspaceDialog/useCreateWorkspaceForm.ts @@ -40,7 +40,7 @@ interface UseCreateWorkspaceTypes { defaultName?: string; defaultTemplate?: string; defaultJobType?: string; - defaultResourceOptions?: WorkspaceResourceOptions; + defaultResourceOptions?: Partial; initialProtectedDatasets?: string; initialSelectedDatasets?: string[]; } @@ -61,12 +61,7 @@ function useCreateWorkspaceForm({ defaultName, defaultTemplate = DEFAULT_PYTHON_TEMPLATE_KEY, defaultJobType = DEFAULT_JOB_TYPE, - defaultResourceOptions = { - num_cpus: DEFAULT_NUM_CPUS, - memory_mb: DEFAULT_MEMORY_MB, - time_limit_minutes: DEFAULT_TIME_LIMIT_MINUTES, - gpu_enabled: DEFAULT_GPU_ENABLED, - }, + defaultResourceOptions = {}, initialProtectedDatasets, initialSelectedDatasets = [], }: UseCreateWorkspaceTypes) { @@ -77,6 +72,13 @@ function useCreateWorkspaceForm({ const checkedWorkspaceName = defaultName ?? ''; const checkedProtectedDatasets = initialProtectedDatasets ?? ''; + const initialResourceOptions = { + num_cpus: DEFAULT_NUM_CPUS, + memory_mb: DEFAULT_MEMORY_MB, + time_limit_minutes: DEFAULT_TIME_LIMIT_MINUTES, + gpu_enabled: DEFAULT_GPU_ENABLED, + ...defaultResourceOptions, + }; const { handleSubmit, control, @@ -91,7 +93,7 @@ function useCreateWorkspaceForm({ 'protected-datasets': checkedProtectedDatasets, templates: [defaultTemplate], workspaceJobTypeId: defaultJobType, - workspaceResourceOptions: defaultResourceOptions, + workspaceResourceOptions: initialResourceOptions, datasets: initialSelectedDatasets, }, mode: 'onChange', diff --git a/context/app/static/js/components/workspaces/types.ts b/context/app/static/js/components/workspaces/types.ts index 83cc1c989a..d6cd6e29fc 100644 --- a/context/app/static/js/components/workspaces/types.ts +++ b/context/app/static/js/components/workspaces/types.ts @@ -106,7 +106,7 @@ interface TemplateExample { description: string; datasets: string[]; assay_display_name?: string[]; - resource_options?: WorkspaceResourceOptions; + resource_options?: Partial; required_filetypes?: string[]; }