rabix / composer

Visual and code editor for Common Workflow Language
http://rabix.io/
Apache License 2.0
301 stars 72 forks source link

Are expressiontools supported by rabix composer? #407

Open zymergen-mbarton opened 6 years ago

zymergen-mbarton commented 6 years ago

I've created expressiontool type steps manually but I'm not able to manually import them into my workflow. They do appear and work if I manually edit my workflow cwl document and add them. Are there any guidelines around using expression tool steps? I tried searching the issues before creating this, apologies if this is already covered somewhere.

ghost commented 6 years ago

Hi @zymergen-mbarton

I see we missed a spot regarding UI elements. It looks like we can parse and edit parameters for expression tool, but the only way to introduce one is to type the code directly into the code panel.

Once you have the code in the workflow, you can set parameters just like for any other tool

As an example, I set up a stub workflow with Rabix Composer:

class: Workflow
cwlVersion: v1.0
id: expression_tool_test
label: Expression tool WF stub
$namespaces:
  sbg: 'https://www.sevenbridges.com'
inputs:
  - id: input
    type: File
    'sbg:x': -358.8203125
    'sbg:y': 113.5
outputs:
  - id: output
    outputSource:
      - file_cat/output
    type: File?
    'sbg:x': 32.1796875
    'sbg:y': 18.5
steps:
  - id: file_cat
    in:
      - id: input
        source: input
    out:
      - id: output
    run: ./file-cat.cwl
    label: file-cat
    'sbg:x': -116.3984375
    'sbg:y': 21
requirements: []

where file-cat.cwl is this simple tool

class: CommandLineTool
cwlVersion: v1.0
$namespaces:
  sbg: 'https://www.sevenbridges.com'
id: file_cat
baseCommand:
  - echo
inputs:
  - id: input
    type: File
    inputBinding:
      position: 1
      prefix: ''
      shellQuote: false
      valueFrom: $("$(cat " + inputs.input.path + ")")
  - id: text
    type: string
    inputBinding:
      position: 2
outputs:
  - id: output
    type: File?
    outputBinding:
      glob: '*out.txt'
label: file-cat
requirements:
  - class: ShellCommandRequirement
  - class: DockerRequirement
    dockerPull: ubuntu
  - class: InlineJavascriptRequirement
stdout: out.txt

Now, I use the CODE panel to directly type in a ExpressionTool code.

  - id: expr_tool
    in:
      - id: word1
        default: Hello
      - id: word2
        default: World
    out:
      - id: out
    run:
      class: ExpressionTool
      cwlVersion: v1.0
      expression: '$({"out": inputs.word1 + inputs.word2 })'
      id: expr_tool
      inputs:
        - id: word1
          label: Word 1
          type: string
        - id: word2
          label: Word 2
          type: string
      outputs:
        - id: out
          label: Word out
          type: string

Switching back to the Visual Editor I can now manipulate the ExpressionTool as usual.

screen shot 2018-09-14 at 5 33 56 pm

We should have a UI concept for the Expression Tool, but I think there may be subtleties with how it exists as an independent element. I will talk with @marijanlekic about what we can do about a UI concept.

I hope this might help you a bit.

-Kaushik

zymergen-mbarton commented 6 years ago

Thanks Kaushik. Yes, I've been manually adding in ExpressionTools and they've worked as part of workflows etc.. I think, in the shorter term, if there was a way to drag in existing expression tool CWL files that would be useful, and mean that workflows wouldn't have to be editted manually to add them which seems to be the tricker part.