0
0
MLOpsdevops~5 mins

Promoting models between stages in MLOps - Commands & Configuration

Choose your learning style9 modes available
Introduction
When you train a machine learning model, you want to test it carefully before using it for real. Promoting models between stages means moving a model from testing to production safely. This helps avoid mistakes and keeps your app working well.
When you want to move a model from development to testing without breaking anything
When you need to approve a model after checking its accuracy before using it live
When you want to keep track of which model version is currently in production
When you want to roll back to a previous model if the new one causes problems
When you want to automate the process of moving models through different quality checks
Commands
This command moves version 3 of 'my-model' to the Production stage, making it the live model used by your app.
Terminal
mlflow models transition-stage --model-name my-model --version 3 --stage Production
Expected OutputExpected
Model version '3' of model 'my-model' transitioned to stage 'Production'.
--model-name - Specifies the name of the model to promote
--version - Specifies the version number of the model to promote
--stage - Specifies the target stage to promote the model to
This command lists all versions of 'my-model' and shows their current stages, so you can verify the promotion.
Terminal
mlflow models list-versions --model-name my-model
Expected OutputExpected
Version Stage 1 Staging 2 Archived 3 Production
--model-name - Specifies the model to list versions for
This command moves version 2 of 'my-model' to the Archived stage, marking it as no longer active.
Terminal
mlflow models transition-stage --model-name my-model --version 2 --stage Archived
Expected OutputExpected
Model version '2' of model 'my-model' transitioned to stage 'Archived'.
--model-name - Specifies the model name
--version - Specifies the version to archive
--stage - Specifies the Archived stage
Key Concept

If you remember nothing else from this pattern, remember: promoting a model means changing its stage label to control which version your app uses.

Code Example
MLOps
import mlflow
from mlflow.tracking import MlflowClient

client = MlflowClient()

# Promote model version 3 to Production
client.transition_model_version_stage(name='my-model', version=3, stage='Production')
print("Model version 3 promoted to Production")
OutputSuccess
Common Mistakes
Trying to promote a model version that does not exist
The command will fail because the version number is invalid or missing
Check available versions with 'mlflow models list-versions' before promoting
Promoting a model without testing it first
This can cause your app to use a bad model, leading to wrong predictions
Always test models in Staging before moving them to Production
Not archiving old model versions after promotion
Old versions may confuse the system or cause accidental use
Use the Archived stage to mark old versions as inactive
Summary
Use 'mlflow models transition-stage' to move a model version between stages like Staging, Production, or Archived.
Check model versions and their stages with 'mlflow models list-versions' to confirm promotions.
Always test models before promoting and archive old versions to keep your system clean.