CWL: how to set default values
2
1
Entering edit mode
8.0 years ago
bird77 ▴ 80

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?

Common-Workflow-Language cwl • 4.8k views
ADD COMMENT
4
Entering edit mode
8.0 years ago
denis.yuen ▴ 100

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
ADD COMMENT
3
Entering edit mode
8.0 years ago

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.

ADD COMMENT
0
Entering edit mode
ADD REPLY
1
Entering edit mode

Issue closed on Nov 23, 2016

ADD REPLY
0
Entering edit mode

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.

ADD REPLY

Login before adding your answer.

Traffic: 1978 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