File tree Expand file tree Collapse file tree
nextflow/src/test/groovy/nextflow/script/parser/v2
nf-lang/src/main/java/nextflow/script/control Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1249,6 +1249,7 @@ All directives can be assigned a dynamic value except the following:
12491249- {ref}` process-executor `
12501250- {ref}` process-label `
12511251- {ref}` process-maxforks `
1252+ - {ref}` process-secret `
12521253
12531254:::{versionadded} 25.10
12541255:::
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import java.nio.file.Files
2020
2121import nextflow.Session
2222import nextflow.exception.ScriptCompilationException
23+ import nextflow.processor.TaskProcessor
2324import nextflow.script.BaseScript
2425import nextflow.script.ScriptMeta
2526import nextflow.script.WorkflowDef
@@ -221,7 +222,7 @@ class ScriptLoaderV2Test extends Dsl2Spec {
221222 session. executorFactory = new MockExecutorFactory ()
222223 def parser = new ScriptLoaderV2 (session)
223224
224- def TEXT = '''
225+ def TEXT = ''' \
225226 process HELLO {
226227 tag props.name
227228
@@ -248,6 +249,37 @@ class ScriptLoaderV2Test extends Dsl2Spec {
248249 noExceptionThrown()
249250 }
250251
252+ def ' should not wrap process directives that cannot be dynamic' () {
253+
254+ given :
255+ def session = new Session ()
256+ session. executorFactory = new MockExecutorFactory ()
257+ def parser = new ScriptLoaderV2 (session)
258+
259+ def TEXT = ''' \
260+ process ECHO {
261+ secret secrets.NCBI_API_KEY ? "NCBI_API_KEY" : ""
262+
263+ script:
264+ """
265+ echo "NCBI_API_KEY=\\ $NCBI_API_KEY"
266+ """
267+ }
268+
269+ workflow {
270+ ECHO()
271+ }
272+ '''
273+
274+ when :
275+ parser. parse(TEXT )
276+ parser. runScript()
277+ and :
278+ TaskProcessor . currentProcessor(). createTaskPreview(). toTaskBean()
279+ then :
280+ noExceptionThrown()
281+ }
282+
251283 def ' should strip unsupported type annotations' () {
252284
253285 given :
Original file line number Diff line number Diff line change @@ -76,11 +76,27 @@ public Statement transform(ProcessNodeV1 node) {
7676 return stmt (callThisX ("process" , args (constX (node .getName ()), closure )));
7777 }
7878
79+ private static final List <String > NON_DYNAMIC_DIRECTIVES = List .of (
80+ "executor" ,
81+ "label" ,
82+ "maxForks" ,
83+ "module" ,
84+ "pod" ,
85+ "publishDir" ,
86+ "secret"
87+ );
88+
7989 private void visitProcessDirectives (Statement directives ) {
8090 asDirectives (directives ).forEach ((call ) -> {
91+ var name = call .getMethodAsString ();
92+ // don't wrap directives that can't be dynamic
93+ if ( NON_DYNAMIC_DIRECTIVES .contains (name ) )
94+ return ;
95+ // don't wrap directives with multiple arguments
8196 var arguments = asMethodCallArguments (call );
8297 if ( arguments .size () != 1 )
8398 return ;
99+ // don't wrap directives that already have a closure
84100 var firstArg = arguments .get (0 );
85101 if ( firstArg instanceof ClosureExpression )
86102 return ;
You can’t perform that action at this time.
0 commit comments