Skip to content

Commit e6843b9

Browse files
authored
Add check that workflow step 'out' parameter must match one of the outputs of (#143)
the underlying process.
1 parent 488ad6f commit e6843b9

File tree

3 files changed

+47
-3
lines changed

3 files changed

+47
-3
lines changed

cwltool/workflow.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,15 +352,15 @@ def job(self, joborder, output_callback, **kwargs):
352352
made_progress = False
353353

354354
for step in self.steps:
355-
if kwargs["on_error"] == "stop" and self.processStatus != "success":
355+
if kwargs.get("on_error", "stop") == "stop" and self.processStatus != "success":
356356
break
357357

358358
if not step.submitted:
359359
step.iterable = self.try_make_job(step, **kwargs)
360360

361361
if step.iterable:
362362
for newjob in step.iterable:
363-
if kwargs["on_error"] == "stop" and self.processStatus != "success":
363+
if kwargs.get("on_error", "stop") == "stop" and self.processStatus != "success":
364364
break
365365
if newjob:
366366
made_progress = True
@@ -455,7 +455,11 @@ def __init__(self, toolpath_object, pos, **kwargs):
455455
found = True
456456
break
457457
if not found:
458-
param["type"] = "Any"
458+
if stepfield == "in":
459+
param["type"] = "Any"
460+
else:
461+
raise WorkflowException("[%s] Workflow step output '%s' not found in the outputs of the tool (expected one of '%s')" % (
462+
self.id, shortname(step_entry), "', '".join([shortname(tool_entry["id"]) for tool_entry in self.embedded_tool.tool[toolfield]])))
459463
param["id"] = inputid
460464
toolpath_object[toolfield].append(param)
461465

tests/test_bad_outputs_wf.cwl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
cwlVersion: v1.0
2+
class: Workflow
3+
inputs: []
4+
outputs:
5+
b:
6+
type: string
7+
outputSource: step2/c
8+
steps:
9+
step1:
10+
in: []
11+
out: [c]
12+
run:
13+
class: CommandLineTool
14+
inputs: []
15+
outputs:
16+
b:
17+
type: string
18+
outputBinding:
19+
outputEval: "qq"
20+
baseCommand: echo
21+
step2:
22+
in:
23+
a: step1/c
24+
out: [c]
25+
run:
26+
class: CommandLineTool
27+
inputs:
28+
a: string
29+
outputs:
30+
b: string
31+
baseCommand: echo

tests/test_examples.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,5 +196,14 @@ def test_recordcompare(self):
196196
self.assertTrue(cwltool.workflow.can_assign_src_to_sink(src, sink))
197197

198198

199+
def test_lifting(self):
200+
# check that lifting the types of the process outputs to the workflow step
201+
# fails if the step 'out' doesn't match.
202+
with self.assertRaises(cwltool.workflow.WorkflowException):
203+
f = cwltool.factory.Factory()
204+
echo = f.make("tests/test_bad_outputs_wf.cwl")
205+
self.assertEqual(echo(inp="foo"), {"out": "foo\n"})
206+
207+
199208
if __name__ == '__main__':
200209
unittest.main()

0 commit comments

Comments
 (0)