caikit.core.toolkit.factory =========================== .. py:module:: caikit.core.toolkit.factory .. autoapi-nested-parse:: This toolkit utility provides common factory construction semantics and a common base class for classes that can be constructed via caikit config Attributes ---------- .. autoapisummary:: caikit.core.toolkit.factory.log caikit.core.toolkit.factory.error Classes ------- .. autoapisummary:: caikit.core.toolkit.factory.FactoryConstructible caikit.core.toolkit.factory.Factory caikit.core.toolkit.factory.ImportableFactory Module Contents --------------- .. py:data:: log .. py:data:: error .. py:class:: FactoryConstructible(config: aconfig.Config, instance_name: str) Bases: :py:obj:`abc.ABC` A 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. .. py:property:: name :type: str :classmethod: :abstractmethod: This is the name of this constructible type that will be used by the factory to identify this class .. py:class:: Factory(name: str) The base factory class implements all common factory functionality to read a designated portion of config and instantiate an instance of the registered classes. .. py:attribute:: TYPE_KEY :value: 'type' .. py:attribute:: CONFIG_KEY :value: 'config' .. py:attribute:: _name .. py:attribute:: _registered_types .. py:property:: name :type: str .. py:method:: register(constructible: Type[FactoryConstructible]) Register the given constructible .. py:method:: construct(instance_config: dict, instance_name: Optional[str] = None) -> FactoryConstructible Construct an instance of the given type .. py:class:: ImportableFactory(name: str) Bases: :py:obj:`Factory` An 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. .. py:attribute:: IMPORT_CLASS_KEY :value: 'import_class' .. py:method:: construct(instance_config: dict, instance_name: Optional[str] = None) Construct an instance of the given type