Skip to content

Print warning for unused CLI parameters #4567

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

Open
marcodelapierre opened this issue Dec 10, 2023 · 2 comments · May be fixed by #5929
Open

Print warning for unused CLI parameters #4567

marcodelapierre opened this issue Dec 10, 2023 · 2 comments · May be fixed by #5929

Comments

@marcodelapierre
Copy link
Contributor

In general, I think it is useful to warn users about unused parameters, because they might actually be the result of undesired typos, for instance --resume instead of -resume. In this case, the warning would help them fix the CLI syntax.

Let me talk about both the traditional CLI and CLI v2 (#3600).

I see two main sub-cases so far:

  • any non-dash-prefixed argument should give a warning (for CLI v2, also single-dash-prefixed - these would be first checked about -x styled runtime parameters)
  • double-dash-prefixed arguments should be compared with a dictionary of params of the pipeline being run; if no match, they should give a warning (for CLI v2, there will be the additional early check around them being runtime parameters)
@aiqc
Copy link

aiqc commented Nov 19, 2024

Shouldn't it be a hard error? A warning would still allow for kicking off an expensive, time-consuming, and resource-heavy workflow that is being run with incorrect parameters.

For example, I changed params.str in the tutorial to params.greeting to avoid reserved words. However, I forgot to change my command from --str to --greeting.


Screenshot from 2024-11-19 16-08-05

That's not the result that I wanted. Parameter validation would have prevented this.


EDIT: It seems like part of the problem is that params can be used throughout the .nf script without first being registered. For example, I don't actually have to define a default value as params.greeting = 'Hello world!' because I can just reference the param directly:

"""
printf '${params.greeting}' | split -b 6 - chunk_
"""

That is to say, parameter validation requires parameter registration.

If this strict-mode functionality were to be introduced, it might have to be enabled in the config in order to avoid breaking changes.

Ideally, it would validate basic types (e.g. str, int, list of str), and maybe predefined values (e.g. params.env:str=['cpu','gpu'] or params.ram:int=range(4:16))

Copy link

stale bot commented Apr 26, 2025

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.

@stale stale bot added the stale label Apr 26, 2025
@bentsherman bentsherman linked a pull request Apr 28, 2025 that will close this issue
1 task
@stale stale bot removed the stale label Apr 28, 2025
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

Successfully merging a pull request may close this issue.

3 participants