16602: Read WorkflowRunnerResources from workflow to get advanced settings
authorPeter Amstutz <peter.amstutz@curii.com>
Wed, 26 Aug 2020 21:18:09 +0000 (17:18 -0400)
committerPeter Amstutz <peter.amstutz@curii.com>
Wed, 26 Aug 2020 21:18:09 +0000 (17:18 -0400)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

src/models/workflow.ts
src/store/processes/processes-actions.ts
src/store/run-process-panel/run-process-panel-actions.ts
src/views/run-process-panel/run-process-advanced-form.tsx

index abc92c624d97ea72e84daef51d854af9f12d1009..ad84bd9e891a95fcfff02a1cb001a72e226e0f45 100644 (file)
@@ -22,6 +22,7 @@ export interface Workflow {
     inputs: CommandInputParameter[];
     outputs: any[];
     steps: any[];
+    hints?: ProcessRequirement[];
 }
 
 export interface CommandLineTool {
@@ -29,6 +30,21 @@ export interface CommandLineTool {
     id: string;
     inputs: CommandInputParameter[];
     outputs: any[];
+    hints?: ProcessRequirement[];
+}
+
+export type ProcessRequirement = GenericProcessRequirement | WorkflowRunnerResources;
+
+export interface GenericProcessRequirement {
+    class: string;
+}
+
+export interface WorkflowRunnerResources {
+    class: 'http://arvados.org/cwl#WorkflowRunnerResources';
+    ramMin?: number;
+    coresMin?: number;
+    keep_cache?: number;
+    acrContainerImage?: string;
 }
 
 export type CommandInputParameter =
index ab51f9caa07babf0b3b4c70bb34e39d99637b4c0..ba70f9147dc895941e42a39ffecd077b46d38962 100644 (file)
@@ -69,7 +69,7 @@ export const reRunProcess = (processUuid: string, workflowUuid: string) =>
                 ram: process.runtimeConstraints.ram,
                 vcpus: process.runtimeConstraints.vcpus,
                 keep_cache_ram: process.runtimeConstraints.keep_cache_ram,
-                api: process.runtimeConstraints.API
+                acr_container_image: process.containerImage
             };
             dispatch<any>(initialize(RUN_PROCESS_ADVANCED_FORM, advancedInitialData));
 
index 2397601d8f1b5e8b0bba911ad1e54f897da8cfa3..f925c5c4af2b7d9f79146b8d33a722a122140f53 100644 (file)
@@ -7,7 +7,7 @@ import { unionize, ofType, UnionOf } from "~/common/unionize";
 import { ServiceRepository } from "~/services/services";
 import { RootState } from '~/store/store';
 import { getUserUuid } from "~/common/getuser";
-import { WorkflowResource, getWorkflowInputs, parseWorkflowDefinition } from '~/models/workflow';
+import { WorkflowResource, WorkflowRunnerResources, getWorkflow, getWorkflowInputs, parseWorkflowDefinition } from '~/models/workflow';
 import { getFormValues, initialize } from 'redux-form';
 import { RUN_PROCESS_BASIC_FORM, RunProcessBasicFormData } from '~/views/run-process-panel/run-process-basic-form';
 import { RUN_PROCESS_INPUTS_FORM } from '~/views/run-process-panel/run-process-inputs-form';
@@ -15,7 +15,10 @@ import { WorkflowInputsData } from '~/models/workflow';
 import { createWorkflowMounts } from '~/models/process';
 import { ContainerRequestState } from '~/models/container-request';
 import { navigateTo } from '../navigation/navigation-action';
-import { RunProcessAdvancedFormData, RUN_PROCESS_ADVANCED_FORM, VCPUS_FIELD, RAM_FIELD, RUNTIME_FIELD, OUTPUT_FIELD, API_FIELD } from '~/views/run-process-panel/run-process-advanced-form';
+import {
+    RunProcessAdvancedFormData, RUN_PROCESS_ADVANCED_FORM, VCPUS_FIELD,
+    KEEP_CACHE_RAM_FIELD, RAM_FIELD, RUNTIME_FIELD, OUTPUT_FIELD, RUNNER_IMAGE_FIELD
+} from '~/views/run-process-panel/run-process-advanced-form';
 import { dialogActions } from '~/store/dialog/dialog-actions';
 import { setBreadcrumbs } from '~/store/breadcrumbs/breadcrumbs-actions';
 import { matchProjectRoute } from '~/routes/routes';
