Skip to content

Commit 0aafd67

Browse files
Iacopo ColonnelliGlassOfWhiskey
authored andcommitted
Updated outputMethod values
1 parent 4bb5329 commit 0aafd67

29 files changed

+65
-55
lines changed

cwltool/checker.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,10 +517,13 @@ 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 (
524+
source_step.get("loop") is not None
525+
and source_step.get("outputMethod") == "all_iterations"
526+
):
524527
return True
525528
return False
526529

cwltool/errors.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88

99
# flake8: noqa: F401
1010

11-
from cwl_utils.errors import WorkflowException as WorkflowException
12-
13-
1411
from cwl_utils.errors import GraphTargetMissingException as GraphTargetMissingException
12+
from cwl_utils.errors import WorkflowException as WorkflowException
1513

1614

1715
class UnsupportedRequirement(WorkflowException):

cwltool/schemas/v1.3.0-dev1/Workflow.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,8 @@ $graph:
497497
docParent: "#LoopWorkflowStep"
498498
doc: The loop output method, as described in [workflow step loop](#LoopWorkflowStep).
499499
symbols:
500-
- last
501-
- all
500+
- last_iteration
501+
- all_iterations
502502

503503

504504
- name: AbstractWorkflowStep
@@ -705,14 +705,14 @@ $graph:
705705
The `outputMethod` field describes how to deal with loop outputs after
706706
termination:
707707
708-
* **last** specifies that only the last computed element for each output
709-
parameter should be propagated to the subsequent steps. This is the
710-
default value.
708+
* **last_iteration** specifies that only the last computed element for
709+
each output parameter should be propagated to the subsequent steps.
710+
This is the default value.
711711
712-
* **all** specifies that an array with all output values computed at the
713-
end of each loop iteration should be propagated to the subsequent steps.
714-
Elements in the array must be ordered according to the loop iterations
715-
that produced them.
712+
* **all_iterations** specifies that an array with all output values
713+
computed at the end of each loop iteration should be propagated to
714+
the subsequent steps. Elements in the array must be ordered according
715+
to the loop iterations that produced them.
716716
717717
Iterative execution in CWL is an optional feature and is not required
718718
to be implemented by all consumers of CWL documents. An implementation that
@@ -734,9 +734,9 @@ $graph:
734734
mapPredicate: outputSource
735735
- name: outputMethod
736736
doc: |
737-
If not specified, the default method is "last".
737+
If not specified, the default method is "last_iteration".
738738
type: LoopOutputMethod?
739-
default: last
739+
default: last_iteration
740740
jsonldPredicate:
741741
"_id": "cwl:outputMethod"
742742
"_type": "@vocab"
@@ -748,7 +748,8 @@ $graph:
748748
Only run the next iteration when the expression evaluates to `true`.
749749
If the first iteration evaluates to `false` the step is skipped.
750750
A skipped step produces a `null` on each output if the `outputMethod`
751-
is set to `last`, and an empty array if the `outputMethod` is set to `all`.
751+
is set to `last_iteration`, and an empty array if the `outputMethod`
752+
is set to `all_iterations`.
752753
753754
754755
- name: Workflow

cwltool/update.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111
cast,
1212
)
1313

14+
from ruamel.yaml.comments import CommentedMap, CommentedSeq
1415
from schema_salad.exceptions import ValidationException
1516
from schema_salad.ref_resolver import Loader
1617
from schema_salad.sourceline import SourceLine
1718

18-
from ruamel.yaml.comments import CommentedMap, CommentedSeq
19-
2019
from .loghandler import _logger
2120
from .utils import CWLObjectType, CWLOutputType, aslist, visit_class, visit_field
2221

@@ -51,7 +50,16 @@ def rewrite_loop_requirements(t: CWLObjectType) -> None:
5150
el["outputSource"] = source
5251
s["loop"] = r["loop"]
5352
if "outputMethod" in r:
54-
s["outputMethod"] = r["outputMethod"]
53+
if r["outputMethod"] == "all":
54+
s["outputMethod"] = "all_iterations"
55+
elif r["outputMethod"] == "last":
56+
s["outputMethod"] = "last_iterations"
57+
else:
58+
raise SourceLine(
59+
r, raise_type=ValidationException
60+
).makeError( # pragma: no cover
61+
f"Invalid value {r["outputMethod"]} for `outputMethod`."
62+
)
5563
cast(
5664
MutableSequence[CWLObjectType],
5765
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

0 commit comments

Comments
 (0)