From a0a6b4315e5d26b752981510827e4d642db8e7f8 Mon Sep 17 00:00:00 2001 From: Ben Sherman Date: Tue, 18 Mar 2025 09:34:49 -0500 Subject: [PATCH 1/3] Fix false "process already defined" error Signed-off-by: Ben Sherman --- .../groovy/nextflow/script/IncludeDef.groovy | 38 ++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/modules/nextflow/src/main/groovy/nextflow/script/IncludeDef.groovy b/modules/nextflow/src/main/groovy/nextflow/script/IncludeDef.groovy index ffa32d8be9..4f04d67161 100644 --- a/modules/nextflow/src/main/groovy/nextflow/script/IncludeDef.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/script/IncludeDef.groovy @@ -111,7 +111,9 @@ class IncludeDef { // -- resolve the concrete against the current script final moduleFile = realModulePath(path).normalize() // -- load the module - final moduleScript = loadModule0(moduleFile, resolveParams(ownerParams), session) + final moduleScript = NF.getSyntaxParserVersion() == 'v2' + ? loadModuleV2(moduleFile, ownerParams, session) + : loadModuleV1(moduleFile, resolveParams(ownerParams), session) // -- add it to the inclusions for( Module module : modules ) { meta.addModule(moduleScript, module.name, module.alias) @@ -133,19 +135,37 @@ class IncludeDef { @PackageScope Path getOwnerPath() { getMeta().getScriptPath() } + /** + * When using the strict syntax, the included script will already + * have been compiled, so simply execute it to load its definitions. + * + * @param path + * @param params + * @param session + */ @PackageScope @Memoized - static BaseScript loadModule0(Path path, Map params, Session session) { + static BaseScript loadModuleV2(Path path, Map params, Session session) { final script = ScriptMeta.getScriptByPath(path) - if( script ) { - script.getBinding().setParams(params) - script.run() - return script - } + if( !script ) + throw new IllegalStateException() + script.getBinding().setParams(params) + script.run() + return script + } + /** + * When not using the strict syntax, compile and execute the + * included script to load its definitions. + * + * @param path + * @param params + * @param session + */ + @PackageScope + @Memoized + static BaseScript loadModuleV1(Path path, Map params, Session session) { final binding = new ScriptBinding() .setParams(params) - - // the execution of a library file has as side effect the registration of declared processes new ScriptLoaderV1(session) .setModule(true) .setBinding(binding) From 6ba2ebdd55e79a92760f31d04d4377f625e40c28 Mon Sep 17 00:00:00 2001 From: Ben Sherman Date: Tue, 18 Mar 2025 10:58:30 -0500 Subject: [PATCH 2/3] Update IncludeDef.groovy Signed-off-by: Ben Sherman --- .../main/groovy/nextflow/script/IncludeDef.groovy | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/nextflow/src/main/groovy/nextflow/script/IncludeDef.groovy b/modules/nextflow/src/main/groovy/nextflow/script/IncludeDef.groovy index 4f04d67161..99ace95c65 100644 --- a/modules/nextflow/src/main/groovy/nextflow/script/IncludeDef.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/script/IncludeDef.groovy @@ -139,9 +139,9 @@ class IncludeDef { * When using the strict syntax, the included script will already * have been compiled, so simply execute it to load its definitions. * - * @param path - * @param params - * @param session + * @param path The included script path + * @param params The params of the including script + * @param session The current workflow run */ @PackageScope @Memoized @@ -158,9 +158,9 @@ class IncludeDef { * When not using the strict syntax, compile and execute the * included script to load its definitions. * - * @param path - * @param params - * @param session + * @param path The included script path + * @param params The params of the including script + * @param session The current workflow run */ @PackageScope @Memoized From afce2a843f0321200a31a7cb2eda8c0f01f00371 Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Tue, 18 Mar 2025 17:47:15 +0100 Subject: [PATCH 3/3] Force test [e2e prod] Signed-off-by: Paolo Di Tommaso