Skip to content

Commit a7804a0

Browse files
committed
Fix stageAs method signature in typed process
Signed-off-by: Ben Sherman <bentshermann@gmail.com>
1 parent d54ff29 commit a7804a0

11 files changed

Lines changed: 28 additions & 21 deletions

File tree

adr/20260306-record-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ process PROKKA {
357357
358358
output:
359359
record(
360-
id: sample.meta.id,
360+
meta: sample.meta,
361361
gff: file("${prefix}/*.gff"),
362362
gbk: file("${prefix}/*.gbk"),
363363
fna: file("${prefix}/*.fna"),

docs/process-typed.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ process cat_opt {
7575
input: Path?
7676
7777
stage:
78-
stageAs 'input.txt', input
78+
stageAs input, 'input.txt'
7979
8080
output:
8181
stdout()
@@ -202,6 +202,10 @@ process cat {
202202

203203
### Custom file staging
204204

205+
:::{versionchanged} 26.04.0
206+
The method signature for `stageAs` was changed from `(filePattern, value)` to `(value, filePattern)`.
207+
:::
208+
205209
The `stageAs` directive stages an input file (or files) under a custom file pattern:
206210

207211
```nextflow
@@ -210,7 +214,7 @@ process blast {
210214
fasta: Path
211215
212216
stage:
213-
stageAs 'query.fa', fasta
217+
stageAs fasta, 'query.fa'
214218
215219
script:
216220
"""
@@ -228,7 +232,7 @@ process grep {
228232
fasta: Path
229233
230234
stage:
231-
stageAs "${id}.fa", fasta
235+
stageAs fasta, "${id}.fa"
232236
233237
script:
234238
"""
@@ -316,7 +320,10 @@ process fastqc {
316320
}
317321
318322
output:
319-
record(id: sample.id, fastqc: file('fastqc_logs'))
323+
record(
324+
id: sample.id,
325+
fastqc: file('fastqc_logs')
326+
)
320327
321328
script:
322329
// ...

docs/reference/process.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ The following directives can be used in the `stage:` section of a typed process:
7373
`env( name: String, String value )`
7474
: Declares an environment variable with the specified name and value in the task environment.
7575

76-
`stageAs( filePattern: String, value: Path )`
76+
`stageAs( value: Path, filePattern: String )`
7777
: Stages a file into the task directory under the given alias.
7878

79-
`stageAs( filePattern: String, value: Iterable<Path> )`
79+
`stageAs( value: Iterable<Path>, filePattern: String )`
8080
: Stages a collection of files into the task directory under the given alias.
8181

8282
`stdin( value: String )`

docs/workflow.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ Outputs can be conditionally published using pipeline parameters:
266266
output {
267267
samples {
268268
path { sample ->
269-
sample.fastqc >> "fastqc"
270-
sample.bam >> params.save_bams ? "align" : null
269+
sample.fastqc >> "fastqc/"
270+
sample.bam >> (params.save_bams ? "align/" : null)
271271
}
272272
}
273273
}

modules/nextflow/src/main/groovy/nextflow/script/dsl/ProcessDslV2.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ class ProcessDslV2 extends ProcessBuilder {
100100
* Declare a file or collection of files to be staged into
101101
* the task directory under the given file pattern.
102102
*
103-
* @param filePattern [String | Closure]
104103
* @param value [Path | Collection<Path> | Closure]
104+
* @param filePattern [String | Closure]
105105
*/
106-
void stageAs(Object filePattern, Object value) {
106+
void stageAs(Object value, Object filePattern) {
107107
inputs.addFile(new ProcessFileInput(filePattern, value))
108108
}
109109

modules/nextflow/src/test/groovy/nextflow/script/dsl/ProcessDslV2Test.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ProcessDslV2Test extends Specification {
4040
dsl._input_('infile', Path, false)
4141
dsl._input_('x', String, false)
4242
dsl._input_('y', String, false)
43-
dsl.stageAs('filename.fa', { infile })
43+
dsl.stageAs({ infile }, 'filename.fa')
4444
dsl.stdin { y }
4545

4646
then:
@@ -112,7 +112,7 @@ class ProcessDslV2Test extends Specification {
112112
dsl.memory '10 GB'
113113
dsl._input_('foo', String, false)
114114
dsl._input_('sample', Path, false)
115-
dsl.stageAs('sample.txt', { sample })
115+
dsl.stageAs({ sample }, 'sample.txt')
116116
dsl._output_('result', Path, { file('$file0') })
117117
dsl._unstage_files('$file0', 'result.txt')
118118

modules/nf-lang/src/main/java/nextflow/script/dsl/ProcessDsl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,12 +381,12 @@ interface StageDsl extends DslScope {
381381
@Description("""
382382
Stage a file into the task directory under the given alias.
383383
""")
384-
void stageAs(String filePattern, Path value);
384+
void stageAs(Path value, String filePattern);
385385

386386
@Description("""
387387
Stage a collection of files into the task directory under the given alias.
388388
""")
389-
void stageAs(String filePattern, Iterable<Path> value);
389+
void stageAs(Iterable<Path> value, String filePattern);
390390

391391
@Description("""
392392
Stage the given value as the standard input (i.e. `stdin`) to the task script.

modules/nf-lang/src/test/groovy/nextflow/script/formatter/ScriptFormatterTest.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class ScriptFormatterTest extends Specification {
207207
nextflow.preview.types=true
208208
209209
process hello{
210-
debug(true) ; input: (id,infile):Tuple<String,Path> ; index:Path ; stage: stageAs('input.txt',infile) ; output: result=tuple(id,file('output.txt')) ; script: 'cat input.txt > output.txt'
210+
debug(true) ; input: (id,infile):Tuple<String,Path> ; index:Path ; stage: stageAs(infile,'input.txt') ; output: result=tuple(id,file('output.txt')) ; script: 'cat input.txt > output.txt'
211211
}
212212
''',
213213
'''\
@@ -221,7 +221,7 @@ class ScriptFormatterTest extends Specification {
221221
index: Path
222222
223223
stage:
224-
stageAs 'input.txt', infile
224+
stageAs infile, 'input.txt'
225225
226226
output:
227227
result = tuple(id, file('output.txt'))

tests/collect-tuple-typed.nf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ process merge {
3232
(barcode, seq_ids, bam, bai): Tuple<String, Bag<String>, Bag<Path>, Bag<Path>>
3333

3434
stage:
35-
stageAs 'bam?', bam
36-
stageAs 'bai?', bai
35+
stageAs bam, 'bam?'
36+
stageAs bai, 'bai?'
3737

3838
script:
3939
"""

tests/dynamic-filename-typed.nf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ process foo {
2727
(name, txt): Tuple<String, Path>
2828

2929
stage:
30-
stageAs "${params.prefix}_${name}.txt", txt
30+
stageAs txt, "${params.prefix}_${name}.txt"
3131

3232
output:
3333
file("${params.prefix}_${name}.txt")

0 commit comments

Comments
 (0)