Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sub-workflow is not inheriting replaced param values #4982

Open
nh13 opened this issue May 9, 2024 · 5 comments
Open

Sub-workflow is not inheriting replaced param values #4982

nh13 opened this issue May 9, 2024 · 5 comments

Comments

@nh13
Copy link

nh13 commented May 9, 2024

Bug report

Expected behavior and actual behavior

When calling .replace on the params object in main.nf, I would expect that any access to the params object in any workflow or sub-workflow would return the updated copy. This is not the case.

Steps to reproduce the problem

.
├── main.nf
├── params.yml
└── sub_main.nf
main.nf
cat main.nf 
include { SUB_MAIN } from './sub_main.nf'

params.replace("foo", "bar-has-been-replaced")

workflow MAIN{
	take:
	numbers
	
	main:
	log.error "MAIN::params: ${params}"
	SUB_MAIN(numbers)
}

workflow {
	main:
	log.error "params: ${params}"
	MAIN(Channel.of(1, 2, 3))
}
params.yml
foo: "bar"
sub_main.nf
workflow SUB_MAIN{
	take:
	numbers

	main:
	log.error "SUB_MAIN::params: ${params}"
	numbers.view()
}

Program output

$ nextflow run -params-file params.yml .
N E X T F L O W  ~  version 23.10.1
Launching `./main.nf` [astonishing_legentil] DSL2 - revision: a32a34c7c7
ERROR ~ params: [foo:bar-has-been-replaced]

 -- Check '.nextflow.log' file for details
ERROR ~ MAIN::params: [foo:bar-has-been-replaced]

 -- Check '.nextflow.log' file for details
ERROR ~ SUB_MAIN::params: [foo:bar]

 -- Check '.nextflow.log' file for details
1
2
3

Notice how SUB_MAIN::params prints out [foo:bar], not the expected [foo:bar-has-been-replaced].

Environment

  • Nextflow version: 23.10.1
  • Java version: openjdk version "17.0.3" 2022-04-19 LTS
  • Operating system: OSX
  • Bash version: zsh 5.9 (x86_64-apple-darwin23.0)
@bentsherman
Copy link
Member

The params map is intended to be immutable, likely this replace will not be supported in the future. The best practice is to only use params in the anonymous workflow and pass params as explicit inputs to subworkflows and processes

@nh13
Copy link
Author

nh13 commented May 10, 2024

I see things like this in nf-core pipelines where params are overwritten (I think).

@bentsherman
Copy link
Member

We are moving away from that pattern. Those params should really just be variables

@nh13
Copy link
Author

nh13 commented May 12, 2024

It would be great to have this be documented somewhere so we don’t have the rug pulled out from us for patterns that are in use today.

@bentsherman
Copy link
Member

We are developing some clearer and stricter guidance on what is allowed in the DSL, since the Groovy compiler allows way more than what is intended for Nextflow. We're still working out some details, but we will definitely provide documentation (and tooling 😄 ) once it's ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants