caikit.runtime.service_generation.rpcs ====================================== .. py:module:: caikit.runtime.service_generation.rpcs .. autoapi-nested-parse:: This package has classes that will serialize a python interface to a protocol buffer interface. Typically used for `caikit.core.module`s that expose .train and .run functions. Attributes ---------- .. autoapisummary:: caikit.runtime.service_generation.rpcs.log caikit.runtime.service_generation.rpcs.INDENT Classes ------- .. autoapisummary:: caikit.runtime.service_generation.rpcs.CaikitRPCBase caikit.runtime.service_generation.rpcs.ModuleClassTrainRPC caikit.runtime.service_generation.rpcs.TaskPredictRPC caikit.runtime.service_generation.rpcs.TaskPredictionJobRPC caikit.runtime.service_generation.rpcs.TaskPredictionManagementRPC caikit.runtime.service_generation.rpcs.TaskPredictionStatusRPC caikit.runtime.service_generation.rpcs.TaskPredictionCancelRPC caikit.runtime.service_generation.rpcs.TaskPredictionResultRPC caikit.runtime.service_generation.rpcs._RequestMessage Module Contents --------------- .. py:data:: log .. py:data:: INDENT :value: ' ' .. py:class:: CaikitRPCBase Bases: :py:obj:`abc.ABC` Helper class that provides a standard way to create an ABC using inheritance. .. py:property:: module_list :type: List[Type[caikit.core.ModuleBase]] :abstractmethod: Return the list of caikit.core Modules that can be invoked using this RPC .. py:property:: request :type: _RequestMessage :abstractmethod: Return the internal representation of the request message type for this RPC .. py:property:: name :type: str .. py:method:: create_request_data_model(package_name: str) -> Type[caikit.core.data_model.base.DataBase] Dynamically create data model for this RPC's request message .. py:method:: create_rpc_json(package_name: str) -> Dict Return json snippet for the service definition of this RPC .. py:class:: ModuleClassTrainRPC(method_signature: caikit.core.signature_parsing.CaikitMethodSignature) Bases: :py:obj:`CaikitRPCBase` Helper class to create a unique RPC corresponding with the train function for a given module class .. py:attribute:: clz :type: Type[caikit.core.ModuleBase] .. py:attribute:: _method .. py:attribute:: _name :value: '' .. py:attribute:: return_type .. py:attribute:: _inner_request .. py:attribute:: _req .. py:method:: create_request_data_model(package_name: str) Partial override of CaikitRPCBase.create_request_data_model to take care of the inner request data model .. py:property:: module_list :type: List[Type[caikit.core.ModuleBase]] Returns a list containing the single caikit.core.module type that this RPC is for .. py:property:: request :type: _RequestMessage Return the internal representation of the request message type for this RPC .. py:method:: module_class_to_rpc_name(module_class: Type[caikit.core.ModuleBase]) -> str :staticmethod: Helper function to convert from the name of a module to the name of the request RPC function .. py:method:: module_class_to_req_name(module_class: Type[caikit.core.ModuleBase]) -> str :staticmethod: Helper function to convert from the name of a module to the name of the request RPC message Example: self.clz._module__ = sample_lib.modules.sample_task.sample_implementation return: SampleTaskSampleModuleTrainRequest .. py:method:: module_class_to_inner_request_name(module_class: Type[caikit.core.ModuleBase]) -> str :staticmethod: Helper function to convert from a module to the name of the inner message containing all the training parameters Example: self.clz._module__ = sample_lib.modules.sample_task.sample_implementation return: SampleTaskSampleModuleTrainParameters .. py:method:: _mutate_method_signature_for_training(signature: caikit.core.signature_parsing.CaikitMethodSignature) -> Optional[caikit.core.signature_parsing.CaikitMethodSignature] :staticmethod: .. py:class:: TaskPredictRPC(task: Type[caikit.core.TaskBase], method_signatures: List[caikit.core.signature_parsing.CaikitMethodSignature], input_streaming: bool = False, output_streaming: bool = False) Bases: :py:obj:`CaikitRPCBase` Helper class to create a unique RPC for the aggregate set of Modules that implement the same task .. py:attribute:: task .. py:attribute:: _method_signatures .. py:attribute:: _input_streaming :value: False .. py:attribute:: _output_streaming :value: False .. py:attribute:: _req .. py:attribute:: return_type .. py:attribute:: _name :value: '' .. py:property:: module_list :type: List[Type[caikit.core.ModuleBase]] Returns the list of all caikit.core.modules that this RPC will be for. These should all be of the same ai-problem, e.g. my_caikit_library.modules.classification .. py:property:: request :type: _RequestMessage Return the internal representation of the request message type for this RPC .. py:property:: input_streaming :type: bool .. py:property:: output_streaming :type: bool .. py:method:: create_rpc_json(package_name: str) -> Dict Return json snippet for the service definition of this RPC .. py:method:: _handle_task_inputs(method_params: Dict[str, Any]) -> Dict[str, Any] Overrides input params with types specified in the Task .. py:method:: _task_to_req_name() -> str Helper function to convert the pair of library name and task name to a request message name .. py:method:: _task_to_rpc_name() -> str Helper function to convert the pair of library name and task name to an RPC name Example: self.task = (sample_lib, sample_task) return: SampleTaskPredict .. py:class:: TaskPredictionJobRPC(task: Type[caikit.core.TaskBase], method_signatures: List[caikit.core.signature_parsing.CaikitMethodSignature]) Bases: :py:obj:`TaskPredictRPC` Helper class to create a unique RPC for prediction tasks. This reuses a large amount of the code from the TaskPredictRPC generation .. py:attribute:: return_type .. py:method:: _task_to_rpc_name() -> str Helper function to convert the pair of library name and task name to an RPC name Example: self.task = (sample_lib, sample_task) return: SampleTaskPredict .. py:class:: TaskPredictionManagementRPC(task: Type[caikit.core.TaskBase], method_signatures: List[caikit.core.signature_parsing.CaikitMethodSignature]) Bases: :py:obj:`CaikitRPCBase` Helper class to create RPCs for each of the job management types .. py:attribute:: task .. py:attribute:: _method_signatures .. py:attribute:: _name .. py:attribute:: _req .. py:property:: return_type :type: Type[caikit.core.data_model.base.DataBase] :abstractmethod: The return type of the management APIs. Must be implemented by subclasses .. py:property:: request :type: _RequestMessage Return the internal representation of the request message type for this RPC .. py:property:: module_list :type: List[Type[caikit.core.ModuleBase]] Returns the list of all caikit.core.modules that this RPC will be for. These should all be of the same ai-problem, e.g. my_caikit_library.modules.classification .. py:property:: input_type :type: Type[caikit.core.data_model.base.DataBase] The input type for all management requests will be a PredictionJobInfoRequest .. py:method:: create_rpc_json(package_name: str) -> Dict Return json snippet for the service definition of this RPC .. py:method:: get_rpc_name() -> str :abstractmethod: Helper function to convert the pair of library name and task name to an RPC name. This must be implemented by subclasses .. py:class:: TaskPredictionStatusRPC(task: Type[caikit.core.TaskBase], method_signatures: List[caikit.core.signature_parsing.CaikitMethodSignature]) Bases: :py:obj:`TaskPredictionManagementRPC` Helper class to create RPCs for each of the job management types .. py:attribute:: return_type The return type of the management APIs. Must be implemented by subclasses .. py:method:: get_rpc_name() -> str Get the status RPC name .. py:class:: TaskPredictionCancelRPC(task: Type[caikit.core.TaskBase], method_signatures: List[caikit.core.signature_parsing.CaikitMethodSignature]) Bases: :py:obj:`TaskPredictionManagementRPC` Helper class to create RPCs for each of the job management types .. py:attribute:: return_type The return type of the management APIs. Must be implemented by subclasses .. py:method:: get_rpc_name() -> str Get the cancel RPC name .. py:class:: TaskPredictionResultRPC(task: Type[caikit.core.TaskBase], method_signatures: List[caikit.core.signature_parsing.CaikitMethodSignature]) Bases: :py:obj:`TaskPredictionManagementRPC` Helper class to create RPCs for each of the job management types .. py:property:: return_type The return type of the management APIs. Must be implemented by subclasses .. py:method:: get_rpc_name() -> str Get the result RPC name .. py:class:: _RequestMessage(msg_name: str, params: Dict[str, Type], default_map: Dict[str, Any]) Helper class to create the input request message that wraps up the inputs for a given function. The request Contains N named data-model or primitive objects. .. py:attribute:: name .. py:attribute:: triples :value: [] .. py:attribute:: default_map .. py:method:: create_data_model(package_name: str) -> Type[caikit.core.data_model.base.DataBase] Dynamically create a data model for this request message