Skip to main content
Version: 1.0

Using the config object


Your configuration object is an instance of OmegaConf's DictConfig.
Here are some of the basic features:

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
@hydra.main(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


$ python Missing mandatory value: waldo        full_key: waldo        reference_type=Optional[Dict[Any, Any]]        object_type=dict

You can learn more about OmegaConf here.