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


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

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