Passing a fixed array of strings to a step input

Hello,

I’ve got a workflow step input that is used as a scatter parameter and whose values are a fixed list of strings: I want that step to scatter on [“IW1”, “IW2”, “IW3”]

I’ve got this far:

- class: Workflow
  doc: SNAP SAR Calibration
  id: main
  inputs:
    #subswath:
    #  type: string[]
    primary:
      doc: Sentinel-1 SLC primary product SAFE Directory
      label: Sentinel-1 SLC primary product SAFE Directory
      type: Directory
    secondary: 
      doc: Sentinel-1 SLC secondary product SAFE Directory
      label: Sentinel-1 SLC secondary product SAFE Directory
      type: Directory
  label: SNAP SAR Calibration
  outputs:
  - id: wf_outputs
    outputSource:
    - node_3/results
    type: Directory
      
  requirements:
  - class: ScatterFeatureRequirement
  - class: SubworkflowFeatureRequirement
  - class: StepInputExpressionRequirement
  - class: InlineJavascriptRequirement

  steps:
    node_01:
      in: 
        input_reference: primary
      out:
      - results
      run: '#stac2safe'
    node_02:
      in: 
        input_reference: secondary
      out:
      - results
      run: '#stac2safe'
    node_1:
      in:
        inp1: node_01/results
        inp2: node_02/results
        inp3: 
          valueFrom: ["IW1", "IW2", "IW3"]
      out:
      - results
      run: '#ifg'
      scatter: inp3
      scatterMethod: dotproduct
    node_2:
      in: 
        inp1: 
          source: node_1/results
          valueFrom: |
            ${
              return self[0]; 
            }
        inp2: 
          source: node_1/results
          valueFrom: |
            ${
              return self[1];
            }
        inp3: 
          source: node_1/results
          valueFrom: |
            ${
              return self[2];
            }

This outputs:

INFO /srv/conda/bin/cwltool 3.0.20210319143721
INFO Resolved 'gpt-stac-topsar-stac.cwl' to 'file:///home/fbrito/work/cwl-snap-graph-topsar/gpt-stac-topsar-stac.cwl'
ERROR Tool definition failed validation:
gpt-stac-topsar-stac.cwl:163:3:   Object `gpt-stac-topsar-stac.cwl#main` is not valid because
                                   tried `Workflow` but
gpt-stac-topsar-stac.cwl:190:3:       the `steps` field is not valid because
                                       tried array of <WorkflowStep> but
gpt-stac-topsar-stac.cwl:203:5:           item is invalid because
gpt-stac-topsar-stac.cwl:204:7:             the `in` field is not valid because
gpt-stac-topsar-stac.cwl:207:9:               item is invalid because
gpt-stac-topsar-stac.cwl:208:11:               the `valueFrom` field is not valid because
                                                 value is a CommentedSeq, expected null or string
                                                 or Expression

Am I missing something obvious? I’ve tried several combinations while looking at similar questions but no luck.

PS: CWL really simplifies our life :wink:

Per the specification for WorkflowStepInput (Common Workflow Language (CWL) Workflow Description, v1.2), accepted types for valueFrom are limited to string and Expression. You’ll notice that the accepted type for default is Any.

What happens if you instead use default rather than valueFrom?

1 Like

Thanks for your feedback @tate

I’ve tried using an Expression but I must have done that the wrong way.

This works fine:

   node_01:
     in: 
       input_reference: primary
     out:
     - results
     run: '#stac2safe'
   node_02:
     in: 
       input_reference: secondary
     out:
     - results
     run: '#stac2safe'
   node_1:
     in:
       inp1: node_01/results
       inp2: node_02/results
       inp3: 
         default: ["IW1", "IW2", "IW3"]
     out:
     - results
     run: '#ifg'
     scatter: inp3
     scatterMethod: dotproduct

Thanks!

1 Like