Skip to content

Commit 540b9f3

Browse files
neurorepromr-c
authored andcommitted
Update the nested worklow description to reflect the content of nestedworkflows.cwl
1 parent f340e79 commit 540b9f3

File tree

1 file changed

+19
-31
lines changed

1 file changed

+19
-31
lines changed

_episodes/22-nested-workflows.md

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,17 @@ alt="Visualization of 1st-workflow.cwl" /></a>
5353
{: .callout}
5454

5555
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.
5858

5959
~~~
6060
compile:
6161
run: 1st-workflow.cwl
6262
in:
63-
inp:
64-
source: create-tar/tar
65-
ex:
63+
tarball: create-tar/tar_compressed_java_file
64+
name_of_file_to_extract:
6665
default: "Hello.java"
67-
out: [classout]
66+
out: [compiled_class]
6867
~~~
6968
{: .source}
7069

@@ -73,9 +72,9 @@ it we had to provide a job file to denote the tar file and `*.java` filename.
7372
This is generally best-practice, as it means it can be reused in multiple parent
7473
workflows, or even in multiple steps within the same workflow.
7574

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
7978
`1st-workflow.cwl` to have more specific input/output names, as those also
8079
appear in its usage as a tool.
8180

@@ -100,35 +99,24 @@ requirement, before adding it to a tar file.
10099
{: .source}
101100

102101
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`:
105104

106105
~~~
107106
run:
108107
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"
115116
~~~
116117
{: .source}
117118

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,
132120
but rather embedded it within the CWL Workflow file? This is generally not best
133121
practice, as the tool then can't be reused. The reason for doing it in this case
134122
is because the command line is hard-coded with filenames that only make sense

0 commit comments

Comments
 (0)