register_config#
- register_config(type_hint: str, plugin: Optional[str] = None, upgrader: Optional[Callable] = None) Callable [source]#
Class decorator used to register Config classes with registry.
All Configs must be registered! Registering a Config does the following:
Associates Config classes with type_hint, plugin, and upgrader, which is necessary for polymorphic deserialization. See build_config() for more details.
Adds a constant type_hint field to the Config which is set to type_hint.
- Parameters
type_hint (str) – a type hint used to deserialize Configs. Must be unique across all registered Configs.
plugin (Optional[str], optional) – the module path of the plugin where the Config is defined. If None, will be inferred. Defauilts to None.
upgrader (Optional[Callable], optional) – a function of the form upgrade(config_dict, version) which returns the corresponding config dict of version = version + 1. This can be useful for maintaining backward compatibility by allowing old configs using an outdated schema to be upgraded to the current schema. Defaults to None.
- Returns
A function that returns a new class that is identical to the input Config with an additional
type_hint
field.- Return type
Callable