Skip to content

Commit 0b83223

Browse files
authored
Merge pull request #19 from tobyhodges/code_blocks
Code blocks
2 parents 7763054 + 59ceae3 commit 0b83223

18 files changed

+237
-163
lines changed

_episodes/02-1st-example.md

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,22 @@ The simplest "hello world" program. This accepts one input parameter, writes a
1717

1818

1919
*1st-tool.cwl*
20-
```
20+
~~~
2121
{% include cwl/1st-tool.cwl %}
22-
```
22+
~~~
23+
{: .source}
2324

2425
Use a YAML object in a separate file to describe the input of a run:
2526

2627
*echo-job.yml*
27-
```
28+
~~~
2829
{% include cwl/echo-job.yml %}
29-
```
30+
~~~
31+
{: .source}
3032

3133
Now invoke `cwl-runner` with the tool wrapper and the input object on the command line:
3234

33-
```
35+
~~~
3436
$ cwl-runner 1st-tool.cwl echo-job.yml
3537
[job 1st-tool.cwl] /tmp/tmpmM5S_1$ echo \
3638
'Hello world!'
@@ -39,36 +41,41 @@ Hello world!
3941
{}
4042
Final process status is success
4143
42-
```
44+
~~~
45+
{: .output}
4346

4447
What's going on here? Let's break it down:
4548

46-
```
49+
~~~
4750
cwlVersion: v1.0
4851
class: CommandLineTool
49-
```
52+
~~~
53+
{: .source}
5054

5155
The `cwlVersion` field indicates the version of the CWL spec used by the document. The `class` field indicates this document describes a command line tool.
5256

53-
```
57+
~~~
5458
baseCommand: echo
55-
```
59+
~~~
60+
{: .source}
5661

5762
The `baseCommand` provides the name of program that will actually run (`echo`)
5863

59-
```
64+
~~~
6065
inputs:
6166
message:
6267
type: string
6368
inputBinding:
6469
position: 1
65-
```
70+
~~~
71+
{: .source}
6672

6773
The `inputs` section describes the inputs of the tool. This is a list of input parameters and each parameter includes an identifier, a data type, and optionally an `inputBinding` which describes how this input parameter should appear on the command line. In this example, the `position` field indicates where it should appear on the command line.
6874

69-
```
75+
~~~
7076
outputs: []
71-
```
77+
~~~
78+
{: .source}
7279

7380
This tool has no formal output, so the `outputs` section is an empty list.
7481

_episodes/03-input.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,18 @@ types and appearing on the command line in different ways:
3434

3535
*inp-job.yml*
3636

37-
```
37+
~~~
3838
{% include cwl/inp-job.yml %}
39-
```
39+
~~~
40+
{: .source}
4041

4142
Notice that "example_file", as a `File` type, must be provided as an
4243
object with the fields `class: File` and `path`.
4344

4445
Next, create a whale.txt and invoke `cwl-runner` with the tool wrapper and the
4546
input object on the command line:
4647

47-
```
48+
~~~
4849
$ touch whale.txt
4950
$ cwl-runner inp.cwl inp-job.yml
5051
[job inp.cwl] /tmp/tmpzrSnfX$ echo \
@@ -57,7 +58,8 @@ $ cwl-runner inp.cwl inp-job.yml
5758
[job inp.cwl] completed success
5859
{}
5960
Final process status is success
60-
```
61+
~~~
62+
{: .output}
6163
> ## Where did those `/tmp` paths come from?
6264
>
6365
> The CWL reference runner (cwltool) and other runners create temporary
@@ -71,54 +73,58 @@ input parameter should be appear on the tool's command line. If
7173
`inputBinding` is missing, the parameter does not appear on the command
7274
line. Let's look at each example in detail.
7375

74-
```
76+
~~~
7577
example_flag:
7678
type: boolean
7779
inputBinding:
7880
position: 1
7981
prefix: -f
80-
```
82+
~~~
83+
{: .source}
8184

8285
Boolean types are treated as a flag. If the input parameter
8386
"example_flag" is "true", then `prefix` will be added to the
8487
command line. If false, no flag is added.
8588

86-
```
89+
~~~
8790
example_string:
8891
type: string
8992
inputBinding:
9093
position: 3
9194
prefix: --example-string
92-
```
95+
~~~
96+
{: .source}
9397

9498
String types appear on the command line as literal values. The `prefix`
9599
is optional, if provided, it appears as a separate argument on the
96100
command line before the parameter . In the example above, this is
97101
rendered as `--example-string hello`.
98102

99-
```
103+
~~~
100104
example_int:
101105
type: int
102106
inputBinding:
103107
position: 2
104108
prefix: -i
105109
separate: false
106-
```
110+
~~~
111+
{: .source}
107112

108113
Integer (and floating point) types appear on the command line with
109114
decimal text representation. When the option `separate` is false (the
110115
default value is true), the prefix and value are combined into a single
111116
argument. In the example above, this is rendered as `-i42`.
112117

113118

114-
```
119+
~~~
115120
example_file:
116121
type: File?
117122
inputBinding:
118123
prefix: --file=
119124
separate: false
120125
position: 4
121-
```
126+
~~~
127+
{: .source}
122128

123129
File types appear on the command line as the path to the file. When the
124130
parameter type ends with a question mark `?` it indicates that the

_episodes/04-output.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,22 @@ themselves, or come from examining the content of those files.
2525

2626
*tar.cwl*
2727

28-
```
28+
~~~
2929
{% include cwl/tar.cwl %}
30-
```
30+
~~~
31+
{: .source}
3132

3233
*tar-job.yml*
3334

34-
```
35+
~~~
3536
{% include cwl/tar-job.yml %}
36-
```
37+
~~~
38+
{: .source}
3739

3840
Next, create a tar file for the example and invoke `cwl-runner` with the tool
3941
wrapper and the input object on the command line:
4042

41-
```
43+
~~~
4244
$ touch hello.txt && tar -cvf hello.tar hello.txt
4345
$ cwl-runner tar.cwl tar-job.yml
4446
[job tar.cwl] /tmp/tmpqOeawQ$ tar \
@@ -47,29 +49,31 @@ $ cwl-runner tar.cwl tar-job.yml
4749
[job tar.cwl] completed success
4850
{
4951
"example_out": {
50-
"checksum": "sha1$da39a3ee5e6b4b0d3255bfef95601890afd80709",
51-
"basename": "hello.txt",
52-
"nameroot": "hello",
53-
"nameext": ".txt",
54-
"location": "file:///home/me/cwl/user_guide/hello.txt",
55-
"path": "/home/me/cwl/user_guide/hello.txt",
56-
"class": "File",
52+
"checksum": "sha1$da39a3ee5e6b4b0d3255bfef95601890afd80709",
53+
"basename": "hello.txt",
54+
"nameroot": "hello",
55+
"nameext": ".txt",
56+
"location": "file:///home/me/cwl/user_guide/hello.txt",
57+
"path": "/home/me/cwl/user_guide/hello.txt",
58+
"class": "File",
5759
"size": 0
5860
}
5961
}
6062
Final process status is success
61-
```
63+
~~~
64+
{: .output}
6265

6366
The field `outputBinding` describes how to to set the value of each
6467
output parameter.
6568

66-
```
69+
~~~
6770
outputs:
6871
example_out:
6972
type: File
7073
outputBinding:
7174
glob: hello.txt
72-
```
75+
~~~
76+
{: .source}
7377

7478
The `glob` field consists of the name of a file in the output directory.
7579
If you don't know name of the file in advance, you can use a wildcard pattern like `*.txt`.

