I'd like to convert a OmegaConf/Hydra config to a nested dictionary/list. How can I do this?
Convert hydra/omegaconf config to python nested dict/list?
16.1k Views Asked by Rylan Schaeffer At
2
There are 2 best solutions below
1

One can simply convert from omegaconf to python dictionary by dict(). Follow the example given below:
>>> type(config)
<class 'omegaconf.dictconfig.DictConfig'>
>>> config
{'host': '0.0.0.0', 'port': 8000, 'app': 'main:app', 'reload': False, 'debug': False}
>>> dict(config)
{'host': '0.0.0.0', 'port': 8000, 'app': 'main:app', 'reload': False, 'debug': False}
>>> type(dict(config))
<class 'dict'>
See OmegaConf.to_container().
Usage snippet: