Skip to content

Commit

Permalink
When on_error=continue, do not execute downstream steps connected to …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
tetron authored Feb 13, 2017
1 parent a774d7f commit 1bdb36d
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 13 deletions.
3 changes: 3 additions & 0 deletions cwltool/draft2tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,9 @@ def collect_output(self, schema, builder, outdir, fs_access, compute_checksum=Tr
for g in fs_access.glob(fs_access.join(outdir, gb))])
except (OSError, IOError) as e:
_logger.warn(Text(e))
except:
_logger.error("Unexpected error from fs_access", exc_info=True)
raise

for files in r:
if files["class"] == "Directory" and "listing" not in files:
Expand Down
10 changes: 5 additions & 5 deletions cwltool/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

_logger = logging.getLogger("cwltool")

WorkflowStateItem = namedtuple('WorkflowStateItem', ['parameter', 'value'])
WorkflowStateItem = namedtuple('WorkflowStateItem', ['parameter', 'value', 'success'])


def defaultMakeTool(toolpath_object, # type: Dict[Text, Any]
Expand Down Expand Up @@ -161,7 +161,7 @@ def object_from_state(state, parms, frag_only, supportsMultipleInput, sourceFiel
"declared.")
connections = aslist(inp[sourceField])
for src in connections:
if src in state and state[src] is not None:
if src in state and state[src] is not None and (state[src].success == "success" or incomplete):
if not match_types(
inp["type"], state[src], iid, inputobj,
inp.get("linkMerge", ("merge_nested"
Expand Down Expand Up @@ -232,7 +232,7 @@ def receive_output(self, step, outputparms, jobout, processStatus):
for i in outputparms:
if "id" in i:
if i["id"] in jobout:
self.state[i["id"]] = WorkflowStateItem(i, jobout[i["id"]])
self.state[i["id"]] = WorkflowStateItem(i, jobout[i["id"]], processStatus)
else:
_logger.error(u"[%s] Output is missing expected field %s", step.name, i["id"])
processStatus = "permanentFail"
Expand Down Expand Up @@ -359,9 +359,9 @@ def job(self, joborder, output_callback, **kwargs):
with SourceLine(self.tool["inputs"], e, WorkflowException):
iid = shortname(i["id"])
if iid in joborder:
self.state[i["id"]] = WorkflowStateItem(i, copy.deepcopy(joborder[iid]))
self.state[i["id"]] = WorkflowStateItem(i, copy.deepcopy(joborder[iid]), "success")
elif "default" in i:
self.state[i["id"]] = WorkflowStateItem(i, copy.deepcopy(i["default"]))
self.state[i["id"]] = WorkflowStateItem(i, copy.deepcopy(i["default"]), "success")
else:
raise WorkflowException(
u"Input '%s' not in input object and does not have a default value." % (i["id"]))
Expand Down
2 changes: 2 additions & 0 deletions tests/wf/echo.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ inputs:
else:
f = open("foo"+sys.argv[1]+".txt", "w")
f.write(sys.argv[1]+"\n")
if sys.argv[1] == "5":
exit(1)
outputs:
out:
type: File
Expand Down
27 changes: 20 additions & 7 deletions tests/wf/scatterfail.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class: Workflow
cwlVersion: v1.0
requirements:
ScatterFeatureRequirement: {}
SubworkflowFeatureRequirement: {}
inputs:
range:
type: string[]
Expand All @@ -16,10 +17,22 @@ steps:
r: range
scatter: r
out: [out]
run: echo.cwl
step2:
in:
r: step1/out
scatter: r
out: []
run: cat.cwl
run:
class: Workflow
inputs:
r: string
outputs:
out:
type: File
outputSource: sstep1/out
steps:
sstep1:
in:
r: r
out: [out]
run: echo.cwl
sstep2:
in:
r: sstep1/out
out: []
run: cat.cwl
17 changes: 17 additions & 0 deletions tests/wf/wffail.cwl
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
class: Workflow
cwlVersion: v1.0
inputs: []
requirements:
StepInputExpressionRequirement: {}
outputs:
out1:
type: File
outputSource: step1/out
out2:
type: File
outputSource: step2/out
out4:
type: File
outputSource: step4/out
steps:
step1:
in:
Expand All @@ -19,3 +24,15 @@ steps:
r: {default: "2"}
out: [out]
run: echo.cwl
step3:
in:
r: {default: "5"}
out: [out]
run: echo.cwl
step4:
in:
r:
source: step3/out
valueFrom: $(inputs.r.basename)
out: [out]
run: echo.cwl
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ commands = make mypy
whitelist_externals = make
deps =
mypy>=0.470
typed-ast
typed-ast==0.6.3
-rrequirements.txt

[testenv:py35-lint]
Expand Down

0 comments on commit 1bdb36d

Please sign in to comment.