Skip to content

Commit 4fcf203

Browse files
author
Peter Amstutz
committed
Copy draft-3 user guide.
1 parent c113a39 commit 4fcf203

File tree

4 files changed

+185
-20
lines changed

4 files changed

+185
-20
lines changed

v1.0/UserGuide.yml

Lines changed: 181 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
doc:
44
- $include: userguide-intro.md
55

6+
- |
7+
# Wrapping Command Line Tools
8+
69
- |
710
## First example
811
@@ -11,9 +14,9 @@
1114
output. CWL documents are written in [JSON](http://json.org) or
1215
[YAML](http://yaml.org), or a mix of the two.
1316
14-
*1st.cwl*
17+
*1st-tool.cwl*
1518
```
16-
- $include: examples/1st.cwl
19+
- $include: examples/1st-tool.cwl
1720
- |
1821
```
1922
@@ -29,7 +32,7 @@
2932
command line:
3033
3134
```
32-
$ cwl-runner 1st.cwl echo-job.yml
35+
$ cwl-runner 1st-tool.cwl echo-job.yml
3336
[job 140199012414352] $ echo 'Hello world!'
3437
Hello world!
3538
Final process status is success
@@ -311,7 +314,7 @@
311314
command line:
312315
```
313316
$ rm hello.tar || true && touch goodbye.txt && tar -cvf hello.tar
314-
$ cwl-runner example-tar-param.cwl example-tar-param-job.yml
317+
$ cwl-runner tar-param.cwl tar-param-job.yml
315318
[job 139868145165200] $ tar xf /home/example/hello.tar goodbye.txt
316319
Final process status is success
317320
{
@@ -480,8 +483,7 @@
480483
481484
```
482485
$ cwl-runner array-inputs.cwl array-inputs-job.yml
483-
/home/peter/work/cwl-venv/bin/cwltool 1.0.20160325210917
484-
[job 140334923640912] /home/peter/work/common-workflow-language/draft-3/examples$ echo -A one two three -B=four -B=five -B=six -C=seven,eight,nine
486+
[job 140334923640912] /home/example$ echo -A one two three -B=four -B=five -B=six -C=seven,eight,nine
485487
-A one two three -B=four -B=five -B=six -C=seven,eight,nine
486488
Final process status is success
487489
{}
@@ -497,6 +499,48 @@
497499
You can specify arrays of arrays, arrays of records, and other complex
498500
types.
499501
502+
- |
503+
## Array outputs
504+
505+
You can also capture multiple output files into an array of files using `glob`.
506+
507+
*array-outputs.cwl*
508+
```
509+
- $include: examples/array-outputs.cwl
510+
- |
511+
```
512+
513+
*array-outpust-job.yml*
514+
```
515+
- $include: examples/array-outputs-job.yml
516+
- |
517+
```
518+
519+
Now invoke `cwl-runner` providing the tool wrapper and the input object
520+
on the command line:
521+
522+
```
523+
$ cwl-runner array-outputs.cwl array-outputs-job.yml
524+
[job 140190876078160] /home/example$ touch foo.txt bar.dat baz.txt
525+
Final process status is success
526+
{
527+
"output": [
528+
{
529+
"size": 0,
530+
"path": "/home/peter/work/common-workflow-language/draft-3/examples/foo.txt",
531+
"checksum": "sha1$da39a3ee5e6b4b0d3255bfef95601890afd80709",
532+
"class": "File"
533+
},
534+
{
535+
"size": 0,
536+
"path": "/home/peter/work/common-workflow-language/draft-3/examples/baz.txt",
537+
"checksum": "sha1$da39a3ee5e6b4b0d3255bfef95601890afd80709",
538+
"class": "File"
539+
}
540+
]
541+
}
542+
```
543+
500544
- |
501545
## Record inputs, dependent and mutually exclusive parameters
502546
@@ -677,14 +721,143 @@
677721
678722
```
679723
$ cwl-runner linkfile.cwl arguments-job.yml
680-
[job 139928309171664] /home/example$ docker run -i --volume=/home/peter/work/common-workflow-language/draft-3/examples/Hello.java:/var/lib/cwl/job557617295_examples/Hello.java:ro --volume=/home/peter/work/common-workflow-language/draft-3/examples:/var/spool/cwl:rw --volume=/tmp/tmpmNbApw:/tmp:rw --workdir=/var/spool/cwl --read-only=true --net=none --user=1001 --rm --env=TMPDIR=/tmp java:7 javac Hello.java
724+
[job 139928309171664] /home/example$ docker run -i --volume=/home/example/Hello.java:/var/lib/cwl/job557617295_examples/Hello.java:ro --volume=/home/example:/var/spool/cwl:rw --volume=/tmp/tmpmNbApw:/tmp:rw --workdir=/var/spool/cwl --read-only=true --net=none --user=1001 --rm --env=TMPDIR=/tmp java:7 javac Hello.java
681725
Final process status is success
682726
{
683727
"classfile": {
684728
"size": 416,
685-
"path": "/home/peter/work/common-workflow-language/draft-3/examples/Hello.class",
729+
"path": "/home/example/Hello.class",
686730
"checksum": "sha1$2f7ac33c1f3aac3f1fec7b936b6562422c85b38a",
687731
"class": "File"
688732
}
689733
}
690734
```
735+
736+
- |
737+
# Writing Workflows
738+
739+
## First workflow
740+
741+
This workflow extracts a java source file from a tar file and then
742+
compiles it.
743+
744+
*1st-workflow.cwl*
745+
```
746+
- $include: examples/1st-workflow.cwl
747+
- |
748+
```
749+
750+
Use a JSON object in a separate file to describe the input of a run:
751+
752+
*1st-workflow-job.yml*
753+
```
754+
- $include: examples/1st-workflow-job.yml
755+
- |
756+
```
757+
758+
Now invoke `cwl-runner` with the tool wrapper and the input object on the
759+
command line:
760+
761+
```
762+
$ cwl-runner 1st-workflow.cwl 1st-workflow-job.yml
763+
[job untar] /tmp/tmp94qFiM$ tar xf /home/example/hello.tar Hello.java
764+
[step untar] completion status is success
765+
[job compile] /tmp/tmpu1iaKL$ docker run -i --volume=/tmp/tmp94qFiM/Hello.java:/var/lib/cwl/job301600808_tmp94qFiM/Hello.java:ro --volume=/tmp/tmpu1iaKL:/var/spool/cwl:rw --volume=/tmp/tmpfZnNdR:/tmp:rw --workdir=/var/spool/cwl --read-only=true --net=none --user=1001 --rm --env=TMPDIR=/tmp java:7 javac -d /var/spool/cwl /var/lib/cwl/job301600808_tmp94qFiM/Hello.java
766+
[step compile] completion status is success
767+
[workflow 1st-workflow.cwl] outdir is /home/example
768+
Final process status is success
769+
{
770+
"classout": {
771+
"path": "/home/example/Hello.class",
772+
"checksum": "sha1$2f7ac33c1f3aac3f1fec7b936b6562422c85b38a",
773+
"class": "File",
774+
"size": 416
775+
}
776+
}
777+
```
778+
779+
What's going on here? Let's break it down:
780+
781+
```
782+
cwlVersion: cwl:draft-3
783+
class: Workflow
784+
```
785+
786+
The 'cwlVersion` field indicates the version of the CWL spec used by the
787+
document. The `class` field indicates this document describes a workflow.
788+
789+
790+
```
791+
inputs:
792+
- id: inp
793+
type: File
794+
- id: ex
795+
type: string
796+
```
797+
798+
The `inputs` section describes the inputs of the workflow. This is a
799+
list of input parameters where each parameter consists of an identifier
800+
and a data type. These parameters can be used as sources for input to
801+
specific workflows steps.
802+
803+
```
804+
outputs:
805+
- id: classout
806+
type: File
807+
source: "#compile/classfile"
808+
```
809+
810+
The `outputs` section describes the outputs of the workflow. This is a
811+
list of output parameters where each parameter consists of an identifier
812+
and a data type. The `source` connects the output parameter `classfile`
813+
of the `compile` step to the workflow output parameter `classout`.
814+
815+
```
816+
steps:
817+
- id: untar
818+
run: tar-param.cwl
819+
inputs:
820+
- id: tarfile
821+
source: "#inp"
822+
- id: extractfile
823+
source: "#ex"
824+
outputs:
825+
- id: example_out
826+
```
827+
828+
The `steps` section describes the actual steps of the workflow. In this
829+
example, the first step extracts a file from a tar file, and the second
830+
step compiles the file from the first step using the java compiler.
831+
Workflow steps are not necessarily run in the order they are listed,
832+
instead the order is determined by the dependencies between steps (using
833+
`source`). In addition, workflow steps which do not depend on one
834+
another may run in parallel.
835+
836+
The first step, `untar` runs `tar-param.cwl` (described previously in
837+
[Parameter references](#Parameter_references)). This tool has two input
838+
parameters, `tarfile` and `extractfile` and one output parameter
839+
`example_out`.
840+
841+
The `inputs` section of the workflow step connects these two input
842+
parameters to the inputs of the workflow, `#inp` and `#ex` using
843+
`source`. This means that when the workflow step is executed, the values
844+
assigned to `#inp` and `#ex` will be used for the parameters `tarfile`
845+
and `extractfile` in order to run the tool.
846+
847+
The `outputs` section of the workflow step lists the output parameters
848+
that are expected from the tool.
849+
850+
```
851+
- id: compile
852+
run: arguments.cwl
853+
inputs:
854+
- id: src
855+
source: "#untar/example_out"
856+
outputs:
857+
- id: classfile
858+
```
859+
860+
The second step `compile` depends on the results from the first step by
861+
connecting the input parameter `src` to the output parameter of `untar`
862+
using `#untar/example_out`. The output of this step `classfile` is
863+
connected to the `outputs` section for the Workflow, described above.

v1.0/examples/1st.cwl

Lines changed: 0 additions & 9 deletions
This file was deleted.

v1.0/examples/arguments.cwl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
cwlVersion: cwl:draft-3
22
class: CommandLineTool
3+
label: Example trivial wrapper for Java 7 compiler
34
baseCommand: javac
45
hints:
56
- class: DockerRequirement

v1.0/userguide-intro.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ Hello!
44

55
This guide will introduce you to writing tool wrappers and workflows using the
66
Common Workflow Language (CWL). This guide describes the current stable
7-
specification, draft 3.
7+
specification, version 1.0.
8+
9+
Note: This document is a work in progress. Not all features are covered, yet.
810

911
<!--ToC-->
1012

@@ -24,5 +26,3 @@ technologies such as Docker, be used with CWL implementations from different
2426
vendors, and is well suited for describing large-scale workflows in cluster,
2527
cloud and high performance computing environments where tasks are scheduled in
2628
parallel across many nodes.
27-
28-
# Wrapping Command Line Tools

0 commit comments

Comments
 (0)