Skip to main content
Version: Next

Using the config object

Β Example (Click Here)

Here are some basic features of the Hydra Configuration Object:

node:                         # Config is hierarchical
loompa: 10 # Simple value
zippity: ${node.loompa} # Value interpolation
do: "oompa ${node.loompa}" # String interpolation
waldo: ??? # Missing value, must be populated prior to access
from omegaconf import DictConfig, OmegaConf
import hydra

@hydra.main(version_base=None, config_path=".", config_name="config")
def my_app(cfg: DictConfig):
assert cfg.node.loompa == 10 # attribute style access
assert cfg["node"]["loompa"] == 10 # dictionary style access

assert cfg.node.zippity == 10 # Value interpolation
assert isinstance(cfg.node.zippity, int) # Value interpolation type
assert == "oompa 10" # string interpolation

cfg.node.waldo # raises an exception

if __name__ == "__main__":


$ python 
Traceback (most recent call last):
File "", line 32, in my_app
omegaconf.errors.MissingMandatoryValue: Missing mandatory value: node.waldo
full_key: node.waldo

Hydra's configuration object is an instance of OmegaConf's DictConfig. You can learn more about OmegaConf here.