Model Registry#
Retrieval#
get_model_registry#
Project.get_model_registry()
Connect to Project's Model Registry API.
Example for getting the Model Registry API of a project
import hopsworks
project = hopsworks.login()
mr = project.get_model_registry()
Returns
hsml.model_registry.ModelRegistry
: The Model Registry API
Raises
hopsworks.client.exceptions.RestAPIError
: If the backend encounters an error when handling the request
Modules#
llm#
Module for exporting a Large Language Model.
project_path#
Path of the project the registry is connected to.
python#
Module for exporting a generic Python model.
sklearn#
Module for exporting a sklearn model.
tensorflow#
Module for exporting a TensorFlow model.
torch#
Module for exporting a torch model.
Properties#
llm#
Module for exporting a Large Language Model.
model_registry_id#
Id of the model registry.
project_id#
Id of the project the registry is connected to.
project_name#
Name of the project the registry is connected to.
project_path#
Path of the project the registry is connected to.
shared_registry_project_name#
Name of the project the shared model registry originates from.
Methods#
get_best_model#
ModelRegistry.get_best_model(name, metric, direction)
Get the best performing model entity from the model registry. Getting the best performing model from the Model Registry means specifying in addition to the name, also a metric name corresponding to one of the keys in the training_metrics dict of the model and a direction. For example to get the model version with the highest accuracy, specify metric='accuracy' and direction='max'.
Arguments
- name
str
: Name of the model to get. - metric
str
: Name of the key in the training metrics field to compare. - direction
str
: 'max' to get the model entity with the highest value of the set metric, or 'min' for the lowest.
Returns
Model
: The model metadata object or None
if it does not exist.
Raises
hopsworks.client.exceptions.RestAPIError
: If unable to retrieve model from the model registry.
get_model#
ModelRegistry.get_model(name, version=None)
Get a model entity from the model registry. Getting a model from the Model Registry means getting its metadata handle so you can subsequently download the model directory.
Arguments
- name
str
: Name of the model to get. - version
int
: Version of the model to retrieve, defaults toNone
and will return theversion=1
.
Returns
Model
: The model metadata object or None
if it does not exist.
Raises
hopsworks.client.exceptions.RestAPIError
: If unable to retrieve model from the model registry.
get_models#
ModelRegistry.get_models(name)
Get all model entities from the model registry for a specified name. Getting all models from the Model Registry for a given name returns a list of model entities, one for each version registered under the specified model name.
Arguments
- name
str
: Name of the model to get.
Returns
List[Model]
: A list of model metadata objects.
Raises
hopsworks.client.exceptions.RestAPIError
: If unable to retrieve model versions from the model registry.