cwltool icon indicating copy to clipboard operation
cwltool copied to clipboard

Input of array of enum is not recognized by the cwltool command line input object feature

Open esanzgar opened this issue 7 years ago • 3 comments

If an input is defined as an array of enum, cwltool is unable to make a command line argument from it:

inputs:
  applications:
    type:
        - type: array
          items:
              type: enum
              symbols:
                  - a
                  - b
    inputBinding:
      itemSeparator: ","
      prefix: --applications

Expected Behavior

cwltool --debug https://raw.githubusercontent.com/esanzgar/webservice-cwl/master/docker_cwls/array_enum.cwl --application a --application b should feed --applications a,b to the tool.

Actual Behavior

cwltool --debug https://raw.githubusercontent.com/esanzgar/webservice-cwl/master/docker_cwls/array_enum.cwl --application a --application b

Can't make command line argument from [ordereddict([('type', 'array'), ('items', ordereddict([('type', 'enum'), ('symbols', [u'https://raw.githubusercontent.com/esanzgar/webservice-cwl/master/docker_cwls/array_enum.cwl#applications/a', u'https://raw.githubusercontent.com/esanzgar/webservice-cwl/master/docker_cwls/array_enum.cwl#applications/b']), ('name', u'applicationsbf7fee68-a1f1-410b-a430-39c74fc57643')]))])]
usage: https://raw.githubusercontent.com/esanzgar/webservice-cwl/master/docker_cwls/array_enum.cwl
       [-h] [job_order]
https://raw.githubusercontent.com/esanzgar/webservice-cwl/master/docker_cwls/array_enum.cwl: error: unrecognized arguments: --application --application b

Workflow Code

cwltool --debug https://raw.githubusercontent.com/esanzgar/webservice-cwl/master/docker_cwls/array_enum.cwl --application a --application b

Your Environment

  • cwltool version: 1.0.20170928192020

esanzgar avatar Nov 30 '17 11:11 esanzgar

Thank you @esanzgar for your report

As a reminder, you can always create a YAML/JSON input file if the command line parser doesn't work. Though I find the command line interface to be very convenient!

mr-c avatar Nov 30 '17 11:11 mr-c

As suggested here, I also tried this combination but it results in an exception:

inputs:
  applications:
    type:
        - "null"
        - type: array
          items:
              type: enum
              symbols:
                  - a
                  - b
    inputBinding:
      itemSeparator: ","
      prefix: --applications

Full Traceback

Traceback (most recent call last):
  File "/Users/eduardo/.config/virtualenvs/cwl/lib/python2.7/site-packages/cwltool/main.py", line 279, in single_job_executor
    for r in jobiter:
  File "/Users/eduardo/.config/virtualenvs/cwl/lib/python2.7/site-packages/cwltool/draft2tool.py", line 332, in job
    builder = self._init_job(job_order, **kwargs)
  File "/Users/eduardo/.config/virtualenvs/cwl/lib/python2.7/site-packages/cwltool/process.py", line 609, in _init_job
    builder.bindings.extend(builder.bind_input(self.inputs_record_schema, builder.job))
  File "/Users/eduardo/.config/virtualenvs/cwl/lib/python2.7/site-packages/cwltool/builder.py", line 120, in bind_input
    bindings.extend(self.bind_input(f, datum[f["name"]], lead_pos=lead_pos, tail_pos=f["name"]))
  File "/Users/eduardo/.config/virtualenvs/cwl/lib/python2.7/site-packages/cwltool/builder.py", line 99, in bind_input
    avsc = AvroSchemaFromJSONData(t, self.names)
  File "/Users/eduardo/.config/virtualenvs/cwl/lib/python2.7/site-packages/avro/schema.py", line 746, in make_avsc_object
    return ArraySchema(items, names, other_props)
  File "/Users/eduardo/.config/virtualenvs/cwl/lib/python2.7/site-packages/avro/schema.py", line 492, in __init__
    raise SchemaParseException(fail_msg)

SchemaParseException: Items schema (ordereddict([('type', 'enum'), ('symbols', [u'a', u'b']), ('name', u'applicationsba75a91b-31b9-41a1-8a12-42de373b7dec')])) not a valid Avro schema: The name "applicationsba75a91b-31b9-41a1-8a12-42de373b7dec" is already in use. (known names: ['outputs_record_schema', u'File_class', u'applicationsba75a91b-31b9-41a1-8a12-42de373b7dec', 'File', 'Directory', 'input_record_schema', u'Directory_class', 'Any'])
Workflow error, try again with --debug for more information:
Items schema (ordereddict([('type', 'enum'), ('symbols', [u'a', u'b']), ('name', u'applicationsba75a91b-31b9-41a1-8a12-42de373b7dec')])) not a valid Avro schema: The name "applicationsba75a91b-31b9-41a1-8a12-42de373b7dec" is already in use. (known names: ['outputs_record_schema', u'File_class', u'applicationsba75a91b-31b9-41a1-8a12-42de373b7dec', 'File', 'Directory', 'input_record_schema', u'Directory_class', 'Any'])
Traceback (most recent call last):
  File "/Users/eduardo/.config/virtualenvs/cwl/lib/python2.7/site-packages/cwltool/main.py", line 913, in main
    **vars(args))
  File "/Users/eduardo/.config/virtualenvs/cwl/lib/python2.7/site-packages/cwltool/main.py", line 294, in single_job_executor
    raise WorkflowException(Text(e))
WorkflowException: Items schema (ordereddict([('type', 'enum'), ('symbols', [u'a', u'b']), ('name', u'applicationsba75a91b-31b9-41a1-8a12-42de373b7dec')])) not a valid Avro schema: The name "applicationsba75a91b-31b9-41a1-8a12-42de373b7dec" is already in use. (known names: ['outputs_record_schema', u'File_class', u'applicationsba75a91b-31b9-41a1-8a12-42de373b7dec', 'File', 'Directory', 'input_record_schema', u'Directory_class', 'Any'])

esanzgar avatar Nov 30 '17 11:11 esanzgar

This issue has been mentioned on Common Workflow Language Discourse. There might be relevant details there:

https://cwl.discourse.group/t/set-tool-output-format-string-from-workflow-inputs/524/4

cwl-bot avatar Jan 17 '22 16:01 cwl-bot