Skip to content

Commit b7a6610

Browse files
committed
soften schema; expand arbitrary cycle example
1 parent 1c77bda commit b7a6610

File tree

3 files changed

+106
-32
lines changed

3 files changed

+106
-32
lines changed

cwltool/extensions-v1.2.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,11 @@ $graph:
127127
type: string?
128128
jsonldPredicate: "@id"
129129
doc: "It must reference the `id` of one of the elements in the `in` field of the step."
130-
source:
130+
loop_source:
131131
doc: |
132132
Specifies one or more of the step output parameters that will
133133
provide input to the loop iterations after the first one (inputs
134134
of the first iteration are the step input parameters).
135-
jsonldPredicate:
136-
"_id": "cwl:source"
137-
"_type": "@id"
138-
refScope: 2
139135
type:
140136
- string?
141137
- string[]?
@@ -231,7 +227,7 @@ $graph:
231227
jsonldPredicate:
232228
_id: "cwltool:loop"
233229
mapSubject: id
234-
mapPredicate: source
230+
mapPredicate: loop_source
235231
doc: |
236232
Defines the input parameters of the loop iterations after the first one
237233
(inputs of the first iteration are the step input parameters). If no

cwltool/process.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ def filter(self, record: logging.LogRecord) -> bool:
121121
"http://commonwl.org/cwltool#LoadListingRequirement",
122122
"http://commonwl.org/cwltool#InplaceUpdateRequirement",
123123
"http://commonwl.org/cwltool#CUDARequirement",
124+
"http://commonwl.org/cwltool#Loop",
124125
]
125126

126127
cwl_files = (

tests/loop.cwl

Lines changed: 103 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,148 @@
11
cwlVersion: v1.2
22
class: Workflow
33

4+
doc: |
5+
Implementation of http://www.workflowpatterns.com/patterns/control/structural/wcp10.php#fig13
6+
the example for the "Arbitrary Cycles" pattern from the Workflow Patterns Initiative
7+
48
$namespaces:
59
cwltool: "http://commonwl.org/cwltool#"
610

11+
requirements:
12+
SubworkflowFeatureRequirement: {}
13+
714
inputs:
8-
i1: Any
15+
i1: boolean
916
outputs:
1017
o1:
1118
type: Any
1219
outputSource: subworkflow/o1
1320
steps:
1421
A:
15-
run: A.cwl
1622
in:
17-
in1: in1
23+
i1: i1
24+
run:
25+
class: ExpressionTool
26+
requirements:
27+
InlineJavascriptRequirement: {}
28+
inputs:
29+
i1: boolean
30+
expression: |
31+
${
32+
if (inputs.in1) {
33+
return {"p1": 42, "p2": null};
34+
}
35+
return {"p1": null, "p2": 23};
36+
}
37+
outputs:
38+
p1: int?
39+
p2: int?
1840
out: [p1, p2]
1941
B:
20-
run: B.cwl
2142
in:
2243
p1: A/p1
44+
when: $(inputs.p1 !== null)
45+
run:
46+
class: ExpressionTool
47+
requirements:
48+
InlineJavascriptRequirement: {}
49+
inputs:
50+
p1: int
51+
expression: |
52+
${ return {"p3": inputs.p1 * 2}; }
53+
outputs:
54+
p3: int
2355
out: [p3]
2456
C:
25-
run: C.cwl
2657
in:
2758
p2: A/p2
59+
when: $(inputs.p2 !== null)
60+
run:
61+
class: ExpressionTool
62+
requirements:
63+
InlineJavascriptRequirement: {}
64+
inputs:
65+
p2: int
66+
expression: |
67+
${ return {"p4": inputs.p2 * 3 }; }
68+
outputs:
69+
p4: int
2870
out: [p4]
2971
subworkflow:
72+
in:
73+
loop_p3: B/p3
74+
p4: C/p4
75+
requirements:
76+
cwltool:Loop:
77+
loop_when: $(outputs.o1 !== null)
78+
loop:
79+
p3: new_p3
80+
outputMethod: last
3081
run:
3182
class: Workflow
3283
inputs:
33-
p3: Any
34-
p4: Any
84+
loop_p3: int?
85+
p4: int?
3586
outputs:
3687
o1:
37-
type: Any
88+
type: int
3889
outputSource: E/o1
39-
p3:
40-
type: Any
41-
outputSource: F/p3
90+
new_p3:
91+
type: int?
92+
outputSource: F/end_p3
4293
steps:
4394
D:
44-
run: D.cwl
4595
in:
46-
p3: p3
96+
start_p3: loop_p3
97+
when: $(inputs.p3 !== null)
98+
run:
99+
class: ExpressionTool
100+
requirements:
101+
InlineJavascriptRequirement: {}
102+
inputs:
103+
start_p3: int
104+
expression: |
105+
${ return {"p4": inputs.start_p3 * 10 }; }
106+
outputs:
107+
p4: int
47108
out: [p4]
48109
E:
49-
run: E.cwl
50110
in:
51111
p4:
52112
source:
53113
- p4
54114
- D/p4
55115
pickValue: the_only_non_null
116+
run:
117+
class: ExpressionTool
118+
requirements:
119+
InlineJavascriptRequirement: {}
120+
inputs:
121+
p4: int
122+
expression: |
123+
${ if (inputs.p4 < 100) {
124+
return {"o1": null, "p5": inputs.p4 };
125+
}
126+
return {"o1": inputs.p4, "p5": null };
127+
}
128+
outputs:
129+
o1: int?
130+
p5: int?
56131
out: [o1, p5]
57132
F:
58-
run: F.cwl
59133
in:
60134
p5: E/p5
61-
out: [p3]
62-
in:
63-
p3: B/p3
64-
p4: C/p4
65-
out: [o1, p3]
66-
requirements:
67-
cwltool:Loop:
68-
loop_when: $(outputs.o1 !== null)
69-
loop:
70-
p3: p3
71-
outputMethod: last
135+
o1: E/o1
136+
when: $(inputs.o1 === null)
137+
run:
138+
class: ExpressionTool
139+
requirements:
140+
InlineJavascriptRequirement: {}
141+
inputs:
142+
p5: int
143+
expression: |
144+
${ return {"end_p3": inputs.p5 + 1}; }
145+
outputs:
146+
end_p3: int
147+
out: [end_p3]
148+
out: [o1, new_p3]

0 commit comments

Comments
 (0)