Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima@veritasgenetics.com>
export type ProcessResource = ContainerRequestResource;
+export const MOUNT_PATH_CWL_WORKFLOW = '/var/lib/cwl/workflow.json';
+export const MOUNT_PATH_CWL_INPUT = '/var/lib/cwl/cwl.input.json';
+
export const createWorkflowMounts = (workflow: WorkflowResource, inputs: WorkflowInputsData): { [path: string]: MountType } => {
return {
'/var/spool/cwl': {
};
export const getWorkflowInputs = (workflowDefinition: WorkflowResourceDefinition) => {
- const mainWorkflow = workflowDefinition.$graph!.find(item => item.class === 'Workflow' && item.id === '#main');
+ if (!workflowDefinition.$graph) { return undefined; }
+ const mainWorkflow = workflowDefinition.$graph.find(item => item.class === 'Workflow' && item.id === '#main');
return mainWorkflow
? mainWorkflow.inputs
: undefined;
import { dialogActions } from '~/store/dialog/dialog-actions';
import { RootState } from '~/store/store';
import { Dispatch } from 'redux';
-import { getProcess } from '~/store/processes/process';
+import { getProcess, Process } from '~/store/processes/process';
import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions';
+import { getWorkflowInputs } from '~/models/workflow';
+import { JSONMount } from '~/models/mount-types';
+import { MOUNT_PATH_CWL_WORKFLOW } from '~/models/process';
export const PROCESS_INPUT_DIALOG_NAME = 'processInputDialog';
const process = getProcess(processUuid)(getState().resources);
if (process) {
const data: any = process;
- 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) {
+ const inputs = getInputsFromWFMount(process);
+ if (inputs && 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
+ };
+
+const getInputsFromWFMount = (process: Process) => {
+ if (!process || !process.containerRequest[MOUNT_PATH_CWL_WORKFLOW] ) { return undefined; }
+ const mnt = process.containerRequest.mounts[MOUNT_PATH_CWL_WORKFLOW] as JSONMount;
+ return getWorkflowInputs(mnt.content);
+};
\ No newline at end of file
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";
+import { MOUNT_PATH_CWL_WORKFLOW, MOUNT_PATH_CWL_INPUT } from '~/models/process';
+import { getWorkflowInputs } from "~/models/workflow";
export const loadProcess = (containerRequestUuid: string) =>
async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository): Promise<Process> => {
const workflows = getState().runProcessPanel.searchWorkflows;
const workflow = workflows.find(workflow => workflow.uuid === workflowUuid);
if (workflow && process) {
- const newValues = getInputs(process);
- 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);
+ let inputs = getWorkflowInputs(process.mounts[MOUNT_PATH_CWL_WORKFLOW]);
+ inputs = getInputs(process);
+ const stringifiedDefinition = JSON.stringify(process.mounts[MOUNT_PATH_CWL_WORKFLOW].content);
const newWorkflow = { ...workflow, definition: stringifiedDefinition };
const basicInitialData: RunProcessBasicFormData = { name: `Copy of: ${process.name}`, description: process.description };
}
};
-const getInputs = (data: any) =>
- 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
- }
- )
- ) : [];
+const getInputs = (data: any) => {
+ if (!data || !data.mounts || !data.mounts[MOUNT_PATH_CWL_WORKFLOW]) { return []; }
+ const inputs = getWorkflowInputs(data.mounts[MOUNT_PATH_CWL_WORKFLOW].content);
+ return inputs ? inputs.map(
+ (it: any) => (
+ {
+ type: it.type,
+ id: it.id,
+ label: it.label,
+ default: data.mounts[MOUNT_PATH_CWL_INPUT].content[it.id],
+ doc: it.doc
+ }
+ )
+ ) : [];
+};
export const openRemoveProcessDialog = (uuid: string) =>
(dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
import { withDialog } from "~/store/dialog/with-dialog";
import { PROCESS_INPUT_DIALOG_NAME } from '~/store/processes/process-input-actions';
import { RunProcessInputsForm } from "~/views/run-process-panel/run-process-inputs-form";
+import { MOUNT_PATH_CWL_WORKFLOW, MOUNT_PATH_CWL_INPUT } from "~/models/process";
+import { getWorkflowInputs } from "~/models/workflow";
export const ProcessInputDialog = withDialog(PROCESS_INPUT_DIALOG_NAME)(
(props: WithDialogProps<any>) =>
</Dialog>
);
-const getInputs = (data: any) =>
- 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
- }
- )
- ) : [];
+const getInputs = (data: any) => {
+ if (!data || !data.mounts || !data.mounts[MOUNT_PATH_CWL_WORKFLOW]) { return []; }
+ const inputs = getWorkflowInputs(data.mounts[MOUNT_PATH_CWL_WORKFLOW].content);
+ return inputs ? inputs.map(
+ (it: any) => (
+ {
+ type: it.type,
+ id: it.id,
+ label: it.label,
+ value: data.mounts[MOUNT_PATH_CWL_INPUT].content[it.id],
+ disabled: true
+ }
+ )
+ ) : [];
+};