[Feature Request] Permit user-defined arguments if needed
See original GitHub issue🚀 Feature Request
Motivation
Is your feature request related to a problem? Please describe.
Because hydra
defines argparse.ArgumentParser
internally, user cannot add own new parser.
Pitch
Describe the solution you’d like
I added a new param(user_arg_parser
) to the hydra.main
decorator. Then my_app
function can receive the additional args
param passed through Hydra.
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument("--user_arg", type=str, help="This is user's argument")
@hydra.main(config_path="config/config.yaml", user_arg_parser=parser)
def my_app(cfg, args):
print(cfg.pretty())
Describe alternatives you’ve considered
Are you willing to open a pull request? (See CONTRIBUTING) Yes.
Additional context
Add any other context or screenshots about the feature request here. You can also record a video
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:26 (15 by maintainers)
Top Results From Across the Web
User-defined functions - Azure Data Explorer - Microsoft Learn
User -defined functions are invoked through a name, are provided with zero or more input arguments (which can be scalar or tabular), and...
Read more >Allow @resolver directive in user-defined types' fields
Issue description. Right now, the @resolver directive is only allowed in the queries and mutations fields. It would be handy to use it...
Read more >argparse — Parser for command-line options, arguments and ...
The argparse module makes it easy to write user-friendly command-line interfaces. The program defines what arguments it requires, and argparse will figure ...
Read more >HTTP/1.1: Header Field Definitions
The first "q" parameter (if any) separates the media-range parameter(s) from the accept-params. Quality factors allow the user or user agent to indicate...
Read more >Set up a method request in API Gateway - AWS Documentation
API Gateway defines a proxy resource as a placeholder for a resource to be specified ... required request parameters to make them available...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you that makes sense. In the case where we have multiple (2+) mutually exclusive args, multiple entry points is probably better design anyways…
@jungerm2: There is a different issue for allowing a different config file: #386 . As for tow different run modes: If those are really mutually exclusive, the work around for now is to have two different entry point. train.py:
test.py:
If you actually do want to share most of the config, you create a mode parameter in your config:
config.yaml:
then the code can behave differently based on the mode.