nextflow-io / nextflow

A DSL for data-driven computational pipelines
http://nextflow.io
Apache License 2.0
2.61k stars 605 forks source link

Configuration file variable interpolation does not respect source order #4983

Open mluypaert opened 1 month ago

mluypaert commented 1 month ago

Bug report

Expected behavior and actual behavior

Expected behaviour:
When using variable interpolation in the nextflow.config file, I expect parameters provided on the command line to override the value of the respective variable in the config file (as per the documented source priority order), and interpolation in other parameters to use this command-line provided value.

Actual behaviour: While the parameter provided on the command-line overrides the value of said parameter definition from the config file, any variable interpolation done in the config file will use the value as found in the config file instead of the cmdline provided value.

Steps to reproduce the problem

Define a nextflow.config file with the following content:

profiles {
    test {
        params {
            propertyOne = 'world'
            anotherProp = "Hello $propertyOne"
        }
    }
}

Write a file called variable-interpolation-test.nf with the following content:

params.propertyOne = ''
params.anotherProp = ''

workflow {
    print "propertyOne: ${params.propertyOne}"
    print "anotherProp: ${params.anotherProp}"
}

Run the variable-interpolation-test.nf script:

nextflow run -profile test variable-interpolation-test.nf --propertyOne There!

and witness that the propertyOne value defined as cmdline argument is not interpolated into anotherProp as it produced below output

Program output

May 09, 2024 3:39:38 PM com.google.auth.oauth2.DefaultCredentialsProvider warnAboutProblematicCredentials
WARNING: Your application has authenticated using end user credentials from Google Cloud SDK. We recommend that most server applications use service accounts instead. If your application continues to use end user credentials from Cloud SDK, you might receive a "quota exceeded" or "API not enabled" error. For more information about service accounts, see https://cloud.google.com/docs/authentication/.
N E X T F L O W  ~  version 23.10.1
Launching `variable-interpolation-test.nf` [curious_mcclintock] DSL2 - revision: d61a249b4e
propertyOne: There!
anotherProp: Hello world

Environment

bentsherman commented 1 month ago

Duplicate of #2662, will be solved by #4744