Skip to content

Commit

Permalink
John conroy/fix template resource (#3550)
Browse files Browse the repository at this point in the history
* Fix resource option defaults

* Add changelog

---------

Co-authored-by: John Conroy <[email protected]>
  • Loading branch information
john-conroy and john-conroy authored Sep 25, 2024
1 parent da7f601 commit da26bf9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-fix-template-resource.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fix bug where template examples with default resource options would not launch.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ interface UseCreateWorkspaceTypes {
defaultName?: string;
defaultTemplate?: string;
defaultJobType?: string;
defaultResourceOptions?: WorkspaceResourceOptions;
defaultResourceOptions?: Partial<WorkspaceResourceOptions>;
initialProtectedDatasets?: string;
initialSelectedDatasets?: string[];
}
Expand All @@ -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) {
Expand All @@ -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,
Expand All @@ -91,7 +93,7 @@ function useCreateWorkspaceForm({
'protected-datasets': checkedProtectedDatasets,
templates: [defaultTemplate],
workspaceJobTypeId: defaultJobType,
workspaceResourceOptions: defaultResourceOptions,
workspaceResourceOptions: initialResourceOptions,
datasets: initialSelectedDatasets,
},
mode: 'onChange',
Expand Down
2 changes: 1 addition & 1 deletion context/app/static/js/components/workspaces/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ interface TemplateExample {
description: string;
datasets: string[];
assay_display_name?: string[];
resource_options?: WorkspaceResourceOptions;
resource_options?: Partial<WorkspaceResourceOptions>;
required_filetypes?: string[];
}

Expand Down

0 comments on commit da26bf9

Please sign in to comment.