g version/stage.

Fetching model versions by stageA common pattern is to assign a special stage to a model version, i.e. production, staging, development etc. This marks this version especially, and can be used to fetch it using a particular semantic meaning, disconnected from the concrete model version. A model version can be assigned a particular stage in the dashboard or by executing the following command in the CLI:

zenml model version update MODEL_NAME --stage=STAGE

These stages can then be passed in as a version to fetch the right model version at a later point:

from zenml import Model, step, pipeline

model= Model(

name="my_model",

version="production"

# The step configuration will take precedence over the pipeline

@step(model=model)

def svc_trainer(...) -> ...:

...

# This configures it for all steps within the pipeline

@pipeline(model=model)

def training_pipeline( ... ):

# training happens here

Autonumbering of versions

ZenML automatically numbers your model versions for you. If you don't specify a version number, or if you pass None into the version argument of the Model object, ZenML will automatically generate a version number (or a new version, if you already have a version) for you. For example if we had a model version really_good_version for model my_model and we wanted to create a new version of this model, we could do so as follows:

from zenml import Model, step

model = Model(

name="my_model",

version="even_better_version"

@step(model=model)

def svc_trainer(...) -> ...:

...

A new model version will be created and ZenML will track that this is the next in the iteration sequence of the models using the number property. If really_good_version was the 5th version of my_model, then even_better_version will be the 6th version of my_model.

from zenml import Model

earlier_version = Model(

name="my_model",

version="really_good_version"

).number # == 5

updated_version = Model(

name="my_model",

version="even_better_version"

).number # == 6