unionml.services.bentoml.BentoMLService#

class unionml.services.bentoml.BentoMLService(model, framework, name=None)#

Initialize a BentoML Service for generating predictions from a unionml.model.Model.

Parameters:
  • model (Model) – the Model bound to this service.

  • framework (str) – machine learning framework supported by bentoml. This is used to access the appropriate module bentoml.<framework>, e.g. bentoml.sklearn.

  • name (Optional[str]) – custom name to give this service. If None, uses nam.

Methods

configure

Create the bentoml.Service API.

load_model

Load a bentoml.Model from a version.

save_model

Save the model as a bentoml.Model.

Attributes

IO_DESCRIPTOR_MAPPING

Maps python types to BentoML IO descriptors

model

Get the Model bound to this service.

name

Get the name of the service.

svc

Get the underlying bentoml.Service instance.

IO_DESCRIPTOR_MAPPING = {<class 'numpy.ndarray'>: <class 'bentoml._internal.io_descriptors.numpy.NumpyNdarray'>, <class 'pandas.core.frame.DataFrame'>: <class 'bentoml._internal.io_descriptors.pandas.PandasDataFrame'>, <class 'list'>: <class 'bentoml._internal.io_descriptors.json.JSON'>, <class 'dict'>: <class 'bentoml._internal.io_descriptors.json.JSON'>}#

Maps python types to BentoML IO descriptors

configure(feature_type=None, output_type=None, enable_async=False, supported_resources=None, supports_cpu_multi_threading=False, runnable_method_kwargs=None)#

Create the bentoml.Service API.

Parameters:
Raises:

ModelArtifactNotFound if the bound unionml.model.Model instance does not have a defined artifact property.

Return type:

Service

load_model(tag_or_version)#

Load a bentoml.Model from a version.

Parameters:
  • tag_or_version (str) – the tag or version associated with the model name. E.g., the version in the tag my_model:version1 would be version1.

  • framework – machine learning framework supported by bentoml. This is used to access the appropriate module bentoml.<framework>, e.g. bentoml.sklearn

property model: Model#

Get the Model bound to this service.

property name: str#

Get the name of the service.

save_model(model_object=None, **kwargs)#

Save the model as a bentoml.Model.

Parameters:
  • model_object (Optional[Any]) – model object to save. If None, this method assumes that unionml.model.Model.artifact is defined.

  • framework – machine learning framework supported by bentoml. This is used to access the appropriate module bentoml.<framework>, e.g. bentoml.sklearn

property svc: Service#

Get the underlying bentoml.Service instance.