Skip to content

Commit 650f4c4

Browse files
Iacopo ColonnelliIacopo Colonnelli
Iacopo Colonnelli
authored and
Iacopo Colonnelli
committed
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

tests/loop/invalid-no-loopWhen.cwl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ steps:
2525
${return {'o1': inputs.i1 + inputs.i2};}
2626
loop:
2727
i1: o1
28-
outputMethod: last
28+
outputMethod: last_iteration
2929
in:
3030
i1: i1
3131
i2: i2

tests/loop/invalid-non-boolean-loopWhen.cwl

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

tests/loop/invalid-non-boolean-loopWhen2.cwl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ steps:
2626
when: '$(inputs.i1 == 1 ? true : "I am a string")'
2727
loop:
2828
i1: o1
29-
outputMethod: last
29+
outputMethod: last_iteration
3030
in:
3131
i1: i1
3232
i2: i2

tests/loop/invalid-value-from-loop-no-requirement.cwl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ steps:
2929
loop:
3030
i1:
3131
valueFrom: $(inputs.i1 + 1)
32-
outputMethod: last
32+
outputMethod: last_iteration

tests/loop/loop-inside-loop-all.cwl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ steps:
4646
when: $(inputs.i1 <= inputs.i2)
4747
loop:
4848
i1: o1
49-
outputMethod: all
49+
outputMethod: all_iterations
5050
in:
5151
i1: i1
5252
i2: i2
@@ -55,4 +55,4 @@ steps:
5555
loop:
5656
i2:
5757
valueFrom: $(inputs.i2 + 1)
58-
outputMethod: all
58+
outputMethod: all_iterations

tests/loop/loop-inside-loop.cwl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ steps:
4242
when: $(inputs.i1 <= inputs.i2)
4343
loop:
4444
i1: o1
45-
outputMethod: last
45+
outputMethod: last_iteration
4646
in:
4747
i1: i1
4848
i2: i2
@@ -51,4 +51,4 @@ steps:
5151
loop:
5252
i2:
5353
valueFrom: $(inputs.i2 + 1)
54-
outputMethod: all
54+
outputMethod: all_iterations

tests/loop/loop-inside-scatter.cwl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ steps:
4141
when: $(inputs.i1 < 10)
4242
loop:
4343
i1: o1
44-
outputMethod: last
44+
outputMethod: last_iteration
4545
in:
4646
i1: i1
4747
i2: i2

tests/loop/multi-source-loop.cwl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ steps:
6262
i1:
6363
outputSource: [osmall, obig]
6464
pickValue: the_only_non_null
65-
outputMethod: all
65+
outputMethod: all_iterations

tests/loop/opt-var-loop.cwl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ steps:
2727
when: $(inputs.i1 < 10)
2828
loop:
2929
i1: o1
30-
outputMethod: last
30+
outputMethod: last_iteration

tests/loop/scatter-inside-loop.cwl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ steps:
4646
when: $(inputs.i1[0] < 10)
4747
loop:
4848
i1: o1
49-
outputMethod: last
49+
outputMethod: last_iteration

tests/loop/single-var-loop-no-iteration.cwl

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

tests/loop/single-var-loop.cwl

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

tests/loop/two-vars-loop-2.cwl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ steps:
2828
when: $(inputs.i1 < 10)
2929
loop:
3030
i1: o1
31-
outputMethod: last
31+
outputMethod: last_iteration

tests/loop/two-vars-loop.cwl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ steps:
3030
loop:
3131
i1: o1
3232
i2: o2
33-
outputMethod: last
33+
outputMethod: last_iteration

tests/loop/value-from-loop.cwl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ steps:
3030
loop:
3131
i1:
3232
valueFrom: $(inputs.i1 + 1)
33-
outputMethod: last
33+
outputMethod: last_iteration

0 commit comments

Comments
 (0)