Skip to content

Commit 064f57f

Browse files
authored
Fix error with dynamic directives with named arguments (#6550)
--------- Signed-off-by: Ben Sherman <[email protected]>
1 parent 1c543c0 commit 064f57f

File tree

2 files changed

+45
-10
lines changed

2 files changed

+45
-10
lines changed

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,41 +126,43 @@ class ProcessBuilder {
126126

127127
/// DIRECTIVES
128128

129-
void accelerator( Map params, value ) {
129+
void accelerator( Map params, value ) {
130130
if( value instanceof Number ) {
131131
if( params.limit==null )
132132
params.limit=value
133133
else if( params.request==null )
134134
params.request=value
135135
}
136-
else if( value != null )
136+
else if( value != null ) {
137137
throw new IllegalArgumentException("Not a valid `accelerator` directive value: $value [${value.getClass().getName()}]")
138+
}
138139
accelerator(params)
139140
}
140141

141142
void accelerator( value ) {
142143
if( value instanceof Number )
143144
config.put('accelerator', [limit: value])
144-
else if( value instanceof Map )
145+
else if( value instanceof Map || value instanceof Closure )
145146
config.put('accelerator', value)
146147
else if( value != null )
147148
throw new IllegalArgumentException("Not a valid `accelerator` directive value: $value [${value.getClass().getName()}]")
148149
}
149150

150-
void arch( Map params, value ) {
151+
void arch( Map params, value ) {
151152
if( value instanceof String ) {
152153
if( params.name==null )
153154
params.name=value
154155
}
155-
else if( value != null )
156+
else if( value != null ) {
156157
throw new IllegalArgumentException("Not a valid `arch` directive value: $value [${value.getClass().getName()}]")
158+
}
157159
arch(params)
158160
}
159161

160162
void arch( value ) {
161163
if( value instanceof String )
162164
config.put('arch', [name: value])
163-
else if( value instanceof Map )
165+
else if( value instanceof Map || value instanceof Closure )
164166
config.put('arch', value)
165167
else if( value != null )
166168
throw new IllegalArgumentException("Not a valid `arch` directive value: $value [${value.getClass().getName()}]")
@@ -178,7 +180,7 @@ class ProcessBuilder {
178180
* @param opts
179181
* @param value
180182
*/
181-
void disk( Map opts, value ) {
183+
void disk( Map opts, value ) {
182184
opts.request = value
183185
disk(opts)
184186
}
@@ -327,10 +329,10 @@ class ProcessBuilder {
327329
*
328330
* publishDir '/some/dir', mode: 'copy'
329331
*
330-
* @param params
331-
* @param path
332+
* @param params map of publish options
333+
* @param path String | Closure<String>
332334
*/
333-
void publishDir(Map params, CharSequence path) {
335+
void publishDir(Map params, path) {
334336
params.put('path', path)
335337
publishDir( params )
336338
}

tests/dynamic-publishdir.nf

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env nextflow
2+
/*
3+
* Copyright 2013-2025, Seqera Labs
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
params.prefix = 'my'
19+
20+
process TEST {
21+
publishDir { "${prefix}/reads" }, mode: 'link'
22+
23+
input:
24+
val(prefix)
25+
26+
script:
27+
"""
28+
"""
29+
}
30+
31+
workflow {
32+
TEST(params.prefix)
33+
}

0 commit comments

Comments
 (0)