Fix module binaries on nextflow module run via session flag (#7087)#7089
Open
pditommaso wants to merge 1 commit intomasterfrom
Open
Fix module binaries on nextflow module run via session flag (#7087)#7089pditommaso wants to merge 1 commit intomasterfrom
nextflow module run via session flag (#7087)#7089pditommaso wants to merge 1 commit intomasterfrom
Conversation
When a module is launched directly via `nextflow module run`, the module main.nf is loaded as the entry script, so `ScriptMeta.isModule()` is false and `TaskProcessor.getModuleBundle()` was returning null, so the `resources/usr/bin` directory was not added to the task PATH. Track the "running as a module" state on the Session: `CmdRun` exposes a `isModuleRun()` hook (default false) which `CmdModuleRun` overrides to true, and `Session.moduleRun` is set from there. The bundle is now resolved when the owner script is either an included module (`meta.isModule()`) or the entry script of a `nextflow module run` invocation (`session.isModuleRun()`). The feature remains opt-in via `nextflow.enable.moduleBinaries`. A null `scriptPath` guard is added to keep `getModuleBundle()` robust against scripts that have not had their path registered. Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
✅ Deploy Preview for nextflow-docs-staging ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
nextflow module run via session flag (#7087)nextflow module run via session flag (#7087)
Member
Author
|
Likely this is cleaner option vs #7088 |
jorgee
approved these changes
May 5, 2026
|
|
||
| Session setModuleRun(boolean value) { | ||
| this.moduleRun = value | ||
| return this |
Contributor
There was a problem hiding this comment.
Nit, there is an inconsistency with setters, setBinding and this one are using fluent but others like setBaseDir and setLibDir return void. Looking at the calls looks like it is not needed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #7087 — alternative to #7088.
When a module is launched directly via
nextflow module run <scope>/<name>, the module'smain.nfis loaded as the entry script, not as an included module. As a resultScriptMeta.isModule()returnsfalsefor the script that owns the process, andTaskProcessor.getModuleBundle()returnednull, so theresources/usr/bindirectory was never injected into the taskPATH-- even withnextflow.enable.moduleBinaries = true.Approach
Track the "running as a module" state explicitly on the
Session(run-scoped, not global), instead of widening the bundle gate:CmdRunexposes aprotected boolean isModuleRun()hook (defaultfalse).CmdModuleRunoverrides it to returntrue.CmdRun.run()propagates the value to the runner's session:runner.session.setModuleRun(isModuleRun()).TaskProcessor.getModuleBundle()now resolves the bundle when the owner script is either an included module (meta.isModule()) or the entry script of a module-run invocation (session.isModuleRun()).The feature remains opt-in via
nextflow.enable.moduleBinaries.How this differs from #7088
Session,CmdRun,CmdModuleRun,TaskProcessor, testnextflow run pipeline.nfwith a siblingresources/moduleBinaries=truenextflow module runSession.moduleRun+CmdRun.isModuleRun()hookThis variation is more conservative: it fixes the reported issue without changing what counts as a module-bundle source for any existing invocation other than
nextflow module run. The trade-off is more plumbing (one new flag threaded from CLI to Session).Possible side-effects and implications
TaskProcessor.getBinDirs()still gates the call onsession.enableModuleBinaries(), so default behavior is unchanged.nextflow run(with or withoutinclude).session.isModuleRun()isfalsefor every CLI subcommand other thannextflow module run, so the gate behaves exactly as before for those invocations.resources/directory.ResourcesBundle.scan()returns an empty bundle when the directory does not exist, sogetBinDirs()produces an empty list.meta?.scriptPath == nullearly-return preserves robustness —ScriptMeta.getModuleBundle()would otherwise throwIllegalStateExceptionifscriptPathwere not yet set.SessiongainsisModuleRun()/setModuleRun(boolean)andCmdRungains aprotected boolean isModuleRun()hook. These are minor additions but worth noting for downstream code that subclassesCmdRun.Test plan
./gradlew :nextflow:test --tests "nextflow.processor.TaskProcessorTest"— new parameterized testshould resolve module bundle for entry script when running as module …covers all three combinations:isModule=true,isModuleRun=false) → bundle resolvedisModule=false,isModuleRun=true) → bundle resolved (the fix)isModule=false,isModuleRun=false) → bundle NOT resolved (unchanged)./gradlew :nextflow:test --tests "nextflow.SessionTest" --tests "nextflow.cli.CmdRunTest"passes.nextflow -c test.config module run cellgeni/failexample --greeting 'Hello world!') succeeds with this change applied — recommended manual verification before merge.