metron_shared.config.instantiate module#
Instantiation from Hydra Config.
- class metron_shared.config.instantiate.HydraInstantiateConversion(value)#
Bases:
Enum
Defines Hydra’s instantiation conversion options. Basically how to handle list and dict like objects, whether they are represented via OmegaConf structs or Python structs.
- ALL = 'all'#
- NO_CONVERSION = 'none'#
- PARTIAL = 'partial'#
- metron_shared.config.instantiate.instantiate_from_hydra_config(hydra_object_config: Union[omegaconf.DictConfig, Dict[str, Any]], conversion: HydraInstantiateConversion = HydraInstantiateConversion.NO_CONVERSION, **kwargs: Any) → Any#
Instantiates object from Hydra object config <hydra_object_config>. It has to contain <_target_> attribute.
- Parameters:
hydra_object_config (Union[DictConfig, Dict[Any]]) – Object’s Hydra config DictConfig or Dict created from that.
conversion (HydraInstantiateConversion) – Defined how non-primitive values in OmegaConf are handled. See https://hydra.cc/docs/advanced/instantiate_objects/overview/#parameter-conversion-strategies.
**kwargs – Key-worded arguments which are passed into a constructor of the instantiated class.
Returns (Any): Instantiated object.