caikit.runtime.client.remote_module_base ======================================== .. py:module:: caikit.runtime.client.remote_module_base .. autoapi-nested-parse:: The RemoteModuleBase is a base class that can be mutated to have the same task methods as a ModuleBase but submit requests to a remote runtime instead of loading locally. By design this class/factory does not use any references to the original Module class. Attributes ---------- .. autoapisummary:: caikit.runtime.client.remote_module_base.log caikit.runtime.client.remote_module_base.error Classes ------- .. autoapisummary:: caikit.runtime.client.remote_module_base.RemoteModuleBase Functions --------- .. autoapisummary:: caikit.runtime.client.remote_module_base.construct_remote_module_class Module Contents --------------- .. py:data:: log .. py:data:: error .. py:class:: RemoteModuleBase(connection_info: caikit.interfaces.common.data_model.ConnectionInfo, protocol: str, model_key: str, model_name: str) Bases: :py:obj:`caikit.core.modules.ModuleBase` Class to act as the base for remote modules. This class will be subclassed and mutated by construct_remote_module_class to make it have the same functions and parameters as the source module. .. py:attribute:: _model_name .. py:attribute:: _connection .. py:attribute:: _tls .. py:attribute:: _protocol .. py:attribute:: _model_key .. py:attribute:: _channel_lock .. py:attribute:: _conn_channel :type: Optional[Union[grpc.Channel, requests.Session]] :value: None .. py:attribute:: _current_conn_time :value: None .. py:attribute:: _max_conn_delta .. py:method:: __del__() Destructor to ensure channel/session is cleaned up on deletion .. py:method:: generate_train_function(method: caikit.runtime.client.remote_config.RemoteRPCDescriptor) -> Callable :classmethod: Factory function to construct a train function that will then be set as an attribute .. py:method:: generate_inference_function(task: Type[caikit.core.task.TaskBase], method: caikit.runtime.client.remote_config.RemoteRPCDescriptor) -> Callable :classmethod: Factory function to construct inference functions that will be set as an attribute. .. py:method:: remote_method_request(method: caikit.runtime.client.remote_config.RemoteRPCDescriptor, service_type: caikit.runtime.names.ServiceType, *args, **kwargs) -> Any Function to run a remote request based on the data stored in RemoteRPCDescriptor .. py:method:: _request_via_http(method: caikit.runtime.client.remote_config.RemoteRPCDescriptor, service_type: caikit.runtime.names.ServiceType, *args, **kwargs) -> Any .. py:method:: _request_via_grpc(method: caikit.runtime.client.remote_config.RemoteRPCDescriptor, service_type: caikit.runtime.names.ServiceType, *args, **kwargs) -> Any Helper function to send a grpc request .. py:property:: _grpc_channel :type: grpc.Channel Helper function to construct a GRPC channel with correct credentials and TLS settings. .. py:property:: _http_session :type: requests.Session Helper function to construct a requests Session with with correct credentials and TLS settings. .. py:method:: _get_remote_object(construction_fn: Callable[[None], Union[grpc.Channel, requests.Session]]) -> Union[grpc.Channel, requests.Session] Helper function to control construction of a grpc channel or http session Args: construction_fn (Callable[[None], Union[grpc.Channel, Session]]): _description_ Returns: Union[grpc.Channel, Session]: _description_ .. py:method:: _get_remote_target() -> str Get the current remote target .. py:method:: _get_streaming_arguments(**kwargs: Dict[str, Any]) -> List[str] :staticmethod: Helper function to detect which kwargs are streaming .. py:method:: _rename_union_sequence_types(obj: Any, dm_type: type) :staticmethod: Helper function that renames all references in a dictionary to match the oneOf value of the DataModel and to collapse all Primitive sequences. This is required to match the format of http requests For example: { "union_str": "test", "ints": { "values":[1,2,3] } } Becomes: { "union": "test", "ints":[1,2,3] } .. py:function:: construct_remote_module_class(model_config: caikit.runtime.client.remote_config.RemoteModuleConfig, model_class: Type[RemoteModuleBase] = RemoteModuleBase) -> Type[caikit.core.modules.ModuleBase] Factory function to construct unique Remote Module Class.