Skip to content

Commit 13aa1b6

Browse files
mribeirodantaspditommasobentsherman
authored
Document emit option in process outputs (#4437)
Signed-off-by: Marcel Ribeiro-Dantas <mribeirodantas@seqera.io> Signed-off-by: Ben Sherman <bentshermann@gmail.com> Co-authored-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com> Co-authored-by: Ben Sherman <bentshermann@gmail.com>
1 parent d9ee987 commit 13aa1b6

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

docs/process.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,52 @@ output:
11771177

11781178
In this example, the process is normally expected to produce an `output.txt` file, but in the cases where the file is legitimately missing, the process does not fail. The output channel will only contain values for those processes that produce `output.txt`.
11791179

1180+
(process-multiple-outputs)=
1181+
1182+
### Multiple outputs
1183+
1184+
When a process declares multiple outputs, each output can be accessed by index. The following example prints the second process output (indexes start at zero):
1185+
1186+
```groovy
1187+
process FOO {
1188+
output:
1189+
path 'bye_file.txt'
1190+
path 'hi_file.txt'
1191+
1192+
"""
1193+
echo "bye" > bye_file.txt
1194+
echo "hi" > hi_file.txt
1195+
"""
1196+
}
1197+
1198+
workflow {
1199+
FOO()
1200+
FOO.out[1].view()
1201+
}
1202+
```
1203+
1204+
You can also use the `emit` option to assign a name to each output and access them by name:
1205+
1206+
```groovy
1207+
process FOO {
1208+
output:
1209+
path 'bye_file.txt', emit: bye_file
1210+
path 'hi_file.txt', emit: hi_file
1211+
1212+
"""
1213+
echo "bye" > bye_file.txt
1214+
echo "hi" > hi_file.txt
1215+
"""
1216+
}
1217+
1218+
workflow {
1219+
FOO()
1220+
FOO.out.hi_file.view()
1221+
}
1222+
```
1223+
1224+
See {ref}`workflow-process-invocation` for more details.
1225+
11801226
## When
11811227

11821228
The `when` block allows you to define a condition that must be satisfied in order to execute the process. The condition can be any expression that returns a boolean value.

docs/workflow.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ The `main:` label can be omitted if there are no `take:` or `emit:` blocks.
4141
Workflows were introduced in DSL2. If you are still using DSL1, see the {ref}`dsl1-page` page to learn how to migrate your Nextflow pipelines to DSL2.
4242
:::
4343

44+
(workflow-process-invocation)=
45+
4446
## Process invocation
4547

4648
A process can be invoked like a function in a workflow definition, passing the expected input channels like function arguments. For example:
@@ -142,6 +144,8 @@ workflow {
142144
}
143145
```
144146

147+
See {ref}`process-multiple-outputs` for more details.
148+
145149
### Process named stdout
146150

147151
The `emit` option can also be used to name a `stdout` output:

0 commit comments

Comments
 (0)