hyped.core.registry.config module¶
Base Configuration Functionality.
- class hyped.core.registry.config.AutoConfig[source]¶
Bases:
BaseAutoClass[BaseConfig]Auto Configuration.
- classmethod from_dict(dct: dict[str, Any]) BaseConfig[source]¶
Convert dict to configuration object of appropriate type.
The type is inferred by the following prioritization:
based on the __type_hash__ if present in the dictionary
based on the type identifier t if present in the dictionary
use the root class, i.e. the class on which the function is called
- Parameters:
- Returns:
the constructed configuration object
- Return type:
- classmethod from_json(serialized: str) BaseConfig[source]¶
Load configuration from json.
Deserialize a json string into a configuration object of appropriate type.
The type is inferred by the following prioritization:
based on the __type_hash__ if present in the json string
based on the type identifier t if present in the json string
use the root class, i.e. the class on which the function is called
- Parameters:
serialized (str) – the serialized string in json format
- Returns:
the constructed configuration object
- Return type:
- class hyped.core.registry.config.AutoConfigurable[source]¶
Bases:
BaseAutoClass[V]Auto Class for configurable types.
- classmethod from_config(config: BaseConfig) V[source]¶
Create instance from given config.
- Parameters:
config (BaseConfig) – configuration
- Returns:
instance created from config
- Return type:
V
- class hyped.core.registry.config.BaseConfig[source]¶
Bases:
Registrable,BaseModelBase Configuration Pydantic Model.
- classmethod from_dict(dct: dict[str, Any]) BaseConfig[source]¶
Convert dict to configuration instance.
- Parameters:
- Returns:
the constructed configuration object
- Return type:
- classmethod from_json(serialized: str) BaseConfig[source]¶
Deserialize a json string into a config.
- Parameters:
serialized (str) – the serialized string in json format
- Returns:
the constructed configuration object
- Return type:
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class hyped.core.registry.config.BaseConfigurable(config: None | U = None, **kwargs)[source]¶
Bases:
Generic[U],RegisterTypeMixin,ABCBase class for configurable types.
- property config: U¶
Retrieves the configuration of the object.
- Returns:
The configuration object.
- Return type:
C
- config_type[source]¶
alias of
BaseConfig
- classmethod from_config(config: U) BaseConfigurable[source]¶
Abstract construction method, must be implemented by sub-types.
- Parameters:
config (T) – configuration to construct the instance from
- Returns:
instance
- Return type:
inst (Configurable)
- generic_config_type[source]¶
alias of
BaseConfig
- class hyped.core.registry.config.RegisterModelMeta(name, bases, attrs, **kwargs)[source]¶
Bases:
RegisterMeta,ModelMetaclassmetaclass for registrable pydantic model.