common-workflow-language / common-workflow-language/cwltool
Having an array of enums as input causes a crash
- Dominant language
- Python
- Stars
- 376
- Forks
- 255
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 12
Description
## Expected Behavior
Input of an array of enums should behave the same way as an array of strings (as long as the input is valid anyway).
## Actual Behavior
cwltool crashes when an input is an array of enums.
## Workflow Code
`tool.cwl`:
```yaml
cwlVersion: v1.0
class: CommandLineTool
baseCommand: echo
inputs:
args:
type:
- type: array
items:
type: enum
symbols:
- foo
- bar
inputBinding:
position: 1
outputs: []
```
`job.yml`:
```yaml
args: [foo]
```
## Full Traceback
```pytb
/Users/jh36/venv/bin/cwltool 1.0.20180711112827
Resolved 'tool.cwl' to 'file:///Users/jh36/tool.cwl'
Got workflow error
Traceback (most recent call last):
File "/Users/jh36/venv/lib/python3.6/site-packages/avro/schema.py", line 493, in __init__
raise SchemaParseException(fail_msg)
File "/Users/jh36/venv/lib/python3.6/site-packages/avro/schema.py", line 740, in make_avsc_object
doc = json_data.get('doc')
File "/Users/jh36/venv/lib/python3.6/site-packages/avro/schema.py", line 457, in __init__
self.set_prop('symbols', symbols)
File "/Users/jh36/venv/lib/python3.6/site-packages/avro/schema.py", line 298, in __init__
self.set_prop('name', name)
File "/Users/jh36/venv/lib/python3.6/site-packages/avro/schema.py", line 275, in add_name
return to_add
avro.schema.SchemaParseException: The name "args3ca4056c-da70-4e57-8a98-3007fe28d209" is already in use.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/jh36/venv/lib/python3.6/site-packages/cwltool/executors.py", line 141, in run_jobs
for job in jobiter:
File "/Users/jh36/venv/lib/python3.6/site-packages/cwltool/command_line_tool.py", line 373, in job
builder = self._init_job(job_order, runtimeContext)
File "/Users/jh36/venv/lib/python3.6/site-packages/cwltool/process.py", line 654, in _init_job
discover_secondaryFiles=getdefault(runtimeContext.toplevel, False)))
File "/Users/jh36/venv/lib/python3.6/site-packages/cwltool/builder.py", line 260, in bind_input
bindings.extend(self.bind_input(f, datum[f["name"]], lead_pos=lead_pos, tail_pos=f["name"], discover_secondaryFiles=discover_secondaryFiles))
File "/Users/jh36/venv/lib/python3.6/site-packages/cwltool/builder.py", line 231, in bind_input
avsc = AvroSchemaFromJSONData(t, self.names)
File "/Users/jh36/venv/lib/python3.6/site-packages/avro/schema.py", line 750, in make_avsc_object
return MapSchema(values, names, other_props)
File "/Users/jh36/venv/lib/python3.6/site-packages/avro/schema.py", line 496, in __init__
avro.schema.SchemaParseException: Items schema (CommentedMap([('type', 'enum'), ('symbols', ['foo', 'bar']), ('name', 'args3ca4056c-da70-4e57-8a98-3007fe28d209')])) not a valid Avro schema: The name "args3ca4056c-da70-4e57-8a98-3007fe28d209" is already in use. (known names: ['File', 'File_class', 'Directory', 'Directory_class', 'Any', 'input_record_schema', 'args3ca4056c-da70-4e57-8a98-3007fe28d209', 'outputs_record_schema'])
Workflow error:
Items schema (CommentedMap([('type', 'enum'), ('symbols', ['foo', 'bar']), ('name', 'args3ca4056c-da70-4e57-8a98-3007fe28d209')])) not a valid Avro schema: The name "args3ca4056c-da70-4e57-8a98-3007fe28d209" is already in use. (known names: ['File', 'File_class', 'Directory', 'Directory_class', 'Any', 'input_record_schema', 'args3ca4056c-da70-4e57-8a98-3007fe28d209', 'outputs_record_schema'])
Traceback (most recent call last):
File "/Users/jh36/venv/lib/python3.6/site-packages/avro/schema.py", line 493, in __init__
raise SchemaParseException(fail_msg)
File "/Users/jh36/venv/lib/python3.6/site-packages/avro/schema.py", line 740, in make_avsc_object
doc = json_data.get('doc')
File "/Users/jh36/venv/lib/python3.6/site-packages/avro/schema.py", line 457, in __init__
self.set_prop('symbols', symbols)
File "/Users/jh36/venv/lib/python3.6/site-packages/avro/schema.py", line 298, in __init__
self.set_prop('name', name)
File "/Users/jh36/venv/lib/python3.6/site-packages/avro/schema.py", line 275, in add_name
return to_add
avro.schema.SchemaParseException: The name "args3ca4056c-da70-4e57-8a98-3007fe28d209" is already in use.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/jh36/venv/lib/python3.6/site-packages/cwltool/executors.py", line 141, in run_jobs
for job in jobiter:
File "/Users/jh36/venv/lib/python3.6/site-packages/cwltool/command_line_tool.py", line 373, in job
builder = self._init_job(job_order, runtimeContext)
File "/Users/jh36/venv/lib/python3.6/site-packages/cwltool/process.py", line 654, in _init_job
discover_secondaryFiles=getdefault(runtimeContext.toplevel, False)))
File "/Users/jh36/venv/lib/python3.6/site-packages/cwltool/builder.py", line 260, in bind_input
bindings.extend(self.bind_input(f, datum[f["name"]], lead_pos=lead_pos, tail_pos=f["name"], discover_secondaryFiles=discover_secondaryFiles))
File "/Users/jh36/venv/lib/python3.6/site-packages/cwltool/builder.py", line 231, in bind_input
avsc = AvroSchemaFromJSONData(t, self.names)
File "/Users/jh36/venv/lib/python3.6/site-packages/avro/schema.py", line 750, in make_avsc_object
return MapSchema(values, names, other_props)
File "/Users/jh36/venv/lib/python3.6/site-packages/avro/schema.py", line 496, in __init__
avro.schema.SchemaParseException: Items schema (CommentedMap([('type', 'enum'), ('symbols', ['foo', 'bar']), ('name', 'args3ca4056c-da70-4e57-8a98-3007fe28d209')])) not a valid Avro schema: The name "args3ca4056c-da70-4e57-8a98-3007fe28d209" is already in use. (known names: ['File', 'File_class', 'Directory', 'Directory_class', 'Any', 'input_record_schema', 'args3ca4056c-da70-4e57-8a98-3007fe28d209', 'outputs_record_schema'])
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/jh36/venv/lib/python3.6/site-packages/cwltool/main.py", line 605, in main
logger=_logger)
File "/Users/jh36/venv/lib/python3.6/site-packages/cwltool/executors.py", line 39, in __call__
return self.execute(*args, **kwargs)
File "/Users/jh36/venv/lib/python3.6/site-packages/cwltool/executors.py", line 89, in execute
self.run_jobs(process, job_order_object, logger, runtime_context)
File "/Users/jh36/venv/lib/python3.6/site-packages/cwltool/executors.py", line 170, in run_jobs
raise WorkflowException(Text(e))
cwltool.errors.WorkflowException: Items schema (CommentedMap([('type', 'enum'), ('symbols', ['foo', 'bar']), ('name', 'args3ca4056c-da70-4e57-8a98-3007fe28d209')])) not a valid Avro schema: The name "args3ca4056c-da70-4e57-8a98-3007fe28d209" is already in use. (known names: ['File', 'File_class', 'Directory', 'Directory_class', 'Any', 'input_record_schema', 'args3ca4056c-da70-4e57-8a98-3007fe28d209', 'outputs_record_schema'])
```
## Your Environment
* cwltool version: 1.0.20180711112827
Contributor guide
Assessment
This issue has not been assessed yet.