@@ -76,16 +79,32 @@ export const openSetWorkflowDialog = (workflow: WorkflowResource) =>
 export const setWorkflow = (workflow: WorkflowResource, isWorkflowChanged = true) =>
     (dispatch: Dispatch<any>, getState: () => RootState) => {
         const isStepChanged = getState().runProcessPanel.isStepChanged;
+
+        const advancedFormValues = {};
+        Object.assign(advancedFormValues, DEFAULT_ADVANCED_FORM_VALUES);
+
+        const wf = getWorkflow(parseWorkflowDefinition(workflow));
+        const hints = wf ? wf.hints : undefined;
+        if (hints) {
+            const resc = hints.find(item => item.class === 'http://arvados.org/cwl#WorkflowRunnerResources') as WorkflowRunnerResources | undefined;
+            if (resc) {
+                if (resc.ramMin) { advancedFormValues[RAM_FIELD] = resc.ramMin; }
+                if (resc.coresMin) { advancedFormValues[VCPUS_FIELD] = resc.coresMin; }
+                if (resc.keep_cache) { advancedFormValues[KEEP_CACHE_RAM_FIELD] = resc.keep_cache; }
+                if (resc.acrContainerImage) { advancedFormValues[RUNNER_IMAGE_FIELD] = resc.acrContainerImage; }
+            }
+        }
+
         if (isStepChanged && isWorkflowChanged) {
             dispatch(runProcessPanelActions.SET_STEP_CHANGED(false));
             dispatch(runProcessPanelActions.SET_SELECTED_WORKFLOW(workflow));
             dispatch<any>(loadPresets(workflow.uuid));
-            dispatch(initialize(RUN_PROCESS_ADVANCED_FORM, DEFAULT_ADVANCED_FORM_VALUES));
+            dispatch(initialize(RUN_PROCESS_ADVANCED_FORM, advancedFormValues));
         }
         if (!isWorkflowChanged) {
             dispatch(runProcessPanelActions.SET_SELECTED_WORKFLOW(workflow));
             dispatch<any>(loadPresets(workflow.uuid));
-            dispatch(initialize(RUN_PROCESS_ADVANCED_FORM, DEFAULT_ADVANCED_FORM_VALUES));
+            dispatch(initialize(RUN_PROCESS_ADVANCED_FORM, advancedFormValues));
         }
     };
 
@@ -135,12 +154,11 @@ export const runProcess = async (dispatch: Dispatch<any>, getState: () => RootSt
                 API: true,
                 vcpus: advancedForm[VCPUS_FIELD],
                 ram: advancedForm[RAM_FIELD],
-                api: advancedForm[API_FIELD],
             },
             schedulingParameters: {
                 max_run_time: advancedForm[RUNTIME_FIELD]
             },
-            containerImage: 'arvados/jobs',
+            containerImage: advancedForm[RUNNER_IMAGE_FIELD],
             cwd: '/var/spool/cwl',
             command: [
                 'arvados-cwl-runner',
@@ -166,7 +184,7 @@ export const runProcess = async (dispatch: Dispatch<any>, getState: () => RootSt
 export const DEFAULT_ADVANCED_FORM_VALUES: Partial<RunProcessAdvancedFormData> = {
     [VCPUS_FIELD]: 1,
     [RAM_FIELD]: 1073741824,
-    [API_FIELD]: true,
+    [RUNNER_IMAGE_FIELD]: "arvados/jobs"
 };
 
 const normalizeInputKeys = (inputs: WorkflowInputsData): WorkflowInputsData =>
index 0400b850a2b460ca2fe2d7d80ae98da6647c9fda..d9848291c98431abf8b67dec98a461146971abd3 100644 (file)
@@ -11,7 +11,6 @@ import { ExpandIcon } from '~/components/icon/icon';
 import * as IntInput from './inputs/int-input';
 import { min } from '~/validators/min';
 import { optional } from '~/validators/optional';
-import { SwitchField } from '~/components/switch-field/switch-field';
 
 export const RUN_PROCESS_ADVANCED_FORM = 'runProcessAdvancedForm';
 
@@ -20,7 +19,7 @@ export const RUNTIME_FIELD = 'runtime';
 export const RAM_FIELD = 'ram';
 export const VCPUS_FIELD = 'vcpus';
 export const KEEP_CACHE_RAM_FIELD = 'keep_cache_ram';
-export const API_FIELD = 'api';
+export const RUNNER_IMAGE_FIELD = 'acr_container_image';
 
 export interface RunProcessAdvancedFormData {
     [OUTPUT_FIELD]?: string;
@@ -28,7 +27,7 @@ export interface RunProcessAdvancedFormData {
     [RAM_FIELD]: number;
     [VCPUS_FIELD]: number;
     [KEEP_CACHE_RAM_FIELD]?: number;
-    [API_FIELD]?: boolean;
+    [RUNNER_IMAGE_FIELD]: string;
 }
 
 export const RunProcessAdvancedForm =
@@ -96,13 +95,11 @@ export const RunProcessAdvancedForm =
                         </Grid>
                         <Grid item xs={12} md={6}>
                             <Field
-                                name={API_FIELD}
-                                component={SwitchField}
-                                switchProps={{
-                                    color: 'primary'
-                                }}
-                                label='API'
-                                helperText='When set, ARVADOS_API_HOST and ARVADOS_API_TOKEN will be set, and process will have networking enabled to access the Arvados API server.' />
+                                name={RUNNER_IMAGE_FIELD}
+                                component={TextField}
+                                label='Runner'
+                                required
+                                helperText='The container image with arvados-cwl-runner that will execute this workflow.' />
                         </Grid>
                     </Grid>
                 </ExpansionPanelDetails>