Skip to content

Commit 43f6c7c

Browse files
committed
Adding information about Workflow, updating CWL workflows
1 parent f31cf32 commit 43f6c7c

File tree

1 file changed

+103
-36
lines changed

1 file changed

+103
-36
lines changed

src/basic-concepts.md

Lines changed: 103 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,18 @@ in parallel across many nodes.
3535

3636
% TODO: add a link to the Core Concepts -> Requirements section below?
3737

38-
```{note}
38+
## Requirements
39+
3940
The CWL specification allows for implementations to provide extra
4041
functionality through Requirements. Some CWL runners may provide
4142
Requirements that are not in the specification. For example, GPU
4243
requirements are supported in `cwltool`, but it is not part of the
4344
{{ cwl_version }} specification. Requirements are explained in
4445
detail in another section.
45-
```
4646

47-
## Processing units
47+
% TODO: better explanation about requirements, with an example.
4848

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
5350

5451
There are four types of processing units defined in the CWL specification
5552
{{ cwl_version }}:
@@ -62,12 +59,11 @@ There are four types of processing units defined in the CWL specification
6259
{{ CWL_PROCESSING_UNITS_GRAPH }}
6360

6461
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.
6664

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`.
7167

7268
### Command-line tool
7369

@@ -81,20 +77,6 @@ The following example contains a minimal example of a CWL
8177
command-line tool for the `echo` Linux command, using inputs and
8278
outputs.
8379

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-
9880
```{graphviz}
9981
:name: command-line-tool-graph
10082
:caption: CWL command-line tool.
@@ -110,6 +92,29 @@ digraph "CWL command-line tool" {
11092
}
11193
```
11294

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+
113118
```{note}
114119
115120
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
124129
meant to be used as a way to isolate complex JavaScript expressions
125130
that need to operate on input data and produce some result as output.
126131

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
128139
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];
131143
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
135163
136-
inputs: []
137-
steps: []
138-
outputs: []
164+
expression: |
165+
${ return {"uppercase_message": inputs.message.toUpperCase()}; }
139166
```
140167

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.
142180

143181
```{graphviz}
144182
:name: workflow-graph
@@ -155,6 +193,35 @@ digraph "CWL Inputs, Steps, and Outputs" {
155193
}
156194
```
157195

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+
158225
## FAIR workflows
159226

160227
CWL has roots in "make" and many similar tools that determine order of

0 commit comments

Comments
 (0)