e useful for understanding the nature of the data.As an example, one can associate the results of a model training alongside a model artifact, the shape of a table alongside a pandas dataframe, or the size of an image alongside a PNG file.

For some artifacts, ZenML automatically logs metadata. As an example, for pandas.Series and pandas.DataFrame objects, ZenML logs the shape and size of the objects:

from zenml.client import Client

# Get an artifact version (e.g. pd.DataFrame)

artifact = Client().get_artifact_version('50ce903f-faa6-41f6-a95f-ff8c0ec66010')

# Fetch it's metadata

artifact.run_metadata["storage_size"].value  # Size in bytes

artifact.run_metadata["shape"].value  # Shape e.g. (500,20)

The information regarding the metadata of an artifact can be found within the DAG visualizer interface on the OSS dashboard:

The ZenML Pro dashboard offers advanced visualization features for artifact exploration, including a dedicated artifacts tab with metadata visualization:

A user can also add metadata to an artifact within a step directly using the log_artifact_metadata method:

from zenml import step, log_artifact_metadata

@step

def model_finetuner_step(

model: ClassifierMixin, dataset: Tuple[np.ndarray, np.ndarray]

) -> Annotated[

ClassifierMixin, ArtifactConfig(name="my_model", tags=["SVC", "trained"])

]:

"""Finetunes a given model on a given dataset."""

model.fit(dataset[0], dataset[1])

accuracy = model.score(dataset[0], dataset[1])

log_artifact_metadata(

# Artifact name can be omitted if step returns only one output

artifact_name="my_model",

# Passing None or omitting this will use the `latest` version

version=None,

# Metadata should be a dictionary of JSON-serializable values

metadata={"accuracy": float(accuracy)}

# A dictionary of dictionaries can also be passed to group metadata

#  in the dashboard

# metadata = {"metrics": {"accuracy": accuracy}}

return model