-
Notifications
You must be signed in to change notification settings - Fork 624
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
Params case translation between camelCase and kebab-case doesn't always work as expected #4033
Comments
After further investigation, this appears to have more to do with whether the params are initialized like this (where things don't seem to work the right way): params {
thing1 = false
thing2 = "another thing"
} or this (where they work as expected): params.thing1 = false
params.thing2 = "another thing" |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I ran into this issue as well. The intended behavior should be for
and
to both create a (Per https://www.nextflow.io/docs/latest/cli.html#pipeline-parameters). |
@pditommaso @marcodelapierre would you be willing mark this issue as a bug? This issue might cause unexpected reproducibility issues. Thanks! |
@bentsherman on the top of your head, may any of your recent fixes have addressed this behaviour? |
Possibly. That fix was released in 23.11.0-edge, so someone should test the example with that version or newer |
I just tested it in 23.12.0-edge, and the problem was still there. |
This is happening because of the read-only nature of the params map. When a new param is added to the map, if the param key is already present (whether in kebab-case or camelCase), the new param is not added. In your case, the params are added in the following order:
The first two params from the config are added and aliased. Then the CLI params are ignored because they are already defined. This is because the CLI params and config params are collected before the kebab/camel aliasing is applied. @pditommaso I recall you were thinking we should just remove the params aliasing altogether. But I think, if we just separate the read-only behavior from the aliasing, so that we can build the params map internally and then make it read-only, that should solve all of these quirks once and for all. |
What was the original rationale on the params aliasing? From what I know so far, I would consider removing the aliasing, as it is a source of confusion and subtle errors. This would need to be communicated clearly in the new NF version, as there may be people relying on that. |
Well, the kebab-case aliasing is nice to have for CLI params, and it's actually pretty simple to implement in isolation, see the linked PR. The complexity comes from the current ParamsMap which tries to implement both aliasing and some read-only behavior, that makes the code very hard to understand and prone to bugs. I would propose that we actually move the aliasing part to the CLI code, so that it is applied only when merging CLI params with the other params. That's the only place where it's needed as you can't use kebab-case in a config file or script, and it should also make the params map much easier to reason about. If we remove anything it should be the definition of params in scripts, I think that is what adds a lot of complexity and it isn't even used very much. That is a separate effort, but certainly would be easier to think through if the aliasing is moved elsewhere. |
…solve #4033) Signed-off-by: Ben Sherman <[email protected]> Co-authored-by: Paolo Di Tommaso <[email protected]>
Bug report
Expected behavior and actual behavior
Parameters are sometimes incorrectly translated between camelCase and kebab-case. Particularly, when default values of
params
are defined in nextflow.config, the translation to kebab-case doesn't work as expected, but when they are defined in the main script, they seem to work fine.Steps to reproduce the problem
Here's a simple script:
If we run it without any arguments, we can see the default values, with all parameters successfully translated into kebab-case:
If we run it with options in camelCase or kebab-case, everything seems to work fine:
However, when the default values of the parameters are specified in
nextflow.config
, it behaves differently. In this example, we have the same script minus the definition of the params:In addition, we have a
nextflow.config
file where the default parameter values are defined:When we run it with no options, we see the default values:
If we run it with camelCase options, it behaves as expected:
However, when we run it with kebab-case options, the values don't get picked up:
There seems to be a disconnect somewhere in the logic that handles the command-line option case translation. If params are defined in the main script it works fine, but if they're defined in the config file, it doesn't.
Environment
Additional context
nextflow.log here:
nextflow.log
Also, as an aside, the
--option=value
mode of parameter passing doesn't seem to be supported. This is may be as designed, but it's something I noticed while testing this:The text was updated successfully, but these errors were encountered: