Skip to content

Commit c7536c9

Browse files
authored
Fix bugs in workflow outputs (#5978)
Signed-off-by: Ben Sherman <[email protected]>
1 parent 72bc4c2 commit c7536c9

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

modules/nextflow/src/main/groovy/nextflow/script/WorkflowBinding.groovy

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,11 @@ class WorkflowBinding extends Binding {
159159
}
160160

161161
void _publish_(String name, Object source) {
162-
if( source instanceof ChannelOut )
163-
throw new ScriptRuntimeException("Cannot assign a multi-channel to a workflow output: $name")
162+
if( source instanceof ChannelOut ) {
163+
if( source.size() > 1 )
164+
throw new ScriptRuntimeException("Cannot assign a multi-channel to a workflow output: $name")
165+
source = source[0]
166+
}
164167

165168
owner.session.outputs[name] = source instanceof DataflowWriteChannel
166169
? source

modules/nf-lang/src/main/java/nextflow/script/control/ScriptToGroovyVisitor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,8 @@ public void visitMethodCallExpression(MethodCallExpression node) {
489489

490490
private void visitPathDirective(MethodCallExpression node) {
491491
var code = asDslBlock(node, 1);
492+
if( code == null )
493+
return;
492494
for( var stmt : code.getStatements() ) {
493495
if( visitPublishStatement(stmt) )
494496
hasPublishStatements = true;

tests/checks/output-dsl.nf/.checks

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ $NXF_RUN --save_bam_bai | tee stdout
2121
[[ -L results/quant/beta ]] || false
2222
[[ -L results/quant/delta ]] || false
2323
[[ -f results/samples.csv ]] || false
24+
[[ -f results/summary.txt ]] || false
2425

2526

2627
#
@@ -46,6 +47,7 @@ $NXF_RUN --save_bam_bai | tee stdout
4647
[[ -L results/quant/beta ]] || false
4748
[[ -L results/quant/delta ]] || false
4849
[[ -f results/samples.csv ]] || false
50+
[[ -f results/summary.txt ]] || false
4951

5052

5153
#
@@ -73,3 +75,4 @@ $NXF_RUN --save_bam_bai -resume | tee stdout
7375
[[ -L results/quant/beta ]] || false
7476
[[ -L results/quant/delta ]] || false
7577
[[ -f results/samples.csv ]] || false
78+
[[ -f results/summary.txt ]] || false

tests/output-dsl.nf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,19 @@ process quant {
6262
'''
6363
}
6464

65+
process summary {
66+
input:
67+
path logs
68+
69+
output:
70+
path('summary.txt'), emit: report
71+
72+
script:
73+
'''
74+
ls -1 *.log > summary.txt
75+
'''
76+
}
77+
6578
workflow {
6679
main:
6780
ids = Channel.of('alpha', 'beta', 'delta')
@@ -83,8 +96,15 @@ workflow {
8396
]
8497
}
8598

99+
ch_logs = ch_samples
100+
.map { sample -> sample.fastqc }
101+
.collect()
102+
103+
summary(ch_logs)
104+
86105
publish:
87106
samples = ch_samples
107+
summary = summary.out
88108
}
89109

90110
output {
@@ -101,4 +121,8 @@ output {
101121
sep ','
102122
}
103123
}
124+
125+
summary {
126+
path '.'
127+
}
104128
}

0 commit comments

Comments
 (0)