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:

  1. based on the __type_hash__ if present in the dictionary

  2. based on the type identifier t if present in the dictionary

  3. use the root class, i.e. the class on which the function is called

Parameters:

dct (dict[str, Any]) – dictionary to be converted

Returns:

the constructed configuration object

Return type:

config (BaseConfig)

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:

  1. based on the __type_hash__ if present in the json string

  2. based on the type identifier t if present in the json string

  3. 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:

config (BaseConfig)

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

classmethod from_config_dict(config: dict) V[source]

Create instance from given config dict.

Parameters:

config (dict) – configuration dict

Returns:

instance created from config dict

Return type:

V

class hyped.core.registry.config.BaseConfig[source]

Bases: Registrable, BaseModel

Base Configuration Pydantic Model.

classmethod from_dict(dct: dict[str, Any]) BaseConfig[source]

Convert dict to configuration instance.

Parameters:

dct (dict[str, Any]) – dictionary to be converted

Returns:

the constructed configuration object

Return type:

config (BaseConfig)

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:

config (BaseConfig)

model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'validate_default': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

to_dict() dict[str, Any][source]

Convert configuration object to dictionary.

to_json(**kwargs) str[source]

Serialize config object into json format.

Parameters:

**kwargs – arguments forwarded to json.dumps

Returns:

the serialized configuration string

Return type:

serialized_config (str)

class hyped.core.registry.config.BaseConfigurable(config: None | U = None, **kwargs)[source]

Bases: Generic[U], RegisterTypeMixin, ABC

Base class for configurable types.

CONFIG_TYPE: None | type[U] = None
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 property type_id: str | None

Type Identifier.

Type identifier used in type registry. Identifier is build from configuration type identifier by appending .impl.

class hyped.core.registry.config.RegisterModelMeta(name, bases, attrs, **kwargs)[source]

Bases: RegisterMeta, ModelMetaclass

metaclass for registrable pydantic model.