_episodes/05-stdout.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,22 @@ stdout` on the corresponding output parameter.
1616

1717
*stdout.cwl*
1818

19-
```
19+
~~~
2020
{% include cwl/stdout.cwl %}
21-
```
21+
~~~
22+
{: .source}
2223

2324
*echo-job.yml*
2425

25-
```
26+
~~~
2627
{% include cwl/echo-job.yml %}
27-
```
28+
~~~
29+
{: .source}
2830

2931
Now invoke `cwl-runner` providing the tool wrapper and the input object
3032
on the command line:
3133

32-
```
34+
~~~
3335
$ cwl-runner stdout.cwl echo-job.yml
3436
[job stdout.cwl] /tmp/tmpE0gTz7$ echo \
3537
'Hello world!' > /tmp/tmpE0gTz7/output.txt
@@ -48,4 +50,5 @@ $ cwl-runner stdout.cwl echo-job.yml
4850
}
4951
Final process status is success
5052
51-
```
53+
~~~
54+
{: .output}

_episodes/06-params.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,22 @@ fields.
1818

1919
*tar-param.cwl*
2020

21-
```
21+
~~~
2222
{% include cwl/tar-param.cwl %}
23-
```
23+
~~~
24+
{: .source}
2425

2526
*tar-param-job.yml*
2627

27-
```
28+
~~~
2829
{% include cwl/tar-param-job.yml %}
29-
```
30+
~~~
31+
{: .source}
3032

3133
Create your input files and invoke `cwl-runner` with the tool wrapper and the
3234
input object on the command line:
3335

34-
```
36+
~~~
3537
$ rm hello.tar || true && touch goodbye.txt && tar -cvf hello.tar goodbye.txt
3638
$ cwl-runner tar-param.cwl tar-param-job.yml
3739
[job tar-param.cwl] /tmp/tmpwH4ouT$ tar \
@@ -41,29 +43,31 @@ $ cwl-runner tar-param.cwl tar-param-job.yml
4143
[job tar-param.cwl] completed success
4244
{
4345
"example_out": {
44-
"checksum": "sha1$da39a3ee5e6b4b0d3255bfef95601890afd80709",
45-
"basename": "goodbye.txt",
46-
"nameroot": "goodbye",
47-
"nameext": ".txt",
48-
"location": "file:///home/me/cwl/user_guide/goodbye.txt",
49-
"path": "/home/me/cwl/user_guide/goodbye.txt",
50-
"class": "File",
46+
"checksum": "sha1$da39a3ee5e6b4b0d3255bfef95601890afd80709",
47+
"basename": "goodbye.txt",
48+
"nameroot": "goodbye",
49+
"nameext": ".txt",
50+
"location": "file:///home/me/cwl/user_guide/goodbye.txt",
51+
"path": "/home/me/cwl/user_guide/goodbye.txt",
52+
"class": "File",
5153
"size": 0
5254
}
5355
}
5456
Final process status is success
55-
```
57+
~~~
58+
{: .output}
5659

5760
Certain fields permit parameter references which are enclosed in `$(...)`.
5861
These are evaluated and replaced with value being referenced.
5962

60-
```
63+
~~~
6164
outputs:
6265
example_out:
6366
type: File
6467
outputBinding:
6568
glob: $(inputs.extractfile)
66-
```
69+
~~~
70+
{: .source}
6771

6872
References are written using a subset of Javascript syntax. In this
6973
example, `$(inputs.extractfile)`, `$(inputs["extractfile"])`, and

_episodes/07-containers.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,22 @@ This example runs a simple Node.js script inside a Docker container.
2626

2727
*docker.cwl*
2828

29-
```
29+
~~~
3030
{% include cwl/docker.cwl %}
31-
```
31+
~~~
32+
{: .source}
3233

3334
*docker-job.yml*
3435

35-
```
36+
~~~
3637
{% include cwl/docker-job.yml %}
37-
```
38+
~~~
39+
{: .source}
3840

3941
Provide a "hello.js" and invoke `cwl-runner` providing the tool wrapper and the
4042
input object on the command line:
4143

42-
```
44+
~~~
4345
$ echo "console.log(\"Hello World\");" > hello.js
4446
$ cwl-runner docker.cwl docker-job.yml
4547
[job docker.cwl] /tmp/tmpgugLND$ docker \
@@ -61,7 +63,8 @@ Hello World
6163
[job docker.cwl] completed success
6264
{}
6365
Final process status is success
64-
```
66+
~~~
67+
{: .output}
6568

6669
Notice the CWL runner has constructed a Docker command line to run the
6770
script. One of the responsibilities of the CWL runner is to adjust the paths of

0 commit comments

Comments
 (0)