@@ -35,21 +35,18 @@ in parallel across many nodes.
35
35
36
36
% TODO: add a link to the Core Concepts -> Requirements section below?
37
37
38
- ``` {note}
38
+ ## Requirements
39
+
39
40
The CWL specification allows for implementations to provide extra
40
41
functionality through Requirements. Some CWL runners may provide
41
42
Requirements that are not in the specification. For example, GPU
42
43
requirements are supported in ` cwltool ` , but it is not part of the
43
44
{{ cwl_version }} specification. Requirements are explained in
44
45
detail in another section.
45
- ```
46
46
47
- ## Processing units
47
+ % TODO: better explanation about requirements, with an example.
48
48
49
- The CWL document is a JSON or YAML file — or a combination of both
50
- JSON and YAML. One of the required attributes of the CWL document
51
- is the ` class ` . The ` class ` defines the type of processing unit used
52
- in the CWL document.
49
+ ## Processing units
53
50
54
51
There are four types of processing units defined in the CWL specification
55
52
{{ cwl_version }}:
@@ -62,12 +59,11 @@ There are four types of processing units defined in the CWL specification
62
59
{{ CWL_PROCESSING_UNITS_GRAPH }}
63
60
64
61
In ` cwltool ` you can execute a CWL document with a command-line tool,
65
- an expression tool, or a workflow.
62
+ an expression tool, or a workflow. Operation is a special unit, not
63
+ covered in this section.
66
64
67
- ``` {note}
68
-
69
- `class: Operation` is a special processing unit, not covered in this section.
70
- ```
65
+ You define the processing unit in your CWL document using the
66
+ ` class ` attribute, e.g. ` class: Workflow ` .
71
67
72
68
### Command-line tool
73
69
@@ -81,20 +77,6 @@ The following example contains a minimal example of a CWL
81
77
command-line tool for the ` echo ` Linux command, using inputs and
82
78
outputs.
83
79
84
- ``` {code-block} cwl
85
- :name: echo.cwl
86
- :caption: "`echo.cwl`"
87
- cwlVersion: v1.2
88
- class: CommandLineTool
89
-
90
- baseCommand: echo
91
-
92
- inputs:
93
- message: string
94
- outputs:
95
- out: stdout
96
- ```
97
-
98
80
``` {graphviz}
99
81
:name: command-line-tool-graph
100
82
:caption: CWL command-line tool.
@@ -110,6 +92,29 @@ digraph "CWL command-line tool" {
110
92
}
111
93
```
112
94
95
+ ``` {code-block} cwl
96
+ :name: echo.cwl
97
+ :caption: "`echo.cwl`"
98
+ cwlVersion: v1.2
99
+ class: CommandLineTool
100
+
101
+ baseCommand: echo
102
+
103
+ stdout: output.txt
104
+
105
+ inputs:
106
+ message:
107
+ type: string
108
+ inputBinding: {}
109
+ outputs:
110
+ out:
111
+ type: string
112
+ outputBinding:
113
+ glob: output.txt
114
+ loadContents: true
115
+ outputEval: $(self[0].contents)
116
+ ```
117
+
113
118
``` {note}
114
119
115
120
The example above uses a simplified form to define inputs and outputs.
@@ -124,21 +129,54 @@ as a Workflow step. It executes a pure JavaScript expression. It is
124
129
meant to be used as a way to isolate complex JavaScript expressions
125
130
that need to operate on input data and produce some result as output.
126
131
127
- ### Workflow
132
+ Similar to the command-line tool it requires ` inputs ` and ` outputs ` .
133
+ But instead of ` baseCommand ` , it requires an ` expression ` attribute.
134
+
135
+ ``` {graphviz}
136
+ :name: expression-tool-graph
137
+ :caption: CWL expression tool.
138
+ :align: center
128
139
129
- Besides having ` class: Workflow ` , the CWL document of a workflow processing
130
- unit must also have the ` cwlVersion ` , ` inputs ` , ` outputs ` , and ` steps ` .
140
+ digraph "CWL command-line tool" {
141
+ rankdir="LR";
142
+ graph [splines=ortho];
131
143
132
- ``` cwl
133
- cwlVersion: {{ cwl_version_text }}
134
- class: Workflow
144
+ node [fontname="Verdana", fontsize="10", shape=box];
145
+ edge [fontname="Verdana", fontsize="10"];
146
+ inputs -> expression -> outputs;
147
+ }
148
+ ```
149
+
150
+ ``` {code-block} cwl
151
+ :name: uppercase.cwl
152
+ :caption: "`uppercase.cwl`"
153
+ cwlVersion: v1.2
154
+ class: ExpressionTool
155
+
156
+ requirements:
157
+ InlineJavascriptRequirement: {}
158
+
159
+ inputs:
160
+ message: string
161
+ outputs:
162
+ uppercase_message: string
135
163
136
- inputs: []
137
- steps: []
138
- outputs: []
164
+ expression: |
165
+ ${ return {"uppercase_message": inputs.message.toUpperCase()}; }
139
166
```
140
167
141
- A workflow step can call a command-line tool or expression tool.
168
+ ``` {note}
169
+
170
+ We had to use an `InlineJavascriptRequirement` as our expression
171
+ contains a JavaScript call in `.toUpperCase()`. This means to tools
172
+ using the expression tool that JavaScript is a requirement.
173
+ ```
174
+
175
+ ### Workflow
176
+
177
+ A workflow is a CWL processing unit that executes command-line tools,
178
+ expression tools, or workflows (sub-workflows) as steps. It must have
179
+ ` inputs ` , ` outputs ` , and ` steps ` defined in the CWL document.
142
180
143
181
``` {graphviz}
144
182
:name: workflow-graph
@@ -155,6 +193,35 @@ digraph "CWL Inputs, Steps, and Outputs" {
155
193
}
156
194
```
157
195
196
+ ``` cwl
197
+ cwlVersion: v1.2
198
+ class: Workflow
199
+
200
+ requirements:
201
+ InlineJavascriptRequirement: {}
202
+
203
+ inputs:
204
+ message: string
205
+
206
+ outputs:
207
+ out:
208
+ type: string
209
+ outputSource: uppercase/uppercase_message
210
+
211
+ steps:
212
+ echo:
213
+ run: echo.cwl
214
+ in:
215
+ message: message
216
+ out: [out]
217
+ uppercase:
218
+ run: uppercase.cwl
219
+ in:
220
+ message:
221
+ source: echo/out
222
+ out: [uppercase_message]
223
+ ```
224
+
158
225
## FAIR workflows
159
226
160
227
CWL has roots in "make" and many similar tools that determine order of
0 commit comments