0
0
MLOpsdevops~30 mins

Promoting models between stages in MLOps - Mini Project: Build & Apply

Choose your learning style9 modes available
Promoting Models Between Stages
📖 Scenario: You work in a team that builds machine learning models. Each model goes through stages: development, testing, and production. You want to write a simple script to promote a model from one stage to the next.
🎯 Goal: Build a script that stores models with their current stages, sets a target stage, updates the model's stage if allowed, and prints the updated stage.
📋 What You'll Learn
Create a dictionary called models with model names as keys and their current stages as values
Create a variable called target_stage with the value 'production'
Write a function called promote_model that takes a model name and promotes it to the target_stage only if the current stage is 'testing'
Print the updated stage of the model after promotion
💡 Why This Matters
🌍 Real World
Teams use model promotion scripts to safely move machine learning models through development, testing, and production stages.
💼 Career
Understanding model promotion is key for MLOps engineers to automate deployment pipelines and ensure model quality.
Progress0 / 4 steps
1
Create the initial models dictionary
Create a dictionary called models with these exact entries: 'modelA': 'development', 'modelB': 'testing', 'modelC': 'production'
MLOps
Need a hint?

Use curly braces {} to create a dictionary with keys and values.

2
Set the target stage variable
Create a variable called target_stage and set it to the string 'production'
MLOps
Need a hint?

Assign the string 'production' to the variable target_stage.

3
Write the promotion function
Write a function called promote_model that takes a parameter model_name. Inside the function, check if models[model_name] is 'testing'. If yes, update models[model_name] to target_stage. Use an if statement for this check.
MLOps
Need a hint?

Use def to create the function. Use if to check the stage and update the dictionary value.

4
Promote a model and print the result
Call the function promote_model with the argument 'modelB'. Then print the stage of 'modelB' from the models dictionary using print(models['modelB']).
MLOps
Need a hint?

Call the function with 'modelB' and then print the updated stage from the dictionary.