Skip to main content
Version: v0.62.0

Experiment artifacts

In addition to scoring artifacts, experiments can have other types of artifacts attached to them. This page describes how to interact with those artifacts.

  1. Connect to H2O MLOps.
import h2o_mlops


mlops = h2o_mlops.Client()
  1. Get an existing experiment to work with by creating a new one.
project = mlops.projects.create(name="demo")
experiment = project.experiments.create(
data="/Users/jgranados/Downloads/GBM_model_python_1649367037255_1.zip",
name="experiment-from-client"
)

Add artifacts

json_artifact = experiment.artifacts.add("./artifact.json")

Note that it is possible to specify the MIME type if the client cannot automatically detect it.

docx_artifact = experiment.artifacts.add(
data="./artifact.docx",
mime_type="application/vnd.openxmlformats-officedocument.wordprocessingml.document"
)

List artifacts

You can view all the artifacts included in the experiment. Note the mime_type, which indicates the media type of the data.

experiment.artifacts.list()

Output:

    | name          | mime_type                 | uid
----+---------------+---------------------------+--------------------------------------
0 | h2o3/mojo | application/zip | dacea816-1499-4848-b4eb-e151ec4152c6
1 | artifact.json | application/json | d6a0723c-8545-4821-bcff-fa8c42ef7d23
2 | artifact.docx | application/vnd.openxmlfo | 100a8f1d-1bf1-46fd-990a-cf54dd461eaf

Retrieve artifacts

json_artifact = experiment.artifacts.list(name="artifact.json")[0]

Note that it is also possible to use experiment.artifacts.get(uid) to directly retrieve an artifact.

Consume artifacts

The following are several examples of things that can be done with an artifact.

Convert JSON artifacts to a Python dictionary or string

JSON artifacts can be converted to a Python dictionary or string. Text artifacts can only be converted to string.

Input:

json_artifact.to_dictionary()["key"]

Output:

'value'

Input:

json_artifact.to_string()

Output:

'{\n    "key": "value"\n}'

Download artifacts

All artifacts can be downloaded.

Input:

docx_artifact.download(overwrite=True)

Output:

'artifact.docx'

Feedback