Skip to main content
Version: Next 🚧

Models

This page describes how to create and view models, manage model versions, and delete models using the H2O MLOps Python client.

To learn more about models, see Understand models.

Prerequisites​

Before you begin,

  1. Connect to H2O MLOps. For instructions, see Connect to H2O MLOps.
  2. Create a project. For instructions, see Create a project.
  3. Create an experiment. For instructions, see Create an experiment.

Create a model​

Create a model within the project using the create() method by specifying the model name and the description.

model = project.models.create(name="my-model", description="My Model")
note

The name of the model must be unique within the project.

View models​

Count models​

Get the total number of models in a project:

Input:

project.models.count()

Output:

1

List models​

List all models in a project:

Input:

project.models.list()

Output:

   | name     | uid
---+----------+--------------------------------------
0 | my-model | 27965199-6f0f-4cbe-bf48-e59b05fa1f04

Filter models​

Use the models.list() method with key-value arguments to filter the models.

Input:

project.models.list(name="my-model")

This returns a list of matching models as a table.

Output:

   | name     | uid
---+----------+--------------------------------------
0 | my-model | 27965199-6f0f-4cbe-bf48-e59b05fa1f04

Retrieve a model​

Retrieve a model by UID:

model = project.models.get(uid="d9a47c99-c66c-4ff9-b2b6-30faf5f413ef")

Retrieve a model by model name:

Input:

model = project.models.get(name="my-model")
model

Output:

<class 'h2o_mlops._models.MLOpsModel(
uid='27965199-6f0f-4cbe-bf48-e59b05fa1f04',
name='my-model',
description='My Model',
version_count=0,
owner_username='test.user@test.com',
created_time=datetime.datetime(2025, 6, 3, 15, 33, 10, 882595, tzinfo=tzutc()),
last_modified_time=datetime.datetime(2025, 6, 3, 15, 33, 10, 882595, tzinfo=tzutc())
)'>
note

You can also retrieve a model from the list returned by models.list() using indexing.
For example, model = project.models.list(key=value)[index]. The key and value arguments are optional.

Model properties​

A model has the following main properties:

  • uid: The unique identifier for the model.
  • name: The name of the model.
  • description: A description of the model.
  • version_count: The number of versions of the model.
  • owner: The user who owns the model.
  • created_time: The timestamp when the model was created.
  • last_modified_time: The timestamp of the last modification.
  • last_modified_by: The user who last modified the model.

Update a model​

You can update only the name and description fields of a model.

Make sure to retrieve the model instance before updating it. See Retrieve a model.

Input:

model.update(name="new-my-model", description="New My Model")
model

Output:

<class 'h2o_mlops._models.MLOpsModel(
uid='27965199-6f0f-4cbe-bf48-e59b05fa1f04',
name='new-my-model',
description='New My Model',
version_count=0,
owner_username='test.user@test.com',
created_time=datetime.datetime(2025, 6, 3, 15, 33, 10, 882595, tzinfo=tzutc()),
last_modified_time=datetime.datetime(2025, 6, 3, 15, 33, 32, 502773, tzinfo=tzutc())
)'>

Manage model versions​

Register an experiment with a model​

To create a new version of a model, register an experiment with it.

Use the following code:

model.register(experiment=experiment)
note

You can also register an experiment using the following alternative methods:

  • Register an experiment with an existing model using artifact data. No need for an MLOpsExperiment instance. This method creates and registers the experiment with the model.

    Example:

    model.register(experiment="/path/experiment.zip", name="experiment-name")
  • Register an experiment and create a new model directly using artifact data. No need for MLOpsModel or MLOpsExperiment instances. This method creates both the model and the experiment, then registers the experiment with the model.

    Example:

    model = project.models.register(experiment="/path/experiment.zip", name="experiment-and-model-name",)

To verify that the experiment is registered with the model, run the following code:

Input:

experiment.registered_model

This returns a tuple containing the associated MLOpsModel instance and the model version the experiment was registered to.

Output:

(<class 'h2o_mlops._models.MLOpsModel(
uid='27965199-6f0f-4cbe-bf48-e59b05fa1f04',
name='new-my-model',
description='New My Model',
version_count=1,
owner_username='test.user@test.com',
created_time=datetime.datetime(2025, 6, 3, 15, 33, 10, 882595, tzinfo=tzutc()),
last_modified_time=datetime.datetime(2025, 6, 3, 15, 33, 40, 578744, tzinfo=tzutc())
)'>,1)

List model versions​

List all versions of a model:

Input:

model.versions()

Output:

   |   version | experiment_uid
---+-----------+--------------------------------------
0 | 1 | bdf42b57-c3de-4f33-8c37-f19a9f5f765d

Filter model versions​

Use the model.versions() method with key-value arguments to filter the model versions.

Input:

model.versions(version=1)

This returns a list of matching model versions as a table.

Output:

   |   version | experiment_uid
---+-----------+--------------------------------------
0 | 1 | bdf42b57-c3de-4f33-8c37-f19a9f5f765d

Retrieve a model version​

You can retrieve a specific version of a model from the list returned by model.versions() using indexing.
For example, version = model.versions(key=value)[index]. The key and value arguments are optional.

Input:

model.versions(version=1)[0]

Output:

MLOpsModelVersion(
uid='7fb119cf-aaaa-42e2-985c-e71a84e6396a',
version=1,
model_uid='27965199-6f0f-4cbe-bf48-e59b05fa1f04'
experiment_uid='bdf42b57-c3de-4f33-8c37-f19a9f5f765d',
owner_username='test.user@test.com',
created_time='2025-06-03 03:33:40 PM',
last_modified_time='2025-06-03 03:33:40 PM',
last_modified_by='test.user@test.com',
state='ACTIVE'
)

Retrieve the experiment​

Get the experiment associated with a model version:

Input:

model.experiment(model_version=1)
note

If nothing is specified for the model_version, the default value "latest" is used.

Output:

<class 'h2o_mlops._experiments.MLOpsExperiment(
uid='bdf42b57-c3de-4f33-8c37-f19a9f5f765d',
name='H2O3 MOJO experiment',
description='GLM - Regression',
is_registered=True,
owner_username='test.user@test.com',
created_time=datetime.datetime(2025, 6, 3, 15, 33, 8, 159914, tzinfo=tzutc()),
last_modified_time=datetime.datetime(2025, 6, 3, 15, 33, 8, 159914, tzinfo=tzutc())
)'>

Unregister an experiment from a model​

To remove an experiment from a model, run:

model.unregister(experiment=experiment)

After unregistering the experiment, list the available model versions to verify the change:

Input:

model.versions()

Output:

   | version   | experiment_uid
---+-----------+------------------

The model version created during registration is removed.

note

To unregister all the models, use:

model.unregister(unregister_all=True)

Delete models​

This section describes two ways to delete models.

WARNING

Deleting a model also deletes all of its associated versions. This action is irreversible.

Delete using a model instance​

If you already have a reference to the model object, use the delete() method:

model.delete()

Delete using model UIDs​

You can delete multiple models at once by specifying their UIDs.

Input:

project.models.delete(uids=["c62ced74-905a-4f06-856d-33b9f5725901"])
note

You can also pass a list of MLOpsModel instances or a _utils.Table containing models. For example: project.models.delete(models=[model]).

Output:

   | model_uid                            | is_deleted   | message
---+--------------------------------------+--------------+-----------
0 | c62ced74-905a-4f06-856d-33b9f5725901 | True |

Feedback