scaffold.hydra.compose

Attributes

CONFIG_STORE

Functions

compose(→ omegaconf.DictConfig)

Alternative for hydra.compose, which differs in the following ways:

Module Contents

scaffold.hydra.compose.compose(config_name_or_class: str | scaffold.hydra.config_helpers.StructuredConfig, config_dir: str | None = None, overrides: List[str] | None = None, return_hydra_config: bool = False, check_missing: bool | None = False, return_leaf: bool | None = 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.

Parameters:
  • config_name_or_class (Union[str, StructuredConfig]) – 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.

  • config_dir (Optional[str] = None) – Optional absolute config directory to add to the search path.

  • overrides (List[str] = None) – Hydra overrides. See https://hydra.cc/docs/advanced/override_grammar/basic/.

  • return_hydra_config (bool = False) – If True, returns the hydra in the root of the config.

  • check_missing (Optional[bool] = False) – If True, will throw an exception if omegaconf.MISSING or ‘???’ values are present.

  • return_leaf (Optional[bool] = True) – 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.

Returns:

Rendered DictConfig.

scaffold.hydra.compose.CONFIG_STORE