
latest_model.set_stage(stage=ModelStages.STAGING)Within a pipeline context, you would get the model from the step context but the mechanism for setting the stage is the same.

from zenml import get_step_context, step, pipeline

from zenml.enums import ModelStages

@step

def promote_to_staging():

model = get_step_context().model

model.set_stage(ModelStages.STAGING, force=True)

@pipeline(

...

def train_and_promote_model():

...

promote_to_staging(after=["train_and_evaluate"])

Fetching model versions by stage

The stage can be used to load the right model version, by passing them in as a version:

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

PreviousLoad a Model in code

NextLinking model binaries/data to a Model

Last updated 15 days ago