caikit.runtime.utils.import_util

A generic module to help import dynamic modules

Attributes

log

Classes

UnifiedDataModel

This class acts as an aggregator between the data models of multiple

Functions

get_data_model(→ UnifiedDataModel)

Get the data model from the Caikit library of interest. This is accomplished

_get_cdm_from_lib(lib_name, cdm)

Function to get caikit core CDM from library name

get_dynamic_module(→ types.ModuleType)

Get the dynamic module of interest.

clean_lib_names(→ List[str])

Module Contents

caikit.runtime.utils.import_util.log[source]
class caikit.runtime.utils.import_util.UnifiedDataModel[source]

This class acts as an aggregator between the data models of multiple Caikit libraries.

_libraries
add_library(lib_name: str, lib: types.ModuleType)[source]

Add the given library to the unified data model

__getattr__(name: str) Any[source]

Fetch an attribute by name aliasing into child libraries

caikit.runtime.utils.import_util.get_data_model(config: aconfig.Config = None) UnifiedDataModel[source]

Get the data model from the Caikit library of interest. This is accomplished via dynamic import on the caikit_library’s environment variable.

NOTE: This function also has the side-effect of importing each of the

caikit_library libraries for the first time, causing their modules to be registered with the caikit.core module registry. It is a critical step in initializing the set of modules that can be loaded by this running server instance.

Args:

config(aconfig.Config): caikit configuration

Returns:

(module): Handle to the module after dynamic wild import

caikit.runtime.utils.import_util._get_cdm_from_lib(lib_name: str, cdm: UnifiedDataModel)[source]

Function to get caikit core CDM from library name

Args:

lib_name (str): Caikit core library name cdm (UnifiedDataModel): Caikit core CDM

Returns:

cdm: UnifiedDataModel

caikit.runtime.utils.import_util.get_dynamic_module(module_name: str, module_dir: str = None) types.ModuleType[source]

Get the dynamic module of interest.

Args:

module_name(str): Name of the module to be dynamically imported (Optional) module_dir(str): Name of the directory from where the module is

to be dynamically imported

Returns:

(module): Handle to the module after dynamic import

caikit.runtime.utils.import_util.clean_lib_names(caikit_library: str) List[str][source]