Add workflow based mounts generator
authorMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Tue, 2 Oct 2018 06:11:26 +0000 (08:11 +0200)
committerMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Tue, 2 Oct 2018 06:11:26 +0000 (08:11 +0200)
Feature #13863

Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski@contractors.roche.com>

src/models/process.ts
src/models/workflow.ts
src/views/run-process-panel/run-process-inputs-form.tsx

index 1e04cb10f395de5284765fbb50244d2e45d4ea1d..9762d50411d45c40be0bb9efbc389e10e3e2e35e 100644 (file)
@@ -3,5 +3,29 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import { ContainerRequestResource } from "./container-request";
+import { MountType, MountKind } from '~/models/mount-types';
+import { WorkflowResource, parseWorkflowDefinition } from '~/models/workflow';
+import { WorkflowInputsData } from './workflow';
 
 export type ProcessResource = ContainerRequestResource;
+
+export const createWorkflowMounts = (workflow: WorkflowResource, inputs: WorkflowInputsData): { [path: string]: MountType } => {
+    return {
+        '/var/spool/cwl': {
+            kind: MountKind.COLLECTION,
+            writable: true,
+        },
+        'stdout': {
+            kind: MountKind.MOUNTED_FILE,
+            path: '/var/spool/cwl/cwl.output.json',
+        },
+        '/var/lib/cwl/workflow.json': {
+            kind: MountKind.JSON,
+            content: parseWorkflowDefinition(workflow)
+        },
+        '/var/lib/cwl/cwl.input.json': {
+            kind: MountKind.JSON,
+            content: inputs,
+        }
+    };
+};
index 88ceb6ed5400714e26a35d523181c5fabe041c4f..d7d97c4c962401bfc7bd5ff655ebe88fdaf4d92d 100644 (file)
@@ -107,6 +107,9 @@ export type StringArrayCommandInputParameter = GenericArrayCommandInputParameter
 export type FileArrayCommandInputParameter = GenericArrayCommandInputParameter<CWLType.FILE, File>;
 export type DirectoryArrayCommandInputParameter = GenericArrayCommandInputParameter<CWLType.DIRECTORY, Directory>;
 
+export type WorkflowInputsData = {
+    [key: string]: boolean | number | string | File | Directory;
+};
 export const parseWorkflowDefinition = (workflow: WorkflowResource): WorkflowResoruceDefinition => {
     const definition = safeLoad(workflow.definition);
     return definition;
index b92899625151f3eee16839cc04172df4ac8f88bb..e92b1e47f35f21cfe747a4daef9d5738d8e7fecd 100644 (file)
@@ -7,7 +7,7 @@ import { reduxForm, InjectedFormProps } from 'redux-form';
 import { CommandInputParameter, CWLType, IntCommandInputParameter, BooleanCommandInputParameter, FileCommandInputParameter } from '~/models/workflow';
 import { IntInput } from '~/views/run-process-panel/inputs/int-input';
 import { StringInput } from '~/views/run-process-panel/inputs/string-input';
-import { StringCommandInputParameter, FloatCommandInputParameter, isPrimitiveOfType } from '../../models/workflow';
+import { StringCommandInputParameter, FloatCommandInputParameter, isPrimitiveOfType, File, Directory, WorkflowInputsData } from '../../models/workflow';
 import { FloatInput } from '~/views/run-process-panel/inputs/float-input';
 import { BooleanInput } from './inputs/boolean-input';
 import { FileInput } from './inputs/file-input';
@@ -27,7 +27,7 @@ export const RunProcessInputsForm = compose(
             (values, input) => ({ ...values, [input.id]: input.default }),
             {}),
     })),
-    reduxForm<any, RunProcessInputFormProps>({
+    reduxForm<WorkflowInputsData, RunProcessInputFormProps>({
         form: RUN_PROCESS_INPUTS_FORM
     }))(
         (props: InjectedFormProps & RunProcessInputFormProps) =>