How do I pass literals in CWL workflows?
1
0
Entering edit mode
3.9 years ago
thomas.e ▴ 110

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.9k views
ADD COMMENT
0
Entering edit mode

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 REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
1
Entering edit mode
3.8 years ago
awilke1972 ▴ 20

an other option is adding a default:

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

ADD COMMENT
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode
ADD REPLY

Login before adding your answer.

Traffic: 2227 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6