I want to package the repo and provide a cmd-line entry point for all the separate tasks managed by hydra. Let me explain with an example. I have multiple tasks that are all powered by hydra. Each task has 3 possible operations. Let's look at only 2 for simplicity- training and inference I can run them like this
python train.py args.epochs=2 ... # edit default params via hyda
python infer.py ...
Now I want to package this repo and create a cli interface that can access all these tasks and support the same ease of use as hydra. Something like this
yolov5 train --args.epochs=2 # should be same as python detect/train.py --args.epochs=2 ..
yolov5 infer --args.conf=0.2
Up until now, I would use fire CLI to create console entry points. But combining fire with hydra doesn't work. If I try to initialize fire with a function decorated by hydra main, it expects cfg as manual cmd-line input rather than hydra reading the default config.
# train.py
@hydra.main(...):
def run(cfg):
...
fire.Fire({
'classify/train': yolov5.train.run,
}) # Throws error that cfg must be passed
Another way that I can think of is directly adding console entry points to the hydra.main()
decorated function. But that would really populate the global cli space.
So, is there a clean and simple way of supporting this use case? Ideally, I'd like to use only hydra to manage this but open to combining other tools if absolutely necessary.