model, and associated artifacts and run like this:zenml model version list <MODEL_NAME> can be used to list all versions of a particular model.

The following commands can be used to list the various pipeline runs associated with a model:

zenml model version runs <MODEL_NAME> <MODEL_VERSIONNAME>

The following commands can be used to list the various artifacts associated with a model:

zenml model version data_artifacts <MODEL_NAME> <MODEL_VERSIONNAME>

zenml model version model_artifacts <MODEL_NAME> <MODEL_VERSIONNAME>

zenml model version deployment_artifacts <MODEL_NAME> <MODEL_VERSIONNAME>

The ZenML Pro dashboard has additional capabilities, that include visualizing all associated runs and artifacts for a model version:

Fetching the model in a pipeline

When configured at the pipeline or step level, the model will be available through the StepContext or PipelineContext.

from zenml import get_step_context, get_pipeline_context, step, pipeline

@step

def svc_trainer(

X_train: pd.DataFrame,

y_train: pd.Series,

gamma: float = 0.001,

) -> Annotated[ClassifierMixin, "trained_model"]:

# This will return the model specified in the

# @pipeline decorator. In this case, the production version of

# the `iris_classifier` will be returned in this case.

model = get_step_context().model

...

@pipeline(

model=Model(

# The name uniquely identifies this model

name="iris_classifier",

# Pass the stage you want to get the right model

version="production",

),

def training_pipeline(gamma: float = 0.002):

# Now this pipeline will have the production `iris_classifier` model active.

model = get_pipeline_context().model

X_train, X_test, y_train, y_test = training_data_loader()

svc_trainer(gamma=gamma, X_train=X_train, y_train=y_train)

Logging metadata to the Model object

Just as one can associate metadata with artifacts, models too can take a dictionary of key-value pairs to capture their metadata. This is achieved using the log_model_metadata method: