question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[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:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:26 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
jungerm2commented, Feb 24, 2020

Thank you that makes sense. In the case where we have multiple (2+) mutually exclusive args, multiple entry points is probably better design anyways…

1reaction
omrycommented, Feb 23, 2020

@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:

@hydra.main(config_path="train.yaml")
def train(cfg):
  ..

test.py:

@hydra.main(config_path="test.yaml")
def test(cfg):
  ..

If you actually do want to share most of the config, you create a mode parameter in your config:

config.yaml:

defaults:
  - model: foo
  - dataset: bar

mode: train 

then the code can behave differently based on the mode.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found