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

[Bug]: gempyor.shared_cli.parse_config_files Raises ValueError When Provided $CONFIG_PATH As Argument #389

Open
TimothyWillard opened this issue Nov 7, 2024 · 1 comment
Labels
bug Defects or errors in the code. config Relating to configuration files or their framework. gempyor Concerns the Python core. medium priority Medium priority.

Comments

@TimothyWillard
Copy link
Contributor

TimothyWillard commented Nov 7, 2024

Label

bug, config, gempyor

Priority Label

medium priority

Describe the bug/issue

If the $CONFIG_PATH environment variable is set this is treated as a config file being passed via the -c option and causes and error if the $CONFIG_PATH is provided as an argument. Not exactly sure what the correct treatment is here, I don't think we just want to take the union of the two generically, but maybe carve out this special case where only one config file is provided and it's the same? Could also check the $CONFIG_PATH env variable and if present in the arguments then remove from the options prior to this ValueError? I think the later is more robust.

To Reproduce

A bit contrived:

(flepimop-env) [twillard@longleaf-login4 flepimop_sample]$ echo $CONFIG_PATH
/work/users/t/w/twillard/flepimop_sample/config_sample_2pop_inference.yml
(flepimop-env) [twillard@longleaf-login4 flepimop_sample]$ flepimop patch $CONFIG_PATH
Traceback (most recent call last):
  File "/nas/longleaf/home/twillard/.conda/envs/flepimop-env/bin/flepimop", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/nas/longleaf/home/twillard/.conda/envs/flepimop-env/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nas/longleaf/home/twillard/.conda/envs/flepimop-env/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/nas/longleaf/home/twillard/.conda/envs/flepimop-env/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nas/longleaf/home/twillard/.conda/envs/flepimop-env/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nas/longleaf/home/twillard/.conda/envs/flepimop-env/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nas/longleaf/home/twillard/.conda/envs/flepimop-env/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/work/users/t/w/twillard/flepiMoP/flepimop/gempyor_pkg/src/gempyor/cli.py", line 27, in patch
    parse_config_files(config, ctx, **kwargs)
  File "/work/users/t/w/twillard/flepiMoP/flepimop/gempyor_pkg/src/gempyor/shared_cli.py", line 303, in parse_config_files
    raise ValueError(
ValueError: Exactly one config file source option must be provided; got {'config_files': (PosixPath('/work/users/t/w/twillard/flepimop_sample/config_sample_2pop_inference.yml'),), 'config_filepath': (PosixPath('/work/users/t/w/twillard/flepimop_sample/config_sample_2pop_inference.yml'),)}.

Although the same issue will appear when using gempyor.shared_cli.parse_config_files in other CLIs.

Environment, if relevant

dev branch, Python 3.11.10, R version 4.3.3

@TimothyWillard TimothyWillard added bug Defects or errors in the code. gempyor Concerns the Python core. config Relating to configuration files or their framework. medium priority Medium priority. labels Nov 7, 2024
@pearsonca
Copy link
Contributor

Hmm - I think there's a source check for options, and we can sniff for that and then issue a warning + ignore the environment variable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Defects or errors in the code. config Relating to configuration files or their framework. gempyor Concerns the Python core. medium priority Medium priority.
Projects
None yet
Development

No branches or pull requests

2 participants