Skip to content

Commit f404c3c

Browse files
author
Peter Amstutz
committed
More tests for overrides. Fix bugs.
1 parent 920f322 commit f404c3c

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

cwltool/process.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,10 @@ def avroize_type(field_type, name_prefix=""):
424424

425425
def get_overrides(metadata, toolid): # type: (Dict[Text, Any], Text) -> List[Dict[Text, Any]]
426426
req = [] # type: List[Dict[Text, Any]]
427-
for ov in metadata.get("cwl:overrides", []):
427+
overrides = metadata.get("cwl:overrides", [])
428+
if not isinstance(overrides, list):
429+
raise validate.ValidationException("Expected overrides to be a list, but was %s" % type(overrides))
430+
for ov in overrides:
428431
if ov["overrideTarget"] == toolid:
429432
req.extend(ov["override"])
430433
return req

cwltool/workflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ def __init__(self, toolpath_object, pos, **kwargs):
681681
strict=kwargs.get("strict"),
682682
fetcher_constructor=kwargs.get("fetcher_constructor"),
683683
resolver=kwargs.get("resolver"),
684-
overrides=kwargs.get("overrides"))
684+
overrides=kwargs.get("metadata", {}).get("overrides"))
685685
except validate.ValidationException as v:
686686
raise WorkflowException(
687687
u"Tool definition %s failed validation:\n%s" %

tests/override/echo.cwl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ cwlVersion: v1.0
22
class: CommandLineTool
33
requirements:
44
ShellCommandRequirement: {}
5+
hints:
56
EnvVarRequirement:
67
envDef:
78
MESSAGE: hello1

tests/test_override.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,10 @@ def test_overrides(self):
4242
self.assertEquals(main([get_data('tests/override/echo-job-ov2.yml')],
4343
stdout=sio), 0)
4444
self.assertEquals({"out": "zing hello4"}, json.loads(sio.getvalue()))
45+
46+
sio = StringIO()
47+
self.assertEquals(main(["--overrides", get_data('tests/override/ov2.yml'),
48+
get_data('tests/override/echo-wf.cwl'),
49+
get_data('tests/override/echo-job.yml')],
50+
stdout=sio), 0)
51+
self.assertEquals({"out": "zing hello5"}, json.loads(sio.getvalue()))

0 commit comments

Comments
 (0)