Bug posted: https://github.com/ga4gh/dockstore/issues/484
How can I set default values for cwl files?
Here is my test.cwl file
cwlVersion: v1.0
class: CommandLineTool
baseCommand: echo
inputs:
example_flag:
type: boolean
default: true
inputBinding:
position: 1
prefix: -f
example_string:
type: string
default: "abc"
inputBinding:
position: 3
prefix: --example-string
example_int:
type: int
default: 5
inputBinding:
position: 2
prefix: -i
separate: false
example_file:
type: File?
inputBinding:
prefix: --file=
separate: false
position: 4
outputs: []
With
$ dockstore tool convert cwl2json --cwl test.cwl
I get the following output
{
"example_string": "fill me in",
"example_file": {
"path": "fill me in",
"class": "File"
},
"example_flag": false,
"example_int": 0
}
Where are the default values I set in the test.cwl file?
2 answers
As a heads-up, this is now a feature for Dockstore 1.1. You should be able to do the following
$ dockstore tool convert cwl2json --cwl test.cwl
{
"example_string": "abc",
"example_file": {
"path": "fill me in",
"class": "File"
},
"example_flag": true,
"example_int": 5
}
$ dockstore tool convert cwl2yaml --cwl test.cwl
example_string: abc
example_file:
path: fill me in
class: File
example_flag: true
example_int: 5
$ dockstore tool convert cwl2yaml --cwl test.cwl > test.yaml
$ vim test.yaml
$ dockstore tool launch --entry test.cwl --local-entry --yaml test.yaml
Hello,
if you want to use the default values for a particular input then do not list that parameter in your input document.
You could request the dockstore developers to include the default values when generating the template input document, or you could contribute that fix yourself. Additionally I would suggest that they generate YAML formatted input templates instead of JSON as they are easier to read and write.
Issue closed on Nov 23, 2016
I would suggest that they generate YAML formatted input templates instead of JSON
few languages and frameworks which I have used have support for writing YAML out of the box, thus leading to the constant requirements for including YAML library dependencies in your software stack. On the other hand, I have yet to find a language or framework where JSON is not included by default. Additionally, the indentation-heavy nature of YAML actually impairs readability greatly, because its nearly impossible to understand the structure of an object with nested attributes in YAML just by looking at it, the difference between 4, 6, 8, 12, etc., whitespaces becomes impossible to distinguish by eye. I think we really need to be encouraging JSON everywhere. YAML just makes everything worse in the long run.
Log in to answer this question.