Skip to content

Model Registry#

You can obtain a ModelRegistry using Project.get_model_registry.

ModelRegistry #

llm property #

llm

Module for exporting a Large Language Model.

model_registry_id property #

model_registry_id

Id of the model registry.

project_id property #

project_id

Id of the project the registry is connected to.

project_name property #

project_name

Name of the project the registry is connected to.

project_path property #

project_path

Path of the project the registry is connected to.

python property #

python

Module for exporting a generic Python model.

shared_registry_project_name property #

shared_registry_project_name

Name of the project the shared model registry originates from.

sklearn property #

sklearn

Module for exporting a sklearn model.

tensorflow property #

tensorflow

Module for exporting a TensorFlow model.

torch property #

torch

Module for exporting a torch model.

get_best_model #

get_best_model(
    name: str, metric: str, direction: str
) -> model.Model | None

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'.

PARAMETER DESCRIPTION
name

Name of the model to get.

TYPE: str

metric

Name of the key in the training metrics field to compare.

TYPE: str

direction

'max' to get the model entity with the highest value of the set metric, or 'min' for the lowest.

TYPE: str

RETURNS DESCRIPTION
model.Model | None

Model: The model metadata object or None if it does not exist.

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If unable to retrieve model from the model registry.

get_model #

get_model(
    name: str, version: int = None
) -> model.Model | 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.

PARAMETER DESCRIPTION
name

Name of the model to get.

TYPE: str

version

Version of the model to retrieve, defaults to None and will return the version=1.

TYPE: int DEFAULT: None

RETURNS DESCRIPTION
model.Model | None

Model: The model metadata object or None if it does not exist.

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If unable to retrieve model from the model registry.

get_models #

get_models(name: str) -> list[model.Model]

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.

PARAMETER DESCRIPTION
name

Name of the model to get.

TYPE: str

RETURNS DESCRIPTION
list[model.Model]

List[Model]: A list of model metadata objects.

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If unable to retrieve model versions from the model registry.