Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

ability to omit the initialization of cli arguments to defaults during inherited initialization #906

Closed
ovatman opened this issue Feb 22, 2024 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@ovatman
Copy link
Contributor

ovatman commented Feb 22, 2024

When working on tomlization of kontrol arguments we needed to remove the default initialization of argument variables. This is required because we would like to override the argument values coming from an input toml with the values from cli which. Default value initialization causes the non specified values from the cli to override specified values from the toml.

However, there are some arguments which are inherited from pyk to which we can not disable the default value initialization from kontrol. It is required to disable such an initialization optionally or when inherited.

@ovatman ovatman added the enhancement New feature or request label Feb 22, 2024
@ovatman ovatman self-assigned this Feb 22, 2024
@tothtamas28
Copy link
Collaborator

tothtamas28 commented Feb 22, 2024

Right now cli provides complete ArgumentParser instances, e.g.:

class KCLIArgs:

with arguments like:

args.add_argument('--verbose', '-v', default=False, action='store_true', help='Verbose output.')

One solution for the issue would be to model the command line arguments, and let the user assemble the parser themself.

A bare bones example to illustrate the idea:

cli_arg = (
    ('--verbose', '-v'),
    {
        'default': False,
        'action': 'store_true',
        'help': 'Verbose output.',
    },
)
...
args, kwargs = cli_arg
parser.add_argument(*args, **kwargs)

This should of course be properly modeled with classes that represent the arguments (or groups of them) and expose methods that enable constructing / enriching argument parsers. Then users had the option to exclude an argument, or modify some of their parts (the default in this case).

This would also make it easier to migrate to another argument parser library.

@ehildenb
Copy link
Member

See #885

@yale-vinson
Copy link

@ovatman What is blocking this one? I want to reference it here so that we know when we can come back to work on this one.

@ovatman ovatman closed this as completed Mar 21, 2024
@ovatman
Copy link
Contributor Author

ovatman commented Mar 21, 2024

This PR resolved this issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants