hsml.model_registry #
ModelRegistry #
project_name property #
Name of the project the registry is connected to.
project_path property #
Path of the project the registry is connected to.
project_id property #
Id of the project the registry is connected to.
shared_registry_project_name property #
Name of the project the shared model registry originates from.
model_registry_id property #
Id of the model registry.
tensorflow property #
Module for exporting a TensorFlow model.
sklearn property #
Module for exporting a sklearn model.
torch property #
Module for exporting a torch model.
python property #
Module for exporting a generic Python model.
llm property #
Module for exporting a Large Language Model.
get_model #
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: |
version | Version of the model to retrieve, defaults to TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
model.Model | None | The model metadata object or |
| RAISES | DESCRIPTION |
|---|---|
hopsworks.client.exceptions.RestAPIError | If unable to retrieve model from the model registry. |
get_models #
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: |
| RETURNS | DESCRIPTION |
|---|---|
list[model.Model] | A list of model metadata objects. |
| RAISES | DESCRIPTION |
|---|---|
hopsworks.client.exceptions.RestAPIError | If unable to retrieve model versions from the model registry. |
get_best_model #
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: |
metric | Name of the key in the training metrics field to compare. TYPE: |
direction | 'max' to get the model entity with the highest value of the set metric, or 'min' for the lowest. TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
model.Model | None | The model metadata object or |
| RAISES | DESCRIPTION |
|---|---|
hopsworks.client.exceptions.RestAPIError | If unable to retrieve model from the model registry. |
hf_download #
hf_download(
hugging_face_model_id: str,
hf_token: str | None = None,
selected_formats: list[str] | None = None,
selected_variants: list[str] | None = None,
selected_filenames: list[str] | None = None,
timeout: int = 36000,
poll_interval: int = 5,
) -> model.Model
Import a model from HuggingFace into this Model Registry.
Kicks off the asynchronous server-side download, polls until the import reaches a terminal status, and returns the registered model on success.
import hopsworks
project = hopsworks.login()
mr = project.get_model_registry()
# Public model — minimal call.
m = mr.hf_download("Qwen/Qwen2.5-0.5B")
# Gated / private — supply an HF access token.
m = mr.hf_download("meta-llama/Llama-3.2-1B", hf_token="hf_xxx")
# Multi-quant repo — pick exactly one variant.
m = mr.hf_download(
"unsloth/Kimi-K2.6-GGUF", selected_variants=["UD-Q4_K_XL"]
)
| PARAMETER | DESCRIPTION |
|---|---|
hugging_face_model_id | HF repo id ( TYPE: |
hf_token | Optional HuggingFace access token; required for gated/private repos. TYPE: |
selected_formats | Weight-format keys to download ( |
selected_variants | GGUF / unsloth quantisation tags to keep ( |
selected_filenames | Explicit per-file allowlist. When non-empty this overrides |
timeout | Maximum seconds to wait for the import to reach a terminal state. TYPE: |
poll_interval | Seconds between status polls. TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
model.Model | The newly registered model entity. |
| RAISES | DESCRIPTION |
|---|---|
hopsworks.client.exceptions.HuggingFaceImportException | If the backend fails the import with a known terminal error. The exception's |
hopsworks.client.exceptions.RestAPIError | For unexpected server errors that are not part of the HF import error set. |