scaffold.hydra.compose ====================== .. py:module:: scaffold.hydra.compose Attributes ---------- .. autoapisummary:: scaffold.hydra.compose.CONFIG_STORE Functions --------- .. autoapisummary:: scaffold.hydra.compose.compose Module Contents --------------- .. py:function:: compose(config_name_or_class: Union[str, scaffold.hydra.config_helpers.StructuredConfig], config_dir: Optional[str] = None, overrides: Optional[List[str]] = None, return_hydra_config: bool = False, check_missing: Optional[bool] = False, return_leaf: Optional[bool] = True) -> omegaconf.DictConfig Alternative for hydra.compose, which differs in the following ways: 1. No need to call `hydra.initialize` before composing a config, since this will use `scaffold.hydra.initialize` internally, which uses an existing instance if available. 2. Is able to compose a config from a `StructuredConfig` class, which does not require the user to know the path in the config store, where the structured config was registered. 3. Can check for missing values right away, instead of throwing an exception when trying to access them. 4. Can automatically return the leaf node of the given config. When calling the original hydra.compose("/my/grouped/config"), this results in a config with the keys config["my"]["group"][...]. Setting return_leaf=True, scaffold.hydra.compose will automatically return the result of config["my"]["group"] instead of adding all group keys. :param config_name_or_class: Path to the config in the config store, or StructuredConfig class. Passing an instance of StructuredConfig has the same effect, but will throw a warning if the instance arguments are not the same as the default ones. :type config_name_or_class: Union[str, StructuredConfig] :param config_dir: Optional absolute config directory to add to the search path. :type config_dir: Optional[str] = None :param overrides: Hydra overrides. See https://hydra.cc/docs/advanced/override_grammar/basic/. :type overrides: List[str] = None :param return_hydra_config: If True, returns the hydra in the root of the config. :type return_hydra_config: bool = False :param check_missing: If True, will throw an exception if omegaconf.MISSING or '???' values are present. :type check_missing: Optional[bool] = False :param return_leaf: If True, will return the leaf node of the config path inside the config store, so compose("/my/grouped/config") will return only the values in the "config" node or yaml, without still containing the group keys in the returned config. :type return_leaf: Optional[bool] = True :returns: Rendered DictConfig. .. py:data:: CONFIG_STORE