Skip to content

Commit

Permalink
Updated outputMethod values
Browse files Browse the repository at this point in the history
  • Loading branch information
Iacopo Colonnelli authored and Iacopo Colonnelli committed Sep 18, 2024
1 parent 4bb5329 commit 650f4c4
Show file tree
Hide file tree
Showing 25 changed files with 41 additions and 32 deletions.
4 changes: 2 additions & 2 deletions cwltool/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,10 +517,10 @@ def is_conditional_step(param_to_step: Dict[str, CWLObjectType], parm_id: str) -


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

Expand Down
11 changes: 10 additions & 1 deletion cwltool/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,16 @@ def rewrite_loop_requirements(t: CWLObjectType) -> None:
el["outputSource"] = source
s["loop"] = r["loop"]
if "outputMethod" in r:
s["outputMethod"] = r["outputMethod"]
if r["outputMethod"] == "all":
s["outputMethod"] = "all_iterations"
elif r["outputMethod"] == "last":
s["outputMethod"] = "last_iterations"
else:
raise SourceLine(
r, raise_type=ValidationException
).makeError( # pragma: no cover
f"Invalid value {r["outputMethod"]} for `outputMethod`."
)
cast(
MutableSequence[CWLObjectType],
s["requirements"],
Expand Down
10 changes: 5 additions & 5 deletions cwltool/workflow_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ def valueFromFunc(k: str, v: Optional[CWLOutputType]) -> Optional[CWLOutputType]
_logger.info("[%s] will be skipped", step.name)
if (
step.tool.get("loop") is not None
and step.tool.get("outputMethod", "last") == "all"
and step.tool.get("outputMethod", "last_iteration") == "all_iterations"
):
callback({k["id"]: [] for k in outputparms}, "skipped")
else:
Expand Down Expand Up @@ -874,7 +874,7 @@ def _set_empty_output(self, outputMethod: str) -> None:
for i in self.step.tool["outputs"]:
if "id" in i:
iid = cast(str, i["id"])
if outputMethod == "all":
if outputMethod == "all_iterations":
self.output_buffer[iid] = cast(MutableSequence[Optional[CWLOutputType]], [])
else:
self.output_buffer[iid] = None
Expand All @@ -887,7 +887,7 @@ def job(
) -> JobsGeneratorType:
"""Generate a WorkflowJobStep job until the `when` condition evaluates to False."""
self.joborder = joborder
outputMethod = self.step.tool.get("outputMethod", "last")
outputMethod = self.step.tool.get("outputMethod", "last_iteration")

callback = functools.partial(
self.loop_callback,
Expand Down Expand Up @@ -953,14 +953,14 @@ def loop_callback(
self.iteration += 1
try:
loop = cast(MutableSequence[CWLObjectType], self.step.tool.get("loop", []))
outputMethod = self.step.tool.get("outputMethod", "last")
outputMethod = self.step.tool.get("outputMethod", "last_iteration")
state: Dict[str, Optional[WorkflowStateItem]] = {}
for i in self.step.tool["outputs"]:
if "id" in i:
iid = cast(str, i["id"])
if iid in jobout:
state[iid] = WorkflowStateItem(i, jobout[iid], processStatus)
if outputMethod == "all":
if outputMethod == "all_iterations":
if iid not in self.output_buffer:
self.output_buffer[iid] = cast(
MutableSequence[Optional[CWLOutputType]], []
Expand Down
2 changes: 1 addition & 1 deletion tests/loop/all-output-loop-no-iteration.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ steps:
when: $(inputs.i1 < 1)
loop:
i1: o1
outputMethod: all
outputMethod: all_iterations
2 changes: 1 addition & 1 deletion tests/loop/all-output-loop.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ steps:
when: $(inputs.i1 < 10)
loop:
i1: o1
outputMethod: all
outputMethod: all_iterations
2 changes: 1 addition & 1 deletion tests/loop/default-value-loop.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ steps:
i1:
outputSource: o1
default: 5
outputMethod: all
outputMethod: all_iterations
2 changes: 1 addition & 1 deletion tests/loop/invalid-loop-scatter.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ steps:
when: $(inputs.i1 < 10)
loop:
i1: o1
outputMethod: last
outputMethod: last_iteration
in:
i1: i1
i2: i2
Expand Down
2 changes: 1 addition & 1 deletion tests/loop/invalid-loop-when-exception.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ steps:
}
loop:
i1: o1
outputMethod: last
outputMethod: last_iteration
in:
i1: i1
i2: i2
Expand Down
2 changes: 1 addition & 1 deletion tests/loop/invalid-loop-when-exception2.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ steps:
}
loop:
i1: o1
outputMethod: last
outputMethod: last_iteration
in:
i1: i1
i2: i2
Expand Down
2 changes: 1 addition & 1 deletion tests/loop/invalid-multi-source-loop-no-requirement.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ steps:
i1:
loopSource: [osmall, obig]
pickValue: the_only_non_null
outputMethod: all
outputMethod: all_iterations
2 changes: 1 addition & 1 deletion tests/loop/invalid-no-loopWhen.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ steps:
${return {'o1': inputs.i1 + inputs.i2};}
loop:
i1: o1
outputMethod: last
outputMethod: last_iteration
in:
i1: i1
i2: i2
Expand Down
2 changes: 1 addition & 1 deletion tests/loop/invalid-non-boolean-loopWhen.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ steps:
when: $(inputs.i1)
loop:
i1: o1
outputMethod: last
outputMethod: last_iteration
in:
i1: i1
i2: i2
Expand Down
2 changes: 1 addition & 1 deletion tests/loop/invalid-non-boolean-loopWhen2.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ steps:
when: '$(inputs.i1 == 1 ? true : "I am a string")'
loop:
i1: o1
outputMethod: last
outputMethod: last_iteration
in:
i1: i1
i2: i2
Expand Down
2 changes: 1 addition & 1 deletion tests/loop/invalid-value-from-loop-no-requirement.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ steps:
loop:
i1:
valueFrom: $(inputs.i1 + 1)
outputMethod: last
outputMethod: last_iteration
4 changes: 2 additions & 2 deletions tests/loop/loop-inside-loop-all.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ steps:
when: $(inputs.i1 <= inputs.i2)
loop:
i1: o1
outputMethod: all
outputMethod: all_iterations
in:
i1: i1
i2: i2
Expand All @@ -55,4 +55,4 @@ steps:
loop:
i2:
valueFrom: $(inputs.i2 + 1)
outputMethod: all
outputMethod: all_iterations
4 changes: 2 additions & 2 deletions tests/loop/loop-inside-loop.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ steps:
when: $(inputs.i1 <= inputs.i2)
loop:
i1: o1
outputMethod: last
outputMethod: last_iteration
in:
i1: i1
i2: i2
Expand All @@ -51,4 +51,4 @@ steps:
loop:
i2:
valueFrom: $(inputs.i2 + 1)
outputMethod: all
outputMethod: all_iterations
2 changes: 1 addition & 1 deletion tests/loop/loop-inside-scatter.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ steps:
when: $(inputs.i1 < 10)
loop:
i1: o1
outputMethod: last
outputMethod: last_iteration
in:
i1: i1
i2: i2
Expand Down
2 changes: 1 addition & 1 deletion tests/loop/multi-source-loop.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ steps:
i1:
outputSource: [osmall, obig]
pickValue: the_only_non_null
outputMethod: all
outputMethod: all_iterations
2 changes: 1 addition & 1 deletion tests/loop/opt-var-loop.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ steps:
when: $(inputs.i1 < 10)
loop:
i1: o1
outputMethod: last
outputMethod: last_iteration
2 changes: 1 addition & 1 deletion tests/loop/scatter-inside-loop.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ steps:
when: $(inputs.i1[0] < 10)
loop:
i1: o1
outputMethod: last
outputMethod: last_iteration
2 changes: 1 addition & 1 deletion tests/loop/single-var-loop-no-iteration.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ steps:
when: $(inputs.i1 < 1)
loop:
i1: o1
outputMethod: last
outputMethod: last_iteration
2 changes: 1 addition & 1 deletion tests/loop/single-var-loop.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ steps:
when: $(inputs.i1 < 10)
loop:
i1: o1
outputMethod: last
outputMethod: last_iteration
2 changes: 1 addition & 1 deletion tests/loop/two-vars-loop-2.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ steps:
when: $(inputs.i1 < 10)
loop:
i1: o1
outputMethod: last
outputMethod: last_iteration
2 changes: 1 addition & 1 deletion tests/loop/two-vars-loop.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ steps:
loop:
i1: o1
i2: o2
outputMethod: last
outputMethod: last_iteration
2 changes: 1 addition & 1 deletion tests/loop/value-from-loop.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ steps:
loop:
i1:
valueFrom: $(inputs.i1 + 1)
outputMethod: last
outputMethod: last_iteration

0 comments on commit 650f4c4

Please sign in to comment.