3
3
doc :
4
4
- $include : userguide-intro.md
5
5
6
+ - |
7
+ # Wrapping Command Line Tools
8
+
6
9
- |
7
10
## First example
8
11
11
14
output. CWL documents are written in [JSON](http://json.org) or
12
15
[YAML](http://yaml.org), or a mix of the two.
13
16
14
- *1st.cwl*
17
+ *1st-tool .cwl*
15
18
```
16
- - $include : examples/1st.cwl
19
+ - $include : examples/1st-tool .cwl
17
20
- |
18
21
```
19
22
29
32
command line:
30
33
31
34
```
32
- $ cwl-runner 1st.cwl echo-job.yml
35
+ $ cwl-runner 1st-tool .cwl echo-job.yml
33
36
[job 140199012414352] $ echo 'Hello world!'
34
37
Hello world!
35
38
Final process status is success
308
311
Invoke `cwl-runner` with the tool wrapper and the input object on the
309
312
command line:
310
313
```
311
- $ cwl-runner example- tar-param.cwl example- tar-param-job.yml
314
+ $ cwl-runner tar-param.cwl tar-param-job.yml
312
315
[job 139868145165200] $ tar xf /home/example/hello.tar goodbye.txt
313
316
Final process status is success
314
317
{
475
478
476
479
```
477
480
$ cwl-runner array-inputs.cwl array-inputs-job.yml
478
- /home/peter/work/cwl-venv/bin/cwltool 1.0.20160325210917
479
- [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
481
+ [job 140334923640912] /home/example$ echo -A one two three -B=four -B=five -B=six -C=seven,eight,nine
480
482
-A one two three -B=four -B=five -B=six -C=seven,eight,nine
481
483
Final process status is success
482
484
{}
492
494
You can specify arrays of arrays, arrays of records, and other complex
493
495
types.
494
496
497
+ - |
498
+ ## Array outputs
499
+
500
+ You can also capture multiple output files into an array of files using `glob`.
501
+
502
+ *array-outputs.cwl*
503
+ ```
504
+ - $include : examples/array-outputs.cwl
505
+ - |
506
+ ```
507
+
508
+ *array-outpust-job.yml*
509
+ ```
510
+ - $include : examples/array-outputs-job.yml
511
+ - |
512
+ ```
513
+
514
+ Now invoke `cwl-runner` providing the tool wrapper and the input object
515
+ on the command line:
516
+
517
+ ```
518
+ $ cwl-runner array-outputs.cwl array-outputs-job.yml
519
+ [job 140190876078160] /home/example$ touch foo.txt bar.dat baz.txt
520
+ Final process status is success
521
+ {
522
+ "output": [
523
+ {
524
+ "size": 0,
525
+ "path": "/home/peter/work/common-workflow-language/draft-3/examples/foo.txt",
526
+ "checksum": "sha1$da39a3ee5e6b4b0d3255bfef95601890afd80709",
527
+ "class": "File"
528
+ },
529
+ {
530
+ "size": 0,
531
+ "path": "/home/peter/work/common-workflow-language/draft-3/examples/baz.txt",
532
+ "checksum": "sha1$da39a3ee5e6b4b0d3255bfef95601890afd80709",
533
+ "class": "File"
534
+ }
535
+ ]
536
+ }
537
+ ```
538
+
495
539
- |
496
540
## Record inputs, dependent and mutually exclusive parameters
497
541
672
716
673
717
```
674
718
$ cwl-runner linkfile.cwl arguments-job.yml
675
- [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
719
+ [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
676
720
Final process status is success
677
721
{
678
722
"classfile": {
679
723
"size": 416,
680
- "path": "/home/peter/work/common-workflow-language/draft-3/examples /Hello.class",
724
+ "path": "/home/example /Hello.class",
681
725
"checksum": "sha1$2f7ac33c1f3aac3f1fec7b936b6562422c85b38a",
682
726
"class": "File"
683
727
}
684
728
}
685
729
```
730
+
731
+ - |
732
+ # Writing Workflows
733
+
734
+ ## First workflow
735
+
736
+ This workflow extracts a java source file from a tar file and then
737
+ compiles it.
738
+
739
+ *1st-workflow.cwl*
740
+ ```
741
+ - $include : examples/1st-workflow.cwl
742
+ - |
743
+ ```
744
+
745
+ Use a JSON object in a separate file to describe the input of a run:
746
+
747
+ *1st-workflow-job.yml*
748
+ ```
749
+ - $include : examples/1st-workflow-job.yml
750
+ - |
751
+ ```
752
+
753
+ Now invoke `cwl-runner` with the tool wrapper and the input object on the
754
+ command line:
755
+
756
+ ```
757
+ $ cwl-runner 1st-workflow.cwl 1st-workflow-job.yml
758
+ [job untar] /tmp/tmp94qFiM$ tar xf /home/example/hello.tar Hello.java
759
+ [step untar] completion status is success
760
+ [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
761
+ [step compile] completion status is success
762
+ [workflow 1st-workflow.cwl] outdir is /home/example
763
+ Final process status is success
764
+ {
765
+ "classout": {
766
+ "path": "/home/example/Hello.class",
767
+ "checksum": "sha1$2f7ac33c1f3aac3f1fec7b936b6562422c85b38a",
768
+ "class": "File",
769
+ "size": 416
770
+ }
771
+ }
772
+ ```
773
+
774
+ What's going on here? Let's break it down:
775
+
776
+ ```
777
+ cwlVersion: cwl:draft-3
778
+ class: Workflow
779
+ ```
780
+
781
+ The 'cwlVersion` field indicates the version of the CWL spec used by the
782
+ document. The `class` field indicates this document describes a workflow.
783
+
784
+
785
+ ```
786
+ inputs:
787
+ - id: inp
788
+ type: File
789
+ - id: ex
790
+ type: string
791
+ ```
792
+
793
+ The `inputs` section describes the inputs of the workflow. This is a
794
+ list of input parameters where each parameter consists of an identifier
795
+ and a data type. These parameters can be used as sources for input to
796
+ specific workflows steps.
797
+
798
+ ```
799
+ outputs:
800
+ - id: classout
801
+ type: File
802
+ source: "#compile/classfile"
803
+ ```
804
+
805
+ The `outputs` section describes the outputs of the workflow. This is a
806
+ list of output parameters where each parameter consists of an identifier
807
+ and a data type. The `source` connects the output parameter `classfile`
808
+ of the `compile` step to the workflow output parameter `classout`.
809
+
810
+ ```
811
+ steps:
812
+ - id: untar
813
+ run: tar-param.cwl
814
+ inputs:
815
+ - id: tarfile
816
+ source: "#inp"
817
+ - id: extractfile
818
+ source: "#ex"
819
+ outputs:
820
+ - id: example_out
821
+ ```
822
+
823
+ The `steps` section describes the actual steps of the workflow. In this
824
+ example, the first step extracts a file from a tar file, and the second
825
+ step compiles the file from the first step using the java compiler.
826
+ Workflow steps are not necessarily run in the order they are listed,
827
+ instead the order is determined by the dependencies between steps (using
828
+ `source`). In addition, workflow steps which do not depend on one
829
+ another may run in parallel.
830
+
831
+ The first step, `untar` runs `tar-param.cwl` (described previously in
832
+ [Parameter references](#Parameter_references)). This tool has two input
833
+ parameters, `tarfile` and `extractfile` and one output parameter
834
+ `example_out`.
835
+
836
+ The `inputs` section of the workflow step connects these two input
837
+ parameters to the inputs of the workflow, `#inp` and `#ex` using
838
+ `source`. This means that when the workflow step is executed, the values
839
+ assigned to `#inp` and `#ex` will be used for the parameters `tarfile`
840
+ and `extractfile` in order to run the tool.
841
+
842
+ The `outputs` section of the workflow step lists the output parameters
843
+ that are expected from the tool.
844
+
845
+ ```
846
+ - id: compile
847
+ run: arguments.cwl
848
+ inputs:
849
+ - id: src
850
+ source: "#untar/example_out"
851
+ outputs:
852
+ - id: classfile
853
+ ```
854
+
855
+ The second step `compile` depends on the results from the first step by
856
+ connecting the input parameter `src` to the output parameter of `untar`
857
+ using `#untar/example_out`. The output of this step `classfile` is
858
+ connected to the `outputs` section for the Workflow, described above.
0 commit comments