When packaging a Hydra application and including a script as an entry point, one can call the script from the command line anywhere. When called the script will utilize the configuration that was included in the package. Is there a way to modify the config search path such that a different configuration can be passed along to the script?
For example:
app.py
import hydra
@hydra.main(config_path="conf", config_name="config")
def my_func(cfg):
print(cfg)
config.yaml
key: value
another_key: second_value
Creating and installing this package with entry_points={"console_scripts": ["hydra_app_test = hydra_app_test.app:my_func"]}
.
$ hydra_app_test
{'key': 'value', 'another_key': 'second_value'}
I would like to be able to define a local config and pass it to hydra_test_app
. Is something like this possible?
some/config/path/config.yaml
key: not_value
mon: key
$ hydra_app_test --config-override=some/config/path
{'key': 'not_value', 'mon': 'key'}
I have tried using the --config-dir
and --config-path
overrides, but without any luck.
$ hydra_app_test --config-dir=some/config/path
{'key': 'value', 'another_key': 'second_value'}
$ hydra_app_test --config-path=some/config/path
Primary config module 'hydra_app_test.some.config.path' not found.
Check that it's correct and contains an __init__.py file
Interestingly enough this pattern works if you do not use the installed app, but run app.py as a script (with the requisite if __name__ == "__main__"
logic)
python path/to/app.py --config-path=some/config/path
{'key': 'not_value', 'mon': 'key'}
Perhaps I am just missing something here, but it would seem you should be able to replicate the same behavior for both installed package scripts and python scripts.