@@ -53,18 +53,17 @@ alt="Visualization of 1st-workflow.cwl" /></a>
53
53
{: .callout}
54
54
55
55
A CWL ` Workflow ` can be used as a ` step ` just like a ` CommandLineTool ` , its CWL
56
- file is included with ` run ` . The workflow inputs (` inp ` and ` ex ` ) and outputs
57
- (` classout ` ) then can be mapped to become the step's input/outputs.
56
+ file is included with ` run ` . The workflow inputs (` tarball ` and ` name_of_file_to_extract ` ) and outputs
57
+ (` compiled_class ` ) then can be mapped to become the step's input/outputs.
58
58
59
59
~~~
60
60
compile:
61
61
run: 1st-workflow.cwl
62
62
in:
63
- inp:
64
- source: create-tar/tar
65
- ex:
63
+ tarball: create-tar/tar_compressed_java_file
64
+ name_of_file_to_extract:
66
65
default: "Hello.java"
67
- out: [classout ]
66
+ out: [compiled_class ]
68
67
~~~
69
68
{: .source}
70
69
@@ -73,9 +72,9 @@ it we had to provide a job file to denote the tar file and `*.java` filename.
73
72
This is generally best-practice, as it means it can be reused in multiple parent
74
73
workflows, or even in multiple steps within the same workflow.
75
74
76
- Here we use ` default: ` to hard-code ` "Hello.java" ` as the ` ex ` input, however
77
- our workflow also requires a tar file at ` inp ` , which we will prepare in the
78
- ` create-tar ` step. At this point it is probably a good idea to refactor
75
+ Here we use ` default: ` to hard-code ` "Hello.java" ` as the ` name_of_file_to_extract `
76
+ input, however our workflow also requires a tar file at ` tarball ` , which we will
77
+ prepare in the ` create-tar ` step. At this point it is probably a good idea to refactor
79
78
` 1st-workflow.cwl ` to have more specific input/output names, as those also
80
79
appear in its usage as a tool.
81
80
@@ -100,35 +99,24 @@ requirement, before adding it to a tar file.
100
99
{: .source}
101
100
102
101
In this case our step can assume ` Hello.java ` rather than be parameterized, so
103
- we can use a simpler ` arguments ` form as long as the CWL workflow engine
104
- supports the ` ShellCommandRequirement ` :
102
+ we can use hardcoded values ` hello.tar ` and ` Hello.java ` in a ` baseCommand ` and
103
+ the resulting ` outputs ` :
105
104
106
105
~~~
107
106
run:
108
107
class: CommandLineTool
109
- requirements:
110
- ShellCommandRequirement: {}
111
- arguments:
112
- - shellQuote: false
113
- valueFrom: >
114
- tar cf hello.tar Hello.java
108
+ inputs: []
109
+ baseCommand: [tar, --create, --file=hello.tar, Hello.java]
110
+ outputs:
111
+ tar_compressed_java_file:
112
+ type: File
113
+ streamable: true
114
+ outputBinding:
115
+ glob: "hello.tar"
115
116
~~~
116
117
{: .source}
117
118
118
- Note the use of ` shellQuote: false ` here, otherwise the shell will try to
119
- execute the quoted binary ` "tar cf hello.tar Hello.java" ` .
120
-
121
- Here the ` > ` block means that newlines are stripped, so it's possible to write
122
- the single command on multiple lines. Similarly, the ` | ` we used above will
123
- preserve newlines, combined with ` ShellCommandRequirement ` this would allow
124
- embedding a shell script.
125
- Shell commands should however be used sparingly in CWL, as it means you
126
- "jump out" of the workflow and no longer get reusable components, provenance or
127
- scalability. For reproducibility and portability it is recommended to only use
128
- shell commands together with a ` DockerRequirement ` hint, so that the commands
129
- are executed in a predictable shell environment.
130
-
131
- Did you notice that we didn't split out the ` tar cf ` tool to a separate file,
119
+ Did you notice that we didn't split out the ` tar --create ` tool to a separate file,
132
120
but rather embedded it within the CWL Workflow file? This is generally not best
133
121
practice, as the tool then can't be reused. The reason for doing it in this case
134
122
is because the command line is hard-coded with filenames that only make sense
0 commit comments