Skip to content

Commit 1bdb36d

Browse files
authored
When on_error=continue, do not execute downstream steps connected to an (#283)
* When on_error=continue, do not execute downstream steps connected to an upstream step that failed. * Log errors from fs_access while collecting output. * Pin typed-ast to 0.6.3
1 parent a774d7f commit 1bdb36d

File tree

6 files changed

+48
-13
lines changed

6 files changed

+48
-13
lines changed

cwltool/draft2tool.py

+3
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,9 @@ def collect_output(self, schema, builder, outdir, fs_access, compute_checksum=Tr
461461
for g in fs_access.glob(fs_access.join(outdir, gb))])
462462
except (OSError, IOError) as e:
463463
_logger.warn(Text(e))
464+
except:
465+
_logger.error("Unexpected error from fs_access", exc_info=True)
466+
raise
464467

465468
for files in r:
466469
if files["class"] == "Directory" and "listing" not in files:

cwltool/workflow.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
_logger = logging.getLogger("cwltool")
2121

22-
WorkflowStateItem = namedtuple('WorkflowStateItem', ['parameter', 'value'])
22+
WorkflowStateItem = namedtuple('WorkflowStateItem', ['parameter', 'value', 'success'])
2323

2424

2525
def defaultMakeTool(toolpath_object, # type: Dict[Text, Any]
@@ -161,7 +161,7 @@ def object_from_state(state, parms, frag_only, supportsMultipleInput, sourceFiel
161161
"declared.")
162162
connections = aslist(inp[sourceField])
163163
for src in connections:
164-
if src in state and state[src] is not None:
164+
if src in state and state[src] is not None and (state[src].success == "success" or incomplete):
165165
if not match_types(
166166
inp["type"], state[src], iid, inputobj,
167167
inp.get("linkMerge", ("merge_nested"
@@ -232,7 +232,7 @@ def receive_output(self, step, outputparms, jobout, processStatus):
232232
for i in outputparms:
233233
if "id" in i:
234234
if i["id"] in jobout:
235-
self.state[i["id"]] = WorkflowStateItem(i, jobout[i["id"]])
235+
self.state[i["id"]] = WorkflowStateItem(i, jobout[i["id"]], processStatus)
236236
else:
237237
_logger.error(u"[%s] Output is missing expected field %s", step.name, i["id"])
238238
processStatus = "permanentFail"
@@ -359,9 +359,9 @@ def job(self, joborder, output_callback, **kwargs):
359359
with SourceLine(self.tool["inputs"], e, WorkflowException):
360360
iid = shortname(i["id"])
361361
if iid in joborder:
362-
self.state[i["id"]] = WorkflowStateItem(i, copy.deepcopy(joborder[iid]))
362+
self.state[i["id"]] = WorkflowStateItem(i, copy.deepcopy(joborder[iid]), "success")
363363
elif "default" in i:
364-
self.state[i["id"]] = WorkflowStateItem(i, copy.deepcopy(i["default"]))
364+
self.state[i["id"]] = WorkflowStateItem(i, copy.deepcopy(i["default"]), "success")
365365
else:
366366
raise WorkflowException(
367367
u"Input '%s' not in input object and does not have a default value." % (i["id"]))

tests/wf/echo.cwl

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ inputs:
1212
else:
1313
f = open("foo"+sys.argv[1]+".txt", "w")
1414
f.write(sys.argv[1]+"\n")
15+
if sys.argv[1] == "5":
16+
exit(1)
1517
outputs:
1618
out:
1719
type: File

tests/wf/scatterfail.cwl

+20-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ class: Workflow
22
cwlVersion: v1.0
33
requirements:
44
ScatterFeatureRequirement: {}
5+
SubworkflowFeatureRequirement: {}
56
inputs:
67
range:
78
type: string[]
@@ -16,10 +17,22 @@ steps:
1617
r: range
1718
scatter: r
1819
out: [out]
19-
run: echo.cwl
20-
step2:
21-
in:
22-
r: step1/out
23-
scatter: r
24-
out: []
25-
run: cat.cwl
20+
run:
21+
class: Workflow
22+
inputs:
23+
r: string
24+
outputs:
25+
out:
26+
type: File
27+
outputSource: sstep1/out
28+
steps:
29+
sstep1:
30+
in:
31+
r: r
32+
out: [out]
33+
run: echo.cwl
34+
sstep2:
35+
in:
36+
r: sstep1/out
37+
out: []
38+
run: cat.cwl

tests/wf/wffail.cwl

+17
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
class: Workflow
22
cwlVersion: v1.0
33
inputs: []
4+
requirements:
5+
StepInputExpressionRequirement: {}
46
outputs:
57
out1:
68
type: File
79
outputSource: step1/out
810
out2:
911
type: File
1012
outputSource: step2/out
13+
out4:
14+
type: File
15+
outputSource: step4/out
1116
steps:
1217
step1:
1318
in:
@@ -19,3 +24,15 @@ steps:
1924
r: {default: "2"}
2025
out: [out]
2126
run: echo.cwl
27+
step3:
28+
in:
29+
r: {default: "5"}
30+
out: [out]
31+
run: echo.cwl
32+
step4:
33+
in:
34+
r:
35+
source: step3/out
36+
valueFrom: $(inputs.r.basename)
37+
out: [out]
38+
run: echo.cwl

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ commands = make mypy
1515
whitelist_externals = make
1616
deps =
1717
mypy>=0.470
18-
typed-ast
18+
typed-ast==0.6.3
1919
-rrequirements.txt
2020

2121
[testenv:py35-lint]

0 commit comments

Comments
 (0)