Question: How do I pass literals in CWL workflows?
0
gravatar for thomas.e
3.3 years ago by
thomas.e110
thomas.e110 wrote:

I want to pass a literal to a tool, for example, the number of threads, in a workflow step.

The parameter is defined as an optional int in the tool itself:

  threads:
    type: int?
    inputBinding:
      prefix: --threads

If I do this in the workflow:

      threads:
        valueFrom: 4

cwltool complains that the value is an int and should be a string.

(p) [thomas.e@vc7hpc-040 test]$ cwltool --debug ../src/pdx-pl.cwl --read1 ../data/S1_R1.fastq.gz --read2 ../data/S1_R2.fastq.gz 
/stornext/Home/data/allstaff/t/thomas.e/dev/pdx-genome/test/p/bin/cwltool 1.0.20170721221557
Resolved '../src/pdx-pl.cwl' to 'file:///stornext/Home/data/allstaff/t/thomas.e/dev/pdx-genome/src/pdx-pl.cwl'
Tool definition failed validation:
../src/pdx-pl.cwl:3:1: Object ../src/pdx-pl.cwl is not valid because
                         tried Workflow but
../src/pdx-pl.cwl:102:1:     the steps field is not valid because
                               tried array of <workflowstep> but
../src/pdx-pl.cwl:503:3:         item is invalid because
../src/pdx-pl.cwl:506:5:           the in field is not valid because
../src/pdx-pl.cwl:525:7:             item is invalid because
../src/pdx-pl.cwl:526:9:               the valueFrom field is not valid because
                                         - tried string but
                                             the value is not string
                                         - tried Expression but
                                             value is a int but expected a string

If I pass a string it complains that it is not an int

[step trim] start
Exception on step 'trim'
[step trim] Cannot make job: Invalid job input record:
the nthreads field is not valid because
  tried int but
    '4' is not int

Currently, I using JS but it seems it should be easier:

      threads:
        valueFrom: ${ return 27; }

cwl • 1.6k views
ADD COMMENTlink modified 3.3 years ago by awilke197220 • written 3.3 years ago by thomas.e110

how about

valueFrom: $( 27 )

that is a bit easier :-)

To me this looks like a bug in the CWL implementation as your 4 should be interpreted as an int 4. But I did not test it myself so I can't tell for sure.

ADD REPLYlink modified 3.3 years ago • written 3.3 years ago by wolfganggerlach198150

ah, valueFrom can only be a string or an expressson, according to the docs. That is your problem.

ADD REPLYlink written 3.3 years ago by wolfganggerlach198150

So a case of "broken as designed". Seems to me other literals should be allowed.

ADD REPLYlink written 3.3 years ago by thomas.e110
1
gravatar for awilke1972
3.3 years ago by
awilke197220
awilke197220 wrote:

an other option is adding a default:

threads: type: int? default: 4 inputBinding: prefix: --threads

ADD COMMENTlink written 3.3 years ago by awilke197220

I think this is only for the CommandLineTool where it is not appropriate to set a default.

ADD REPLYlink written 3.3 years ago by thomas.e110

This is how I pass literals in Workflows, see https://github.com/ProteinsWebTeam/ebi-metagenomics-cwl/blob/master/workflows/emg-pipeline-v3.cwl#L194

ADD REPLYlink written 3.3 years ago by Michael R. Crusoe1.8k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1132 users visited in the last hour