caikit.core.toolkit.factory
This toolkit utility provides common factory construction semantics and a common base class for classes that can be constructed via caikit config
Attributes
Classes
A class can be constructed by a factory if its constructor takes exactly |
|
The base factory class implements all common factory functionality to |
|
An ImportableFactory extends the base Factory to allow the construction |
Module Contents
- caikit.core.toolkit.factory.error
- class caikit.core.toolkit.factory.FactoryConstructible(config: aconfig.Config, instance_name: str)[source]
Bases:
abc.ABCA class can be constructed by a factory if its constructor takes exactly one argument that is an aconfig.Config object and it has a name to identify itself with the factory.
- property name: str
- Classmethod:
- Abstractmethod:
This is the name of this constructible type that will be used by the factory to identify this class
- class caikit.core.toolkit.factory.Factory(name: str)[source]
The base factory class implements all common factory functionality to read a designated portion of config and instantiate an instance of the registered classes.
- TYPE_KEY = 'type'
- CONFIG_KEY = 'config'
- _name
- _registered_types
- property name: str
- register(constructible: Type[FactoryConstructible])[source]
Register the given constructible
- construct(instance_config: dict, instance_name: str | None = None) FactoryConstructible[source]
Construct an instance of the given type
- class caikit.core.toolkit.factory.ImportableFactory(name: str)[source]
Bases:
FactoryAn ImportableFactory extends the base Factory to allow the construction to specify an “import_class” field that will be used to import and register the implementation class before attempting to initialize it.
- IMPORT_CLASS_KEY = 'import_class'