-
-
Notifications
You must be signed in to change notification settings - Fork 651
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] unable to use hydra with click module #409
Comments
Hydra is meant to completely replace argparse or click. Instead of using a Click module here, just put foo: foo in your config.yaml file: config.yaml foo: foo app.py @hydra.main(config_path='config.yml')
def my_app(cfg):
print(f"foo={cfg.foo}) # here is foo
if __name__ == '__main__':
main() $ python app.py foo=bar $ python app.py foo=foo Closing as invalid, but happy to discuss further if needed. |
Does Hydra offer anything analogous to Click's I'm used to doing: @click.group()
def main():
pass
@main.command()
def sub_command_1():
# Sub-functionality
@main.command()
def sub_command_2():
# Sub-functionality in Click and was hoping to do something similar with Hydra. The workaround I'm using for now involves setting a |
Generally speaking, Hydra not calling code for you. See this for example of driving runtime behavior from config: Hydra 1.0 will also cleanly support regular methods: |
For anyone late to the party (like me), there is a supported way to decouple the CLI and thus use Reference:
|
The Compose API is certainly an option if you just need the config composition capabilities from Hydra. |
Do we have this functionality in hydra to execute functions individually from command line (similar to |
Not exactly. |
🐛 Bug
I tried to use hydra with click module for creating CLI tools, but got an error.
To reproduce
** Stack trace/error message **
Expected Behavior
System information
Additional context
This error might be due to the arguement
3
of this line:hydra/hydra/_internal/utils.py
Line 142 in 2a99161
If I change this argument to
-1
, then it works well.The text was updated successfully, but these errors were encountered: