How to specify an optional input for a complex type in CWL?
1
0
Entering edit mode
8.5 years ago
anton.khodak ▴ 10

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 • 4.8k views
ADD COMMENT
1
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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 REPLY
4
Entering edit mode
8.3 years ago

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 COMMENT
0
Entering edit mode
ADD REPLY

Login before adding your answer.

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