caikit.core.data_model.protobufs
This module contains the python protobufs messages defined in the protobufs interfaces. These are used as a backend and for serialization of caikit.core objects but should generally be used only internally or by those intending to serialze data structures. Otherwise, you are probably interested in the classes found directly in data_model.
Functions
|
Add protobufs definitions to the data model so that we can create custom models. |
Package Contents
- caikit.core.data_model.protobufs.import_protobufs(proto_dir, package_base_name, current_globals)[source]
Add protobufs definitions to the data model so that we can create custom models. To do this, we need to provide the path to the proto directory, the base package name, and the globals dict for the package being initialized. Usually this will be called in your __init__.py within your protobufs package, and look a lot like the following.
import os
# Get the import helper from the core from caikit.core.data_model.protobufs import import_protobufs proto_dir = os.path.dirname(os.path.realpath(__file__))
# Import all probobufs as extensions to the core import_protobufs(proto_dir, __name__, globals())
While we could do something like this with introspection, things (unfortunately) don’t play nice with inspecting a wheel whose contents have been compiled to bytecode. :(
- Args:
- proto_dir (str): Path to the proto directory, i.e., the directory that
you __init__ protobufs file is in.
- package_base_name (str): full name of your package, e.g., __name__ from
the __init__ protobufs file.
- current_globals (dict): global dictionary from your protobufs package
__init__ file.