Question: How to specify an optional input for a complex type in CWL?
0
gravatar for anton.khodak
3.2 years ago by
anton.khodak0 wrote:

I need to pass an array as an optional argument in a CWL tool definition. I know that for primitive types ['null', <type>] works fine, but for array it generates an error:

Type property "['null', 'array']" not a valid Avro schema.

I have also tried to specify it the next way:

- id: bam_files
  type: 
  - "null"
  - type: array
    items: string

but cwltool interprets the first given type as the only one, i.e. bam_files is always null or it is a required argument when type: array goes first.

The same applies to enum type.

cwl common-workflow-language • 1.9k views
ADD COMMENTlink modified 3.0 years ago by Michael R. Crusoe1.6k • written 3.2 years ago by anton.khodak0
1

Your second approach should be the correct one. Can you provide the error when you try it that way?

ADD REPLYlink written 3.2 years ago by peter.amstutz300

I'm sorry, I checked the job file and found out that I confused an underscore with a dash in the argument name...

ADD REPLYlink written 3.2 years ago by anton.khodak0

Could you please point to the second approach in the docs? As far as I remember, I found that on GitHub, not in the documentation.

ADD REPLYlink modified 3.2 years ago • written 3.2 years ago by anton.khodak0
2
gravatar for Michael R. Crusoe
3.0 years ago by
Common Workflow Language project
Michael R. Crusoe1.6k wrote:

In this example, type: string[]? would have worked, and that is documented in the standard and the UserGuide. For more complicated situations where there is more than one valid type but the whole thing is optional then the extended syntax is needed.

inputs:
  weird_input:
    type: 
    - "null"
    - type: array
      items: string
    - type: int

Means that weird_input is optional, but if present it must be an int or an array of strings.

ADD COMMENTlink written 3.0 years ago by Michael R. Crusoe1.6k
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: 1702 users visited in the last hour