Question: CWL: how to set default values
1
gravatar for bird77
3.7 years ago by
bird7760
bird7760 wrote:

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?

cwl common workflow language • 2.2k views
ADD COMMENTlink modified 3.6 years ago by denis.yuen100 • written 3.7 years ago by bird7760
4
gravatar for denis.yuen
3.6 years ago by
denis.yuen100
OICR
denis.yuen100 wrote:

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 COMMENTlink written 3.6 years ago by denis.yuen100
3
gravatar for Michael R. Crusoe
3.6 years ago by
Common Workflow Language project
Michael R. Crusoe1.8k wrote:

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 COMMENTlink written 3.6 years ago by Michael R. Crusoe1.8k

Bug posted: https://github.com/ga4gh/dockstore/issues/484

ADD REPLYlink written 3.6 years ago by bird7760
1

Issue closed on Nov 23, 2016

ADD REPLYlink written 3.5 years ago by bird7760

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 REPLYlink modified 4 weeks ago • written 4 weeks ago by steve2.5k
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: 1610 users visited in the last hour