Skip to content

Commit 650f4c4

Browse files
Iacopo ColonnelliIacopo Colonnelli
authored andcommitted
Updated outputMethod values
1 parent 4bb5329 commit 650f4c4

25 files changed

+41
-32
lines changed

cwltool/checker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,10 +517,10 @@ def is_conditional_step(param_to_step: Dict[str, CWLObjectType], parm_id: str) -
517517

518518

519519
def is_all_output_method_loop_step(param_to_step: Dict[str, CWLObjectType], parm_id: str) -> bool:
520-
"""Check if a step contains a `loop` directive with `all` outputMethod."""
520+
"""Check if a step contains a `loop` directive with `all_iterations` outputMethod."""
521521
source_step: Optional[MutableMapping[str, Any]] = param_to_step.get(parm_id)
522522
if source_step is not None:
523-
if source_step.get("loop") is not None and source_step.get("outputMethod") == "all":
523+
if source_step.get("loop") is not None and source_step.get("outputMethod") == "all_iterations":
524524
return True
525525
return False
526526

cwltool/update.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,16 @@ def rewrite_loop_requirements(t: CWLObjectType) -> None:
5151
el["outputSource"] = source
5252
s["loop"] = r["loop"]
5353
if "outputMethod" in r:
54-
s["outputMethod"] = r["outputMethod"]
54+
if r["outputMethod"] == "all":
55+
s["outputMethod"] = "all_iterations"
56+
elif r["outputMethod"] == "last":
57+
s["outputMethod"] = "last_iterations"
58+
else:
59+
raise SourceLine(
60+
r, raise_type=ValidationException
61+
).makeError( # pragma: no cover
62+
f"Invalid value {r["outputMethod"]} for `outputMethod`."
63+
)
5564
cast(
5665
MutableSequence[CWLObjectType],
5766
s["requirements"],

cwltool/workflow_job.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ def valueFromFunc(k: str, v: Optional[CWLOutputType]) -> Optional[CWLOutputType]
744744
_logger.info("[%s] will be skipped", step.name)
745745
if (
746746
step.tool.get("loop") is not None
747-
and step.tool.get("outputMethod", "last") == "all"
747+
and step.tool.get("outputMethod", "last_iteration") == "all_iterations"
748748
):
749749
callback({k["id"]: [] for k in outputparms}, "skipped")
750750
else:
@@ -874,7 +874,7 @@ def _set_empty_output(self, outputMethod: str) -> None:
874874
for i in self.step.tool["outputs"]:
875875
if "id" in i:
876876
iid = cast(str, i["id"])
877-
if outputMethod == "all":
877+
if outputMethod == "all_iterations":
878878
self.output_buffer[iid] = cast(MutableSequence[Optional[CWLOutputType]], [])
879879
else:
880880
self.output_buffer[iid] = None
@@ -887,7 +887,7 @@ def job(
887887
) -> JobsGeneratorType:
888888
"""Generate a WorkflowJobStep job until the `when` condition evaluates to False."""
889889
self.joborder = joborder
890-
outputMethod = self.step.tool.get("outputMethod", "last")
890+
outputMethod = self.step.tool.get("outputMethod", "last_iteration")
891891

892892
callback = functools.partial(
893893
self.loop_callback,
@@ -953,14 +953,14 @@ def loop_callback(
953953
self.iteration += 1
954954
try:
955955
loop = cast(MutableSequence[CWLObjectType], self.step.tool.get("loop", []))
956-
outputMethod = self.step.tool.get("outputMethod", "last")
956+
outputMethod = self.step.tool.get("outputMethod", "last_iteration")
957957
state: Dict[str, Optional[WorkflowStateItem]] = {}
958958
for i in self.step.tool["outputs"]:
959959
if "id" in i:
960960
iid = cast(str, i["id"])
961961
if iid in jobout:
962962
state[iid] = WorkflowStateItem(i, jobout[iid], processStatus)
963-
if outputMethod == "all":
963+
if outputMethod == "all_iterations":
964964
if iid not in self.output_buffer:
965965
self.output_buffer[iid] = cast(
966966
MutableSequence[Optional[CWLOutputType]], []

tests/loop/all-output-loop-no-iteration.cwl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ steps:
2525
when: $(inputs.i1 < 1)
2626
loop:
2727
i1: o1
28-
outputMethod: all
28+
outputMethod: all_iterations

tests/loop/all-output-loop.cwl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ steps:
2525
when: $(inputs.i1 < 10)
2626
loop:
2727
i1: o1
28-
outputMethod: all
28+
outputMethod: all_iterations

tests/loop/default-value-loop.cwl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ steps:
4444
i1:
4545
outputSource: o1
4646
default: 5
47-
outputMethod: all
47+
outputMethod: all_iterations

tests/loop/invalid-loop-scatter.cwl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ steps:
2626
when: $(inputs.i1 < 10)
2727
loop:
2828
i1: o1
29-
outputMethod: last
29+
outputMethod: last_iteration
3030
in:
3131
i1: i1
3232
i2: i2

tests/loop/invalid-loop-when-exception.cwl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ steps:
2929
}
3030
loop:
3131
i1: o1
32-
outputMethod: last
32+
outputMethod: last_iteration
3333
in:
3434
i1: i1
3535
i2: i2

tests/loop/invalid-loop-when-exception2.cwl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ steps:
3333
}
3434
loop:
3535
i1: o1
36-
outputMethod: last
36+
outputMethod: last_iteration
3737
in:
3838
i1: i1
3939
i2: i2

tests/loop/invalid-multi-source-loop-no-requirement.cwl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ steps:
6161
i1:
6262
loopSource: [osmall, obig]
6363
pickValue: the_only_non_null
64-
outputMethod: all
64+
outputMethod: all_iterations

0 commit comments

Comments
 (0)