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; }
how about
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.
ah, valueFrom can only be a string or an expressson, according to the docs. That is your problem.
So a case of "broken as designed". Seems to me other literals should be allowed.