Find the overridden parameters of a hydra config object

34 Views Asked by At

If I set up my hydra config.yaml file with a parameter param1: 12 and then override it through the command line e.g

python run.py param1==42

And run.py is :

@hydra.main(version_base=None, config_path=".", config_name='config.yaml')
def main(cfg) :
   ...

Is there a way to see which parameters were overridden this way ? For example something like cfg.overrides() -> dict ?

Thank you very much

1

There are 1 best solutions below

0
Omry Yadan On

This is available in the HydraConfig singleton. You can also inspect that object from the command line with the flag --cfg hydra.

import hydra
from hydra.core.hydra_config import HydraConfig


@hydra.main(version_base=None, config_path="conf", config_name="cfg")
def main(cfg):
    print(HydraConfig.get().overrides.task)


if __name__ == '__main__':
    main()