15407: Fixes mount handling. Re-run process now shows dialog without erroring.
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Mon, 19 Aug 2019 17:39:22 +0000 (14:39 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Mon, 19 Aug 2019 19:44:09 +0000 (16:44 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima@veritasgenetics.com>

src/models/workflow.ts
src/store/processes/process-input-actions.ts
src/store/processes/processes-actions.ts
src/views-components/process-input-dialog/process-input-dialog.tsx

index a858c0d7dec98e62d65087740bdf902d1153ec08..4fc70419e5be1fbd6b5ddeb86c321e5ad99dcdd8 100644 (file)
@@ -11,9 +11,8 @@ export interface WorkflowResource extends Resource {
     description: string;
     definition: string;
 }
-export interface WorkflowResoruceDefinition {
+export interface WorkflowResourceDefinition {
     cwlVersion: string;
-    graph?: Array<Workflow | CommandLineTool>;
     $graph?: Array<Workflow | CommandLineTool>;
 }
 export interface Workflow {
@@ -117,23 +116,16 @@ export type DirectoryArrayCommandInputParameter = GenericArrayCommandInputParame
 export type WorkflowInputsData = {
     [key: string]: boolean | number | string | File | Directory;
 };
-export const parseWorkflowDefinition = (workflow: WorkflowResource): WorkflowResoruceDefinition => {
+export const parseWorkflowDefinition = (workflow: WorkflowResource): WorkflowResourceDefinition => {
     const definition = safeLoad(workflow.definition);
     return definition;
 };
 
-export const getWorkflowInputs = (workflowDefinition: WorkflowResoruceDefinition) => {
-    if (workflowDefinition.graph) {
-        const mainWorkflow = workflowDefinition.graph.find(item => item.class === 'Workflow' && item.id === '#main');
-        return mainWorkflow
-            ? mainWorkflow.inputs
-            : undefined;
-    } else {
-        const mainWorkflow = workflowDefinition.$graph!.find(item => item.class === 'Workflow' && item.id === '#main');
-        return mainWorkflow
-            ? mainWorkflow.inputs
-            : undefined;
-    }
+export const getWorkflowInputs = (workflowDefinition: WorkflowResourceDefinition) => {
+    const mainWorkflow = workflowDefinition.$graph!.find(item => item.class === 'Workflow' && item.id === '#main');
+    return mainWorkflow
+        ? mainWorkflow.inputs
+        : undefined;
 };
 
 export const getInputLabel = (input: CommandInputParameter) => {
index 7ce2749c9251db0a5242784303d11db6128d848b..88624d082334c15b49a076850960a9c9ab0d185c 100644 (file)
@@ -15,10 +15,10 @@ export const openProcessInputDialog = (processUuid: string) =>
         const process = getProcess(processUuid)(getState().resources);
         if (process) {
             const data: any = process;
-            if (data && data.containerRequest.mounts.varLibCwlWorkflowJson && data.containerRequest.mounts.varLibCwlWorkflowJson.content.graph.filter((a: any) => a.class === 'Workflow')[0] && data.containerRequest.mounts.varLibCwlWorkflowJson.content.graph.filter((a: any) => a.class === 'Workflow')[0].inputs.length > 0) {
+            if (data && data.containerRequest.mounts["/var/lib/cwl/workflow.json"] && data.containerRequest.mounts["/var/lib/cwl/workflow.json"].content.$graph.find((a: any) => a.class === 'Workflow' && a.id === '#main') && data.containerRequest.mounts["/var/lib/cwl/workflow.json"].content.$graph.find((a: any) => a.class === 'Workflow' && a.id === '#main').inputs.length > 0) {
                 dispatch(dialogActions.OPEN_DIALOG({ id: PROCESS_INPUT_DIALOG_NAME, data }));
             } else {
                 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'There are no inputs in this process!', kind: SnackbarKind.ERROR }));
             }
         }
-    }; 
\ No newline at end of file
+    };
\ No newline at end of file
index c6bc1418dcbf6bd8df9b13b598d1109b2d65a87a..91996dde45bd762540aa199beb1e8c5d7c129ca6 100644 (file)
@@ -15,7 +15,6 @@ import { projectPanelActions } from '~/store/project-panel/project-panel-action'
 import { navigateToRunProcess } from '~/store/navigation/navigation-action';
 import { goToStep, runProcessPanelActions } from '~/store/run-process-panel/run-process-panel-actions';
 import { getResource } from '~/store/resources/resources';
-import { getInputValue } from "~/views-components/process-input-dialog/process-input-dialog";
 import { initialize } from "redux-form";
 import { RUN_PROCESS_BASIC_FORM, RunProcessBasicFormData } from "~/views/run-process-panel/run-process-basic-form";
 import { RunProcessAdvancedFormData, RUN_PROCESS_ADVANCED_FORM } from "~/views/run-process-panel/run-process-advanced-form";
@@ -86,8 +85,9 @@ export const reRunProcess = (processUuid: string, workflowUuid: string) =>
         const workflow = workflows.find(workflow => workflow.uuid === workflowUuid);
         if (workflow && process) {
             const newValues = getInputs(process);
-            process.mounts.varLibCwlWorkflowJson.content.graph[1].inputs = newValues;
-            const stringifiedDefinition = JSON.stringify(process.mounts.varLibCwlWorkflowJson.content);
+            process.mounts["/var/lib/cwl/workflow.json"].content.$graph.find(
+                (a: any) => a.id === '#main').inputs = newValues;
+            const stringifiedDefinition = JSON.stringify(process.mounts["/var/lib/cwl/workflow.json"].content);
             const newWorkflow = { ...workflow, definition: stringifiedDefinition };
 
             const basicInitialData: RunProcessBasicFormData = { name: `Copy of: ${process.name}`, description: process.description };
@@ -113,9 +113,18 @@ export const reRunProcess = (processUuid: string, workflowUuid: string) =>
     };
 
 const getInputs = (data: any) =>
-    data && data.mounts.varLibCwlWorkflowJson ? data.mounts.varLibCwlWorkflowJson.content.graph[1].inputs.map((it: any) => (
-        { type: it.type, id: it.id, label: it.label, default: getInputValue(it.id, data.mounts.varLibCwlCwlInputJson.content), doc: it.doc }
-    )) : [];
+    data && data.mounts["/var/lib/cwl/workflow.json"] ? data.mounts["/var/lib/cwl/workflow.json"].content.$graph.find(
+        (a: any) => a.id === '#main').inputs.map(
+            (it: any) => (
+                {
+                    type: it.type,
+                    id: it.id,
+                    label: it.label,
+                    default: data.mounts["/var/lib/cwl/cwl.input.json"].content[it.id],
+                    doc: it.doc
+                }
+            )
+        ) : [];
 
 export const openRemoveProcessDialog = (uuid: string) =>
     (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
index edb4bc6835892e81bd7c9bebe5fdd5213da57041..1650c902db0adacde3b85b7f69c81be8d25dfa07 100644 (file)
@@ -32,16 +32,15 @@ export const ProcessInputDialog = withDialog(PROCESS_INPUT_DIALOG_NAME)(
 );
 
 const getInputs = (data: any) =>
-    data && data.mounts.varLibCwlWorkflowJson ? data.mounts.varLibCwlWorkflowJson.content.graph.filter((a: any) => a.class === 'Workflow')[0].inputs.map((it: any) => (
-        { type: it.type, id: it.id, label: it.label, value: getInputValue(it.id, data.mounts.varLibCwlCwlInputJson.content), disabled: true }
-    )) : [];
-
-const snakeToCamel = (s: string) => {
-    const a = s.split('/');
-    return a[1].replace(/(\_\w)/g, (m: string) => m[1].toUpperCase());
-};
-
-export const getInputValue = (id: string, data: any) => {
-    const a = snakeToCamel(id);
-    return data[a];
-};
\ No newline at end of file
+    data && data.mounts["/var/lib/cwl/workflow.json"] ? data.mounts["/var/lib/cwl/workflow.json"].content.$graph.find(
+        (a: any) => a.id === '#main').inputs.map(
+            (it: any) => (
+                {
+                    type: it.type,
+                    id: it.id,
+                    label: it.label,
+                    value: data.mounts["/var/lib/cwl/cwl.input.json"].content[it.id],
+                    disabled: true
+                }
+            )
+        ) : [];