[Bug] unable to use hydra with click module
See original GitHub issueš Bug
I tried to use hydra with click module for creating CLI tools, but got an error.
To reproduce
import click
import hydra
@click.command()
@click.option('--foo', default='foo')
def main(**kwargs):
my_app()
print('hoge')
print(kwargs)
@hydra.main(config_path='config.yml')
def my_app(cfg):
print(cfg.pretty())
if __name__ == '__main__':
main()
** Stack trace/error message **
hydra.errors.MissingConfigException: Cannot find primary config file: config.yml
Search path:
pkg://hydra.conf (from hydra)
pkg://click (from main)
Expected Behavior
System information
- hydra-core==0.11.3
- Click==7.0
- python 3.6.10
Additional context
This error might be due to the arguement 3
of this line:
https://github.com/facebookresearch/hydra/blob/2a9916133693247775472a4968904b7a05cca1c1/hydra/_internal/utils.py#L142
If I change this argument to -1
, then it works well.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Hydra returning error: "module option must start with http"
I am trying to brute force a web login password using hydra with the below command: hydra -s 8123 -x 2:8:aA1 -t 16...
Read more >How to get a Hydra config without using @hydra.main()
This answer works for regular config files but lets say if you have different structures and paths/dirs/configs for stage/production/developmentĀ ...
Read more >Hydra Logger - Fluke Calibration
clear the COM port for use with Hydra. Logger. Hydra n: RS-232. Communications Error. The selections for Baud Rate and Parity in Hydra...
Read more >Problem with Bruteforce Using Hydra - Null Byte
Hi all, I started to learn using hydra recently and tried to brute force some web base login form which i already have...
Read more >Hydra 1.0
After many months and a lot of hard work by many people, Hydra 1.0 is ... error reporting; Reduce nesting levels with config...
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
Does Hydra offer anything analogous to Clickās
group
?Iām used to doing:
in Click and was hoping to do something similar with Hydra.
The workaround Iām using for now involves setting a
task
key in my config and calling various functions according to its value, but that seems brittle compared to what Click offers.For anyone late to the party (like me), there is a supported way to decouple the CLI and thus use
click
andhydra
together. I just discovered this project this morning so this may not be the best answer but the the ācompose apiā looks like the correct path.Reference: