From 59a7af19f6889e79b1b9a4348e9253f3fa0f50c3 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Mon, 19 Aug 2019 14:39:22 -0300 Subject: [PATCH] 15407: Fixes mount handling. Re-run process now shows dialog without erroring. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- src/models/workflow.ts | 22 ++++++---------- src/store/processes/process-input-actions.ts | 4 +-- src/store/processes/processes-actions.ts | 21 +++++++++++----- .../process-input-dialog.tsx | 25 +++++++++---------- 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/models/workflow.ts b/src/models/workflow.ts index a858c0d7..4fc70419 100644 --- a/src/models/workflow.ts +++ b/src/models/workflow.ts @@ -11,9 +11,8 @@ export interface WorkflowResource extends Resource { description: string; definition: string; } -export interface WorkflowResoruceDefinition { +export interface WorkflowResourceDefinition { cwlVersion: string; - graph?: Array; $graph?: Array; } 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) => { diff --git a/src/store/processes/process-input-actions.ts b/src/store/processes/process-input-actions.ts index 7ce2749c..88624d08 100644 --- a/src/store/processes/process-input-actions.ts +++ b/src/store/processes/process-input-actions.ts @@ -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 diff --git a/src/store/processes/processes-actions.ts b/src/store/processes/processes-actions.ts index c6bc1418..91996dde 100644 --- a/src/store/processes/processes-actions.ts +++ b/src/store/processes/processes-actions.ts @@ -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) => { diff --git a/src/views-components/process-input-dialog/process-input-dialog.tsx b/src/views-components/process-input-dialog/process-input-dialog.tsx index edb4bc68..1650c902 100644 --- a/src/views-components/process-input-dialog/process-input-dialog.tsx +++ b/src/views-components/process-input-dialog/process-input-dialog.tsx @@ -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 + } + ) + ) : []; -- 2.30.2