X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/02fe86a56f080ed1d5770ad6c6856a15f50ab508..e11a6fa13214f91ffc602e53574736174ca6e8e9:/src/models/workflow.ts diff --git a/src/models/workflow.ts b/src/models/workflow.ts index abc92c62..59b81a1d 100644 --- a/src/models/workflow.ts +++ b/src/models/workflow.ts @@ -4,6 +4,7 @@ import { Resource, ResourceKind } from "./resource"; import { safeLoad } from 'js-yaml'; +import { CommandOutputParameter } from "cwlts/mappings/v1.0/CommandOutputParameter"; export interface WorkflowResource extends Resource { kind: ResourceKind.WORKFLOW; @@ -22,6 +23,7 @@ export interface Workflow { inputs: CommandInputParameter[]; outputs: any[]; steps: any[]; + hints?: ProcessRequirement[]; } export interface CommandLineTool { @@ -29,6 +31,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 = @@ -123,7 +140,7 @@ export const parseWorkflowDefinition = (workflow: WorkflowResource): WorkflowRes export const getWorkflow = (workflowDefinition: WorkflowResourceDefinition) => { if (!workflowDefinition.$graph) { return undefined; } - const mainWorkflow = workflowDefinition.$graph.find(item => item.class === 'Workflow' && item.id === '#main'); + const mainWorkflow = workflowDefinition.$graph.find(item => item.id === '#main'); return mainWorkflow ? mainWorkflow : undefined; @@ -136,8 +153,19 @@ export const getWorkflowInputs = (workflowDefinition: WorkflowResourceDefinition : undefined; }; +export const getWorkflowOutputs = (workflowDefinition: WorkflowResourceDefinition) => { + if (!workflowDefinition) { return undefined; } + return getWorkflow(workflowDefinition) + ? getWorkflow(workflowDefinition)!.outputs + : undefined; +}; + export const getInputLabel = (input: CommandInputParameter) => { - return `${input.label || input.id}`; + return `${input.label || input.id.split('/').pop()}`; +}; + +export const getIOParamId = (input: CommandInputParameter | CommandOutputParameter) => { + return `${input.id.split('/').pop()}`; }; export const isRequiredInput = ({ type }: CommandInputParameter) => { @@ -157,10 +185,13 @@ export const isPrimitiveOfType = (input: GenericCommandInputParameter, : input.type === type; export const isArrayOfType = (input: GenericCommandInputParameter, type: CWLType) => - typeof input.type === 'object' && - input.type.type === 'array' - ? input.type.items === type - : false; + input.type instanceof Array + ? (input.type.filter(t => typeof t === 'object' && + t.type === 'array' && + t.items === type).length > 0) + : (typeof input.type === 'object' && + input.type.type === 'array' && + input.type.items === type); export const stringifyInputType = ({ type }: CommandInputParameter) => { if (typeof type === 'string') {