Skip to content

Commit 498c78d

Browse files
authored
Merge pull request #47 from common-workflow-language/map_syntax
first draft of a map<> explainer
2 parents 9afc62b + 2ef32fa commit 498c78d

File tree

3 files changed

+186
-5
lines changed

3 files changed

+186
-5
lines changed

CommandLineTool.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ $graph:
105105
now be calculated from a CWL Expression.
106106
* The exit code of a CommandLineTool invocation is now
107107
available to expressions in `outputEval` as `runtime.exitCode`
108+
* [Better explain](#map) the `map<…>` notation that has existed since v1.0.
109+
* Fixed schema error where the `type` field inside the `inputs` and
110+
`outputs` field was incorrectly listed as optional.
108111
109112
See also the [CWL Workflow Description, v1.1.0-dev1 changelog](Workflow.html#Changelog).
110113
@@ -449,7 +452,6 @@ $graph:
449452
fields:
450453
- name: type
451454
type:
452-
- "null"
453455
- CWLType
454456
- stdin
455457
- CommandInputRecordSchema
@@ -484,7 +486,6 @@ $graph:
484486
fields:
485487
- name: type
486488
type:
487-
- "null"
488489
- CWLType
489490
- stdout
490491
- stderr

Workflow.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ $graph:
8888
* [Added](#LoadListingRequirement) `LoadListingRequirement`
8989
and [loadListing](#LoadContents) to control whether and how
9090
`Directory` listings should be loaded for use in expressions.
91+
* [Better explain](#map) the `map<…>` notation that has existed since v1.0.
92+
* Fixed schema error where the `type` field inside the `inputs` and
93+
`outputs` fields for both `Workflow` and `ExpressionTool` was
94+
incorrectly listed as optional.
9195
9296
See also the [CWL Command Line Tool Description, v1.1.0-dev1 changelog](CommandLineTool.html#Changelog).
9397
@@ -110,7 +114,6 @@ $graph:
110114
fields:
111115
- name: type
112116
type:
113-
- "null"
114117
- CWLType
115118
- OutputRecordSchema
116119
- OutputEnumSchema
@@ -139,7 +142,6 @@ $graph:
139142
fields:
140143
- name: type
141144
type:
142-
- "null"
143145
- CWLType
144146
- InputRecordSchema
145147
- InputEnumSchema
@@ -235,7 +237,6 @@ $graph:
235237
If not specified, the default method is "merge_nested".
236238
- name: type
237239
type:
238-
- "null"
239240
- CWLType
240241
- OutputRecordSchema
241242
- OutputEnumSchema

concepts.md

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,185 @@ An implementation may formally validate the structure of a CWL document using
9191
SALAD schemas located at
9292
https://github.com/common-workflow-language/common-workflow-language/tree/master/v1.1.0-dev1
9393

94+
### map
95+
96+
Note: This section is non-normative.
97+
> type: array&lt;ComplexType&gt; |
98+
> map&lt;`key_field`, ComplexType&gt;
99+
100+
The above syntax in the CWL specifications means there are two or more ways to write the given value.
101+
102+
Option one is a array and is the most verbose option.
103+
104+
Option one generic example:
105+
```
106+
some_cwl_field:
107+
- key_field: a_complex_type1
108+
field2: foo
109+
field3: bar
110+
- key_field: a_complex_type2
111+
field2: foo2
112+
field3: bar2
113+
- key_field: a_complex_type3
114+
```
115+
116+
Option one specific example using [Workflow](Workflow.html#Workflow).[inputs](Workflow.html#WorkflowInputParameter):
117+
> array&lt;InputParameter&gt; |
118+
> map&lt;`id`, `type` | InputParameter&gt;
119+
120+
121+
```
122+
inputs:
123+
- id: workflow_input01
124+
type: string
125+
- id: workflow_input02
126+
type: File
127+
format: http://edamontology.org/format_2572
128+
```
129+
130+
Option two is enabled by the `map<…>` syntax. Instead of an array of entries we
131+
use a mapping, where one field of the `ComplexType` (here named `key_field`)
132+
becomes the key in the map, and its value is the rest of the `ComplexType`
133+
without the key field. If all of the other fields of the `ComplexType` are
134+
optional and unneeded, then we can indicate this with an empty mapping as the
135+
value: `a_complex_type3: {}`
136+
137+
Option two generic example:
138+
```
139+
some_cwl_field:
140+
a_complex_type1: # this was the "key_field" from above
141+
field2: foo
142+
field3: bar
143+
a_complex_type2:
144+
field2: foo2
145+
field3: bar2
146+
a_complex_type3: {} # we accept the defualt values for "field2" and "field3"
147+
```
148+
149+
Option two specific example using [Workflow](Workflow.html#Workflow).[inputs](Workflow.html#WorkflowInputParameter):
150+
> array&lt;InputParameter&gt; |
151+
> map&lt;`id`, `type` | InputParameter&gt;
152+
153+
154+
```
155+
inputs:
156+
workflow_input01:
157+
type: string
158+
workflow_input02:
159+
type: File
160+
format: http://edamontology.org/format_2572
161+
```
162+
163+
Option two specific example using [SoftwareRequirement](#SoftwareRequirement).[packages](#SoftwarePackage):
164+
> array&lt;SoftwarePackage&gt; |
165+
> map&lt;`package`, `specs` | SoftwarePackage&gt;
166+
167+
168+
```
169+
hints:
170+
SoftwareRequirement:
171+
packages:
172+
sourmash:
173+
specs: [ https://doi.org/10.21105/joss.00027 ]
174+
screed:
175+
version: [ "1.0" ]
176+
python: {}
177+
```
178+
`
179+
Sometimes we have a third and even more compact option denoted like this:
180+
> type: array&lt;ComplexType&gt; |
181+
> map&lt;`key_field`, `field2` | ComplexType&gt;
182+
183+
For this example, if we only need the `key_field` and `field2` when specifying
184+
our `ComplexType`s (because the other fields are optional and we are fine with
185+
their default values) then we can abbreviate.
186+
187+
Option three generic example:
188+
```
189+
some_cwl_field:
190+
a_complex_type1: foo # we accept the default value for field3
191+
a_complex_type2: foo2 # we accept the default value for field3
192+
a_complex_type3: {} # we accept the default values for "field2" and "field3"
193+
```
194+
195+
Option three specific example using [Workflow](Workflow.html#Workflow).[inputs](Workflow.html#WorkflowInputParameter):
196+
> array&lt;InputParameter&gt; |
197+
> map&lt;`id`, `type` | InputParameter&gt;
198+
199+
200+
```
201+
inputs:
202+
workflow_input01: string
203+
workflow_input02: File # we accept the default of no File format
204+
```
205+
206+
Option three specific example using [SoftwareRequirement](#SoftwareRequirement).[packages](#SoftwarePackage):
207+
> array&lt;SoftwarePackage&gt; |
208+
> map&lt;`package`, `specs` | SoftwarePackage&gt;
209+
210+
211+
```
212+
hints:
213+
SoftwareRequirement:
214+
packages:
215+
sourmash: [ https://doi.org/10.21105/joss.00027 ]
216+
python: {}
217+
```
218+
219+
220+
What if some entries we want to mix the option 2 and 3? You can!
221+
222+
Mixed option 2 and 3 generic example:
223+
```
224+
some_cwl_field:
225+
my_complex_type1: foo # we accept the default value for field3
226+
my_complex_type2:
227+
field2: foo2
228+
field3: bar2 # we did not accept the default value for field3
229+
# so we had to use the slightly expanded syntax
230+
my_complex_type3: {} # as before, we accept the default values for both
231+
# "field2" and "field3"
232+
```
233+
234+
Mixed option 2 and 3 specific example using [Workflow](Workflow.html#Workflow).[inputs](Workflow.html#WorkflowInputParameter):
235+
> array&lt;InputParameter&gt; |
236+
> map&lt;`id`, `type` | InputParameter&gt;
237+
238+
239+
```
240+
inputs:
241+
workflow_input01: string
242+
workflow_input02: # we use the longer way
243+
type: File # because we want to specify the "format" too
244+
format: http://edamontology.org/format_2572
245+
workflow_input03: {} # back to the short form as this entry
246+
# uses the default of no "type" just like the prior
247+
# examples
248+
```
249+
250+
Mixed option 2 and 3 specific example using [SoftwareRequirement](#SoftwareRequirement).[packages](#SoftwarePackage):
251+
> array&lt;SoftwarePackage&gt; |
252+
> map&lt;`package`, `specs` | SoftwarePackage&gt;
253+
254+
255+
```
256+
hints:
257+
SoftwareRequirement:
258+
packages:
259+
sourmash: [ https://doi.org/10.21105/joss.00027 ]
260+
screed:
261+
specs: [ https://github.com/dib-lab/screed ]
262+
version: [ "1.0" ]
263+
python: {}
264+
```
265+
266+
Note: The `map<…>` (compact) versions are optional, the verbose option #1 is
267+
always allowed, but for presentation reasons option 3 and 2 may be preferred
268+
by human readers.
269+
270+
The normative explanation for these variations, aimed at implementors, is in the
271+
[Schema Salad specification](SchemaSalad.html#Identifier_maps).
272+
94273
## Identifiers
95274

96275
If an object contains an `id` field, that is used to uniquely identify the

0 commit comments

Comments
 (0)