0
0
MLOpsdevops~30 mins

Canary releases for model updates in MLOps - Mini Project: Build & Apply

Choose your learning style9 modes available
Canary releases for model updates
📖 Scenario: You work in a team that manages machine learning models deployed in production. Your team wants to update the model safely by releasing the new version to a small group of users first. This is called a canary release. It helps catch problems early without affecting all users.
🎯 Goal: You will write a simple Python script that simulates a canary release. The script will have a list of users and two model versions. It will assign a small percentage of users to the new model (canary) and the rest to the old model (stable). Finally, it will print which user gets which model version.
📋 What You'll Learn
Create a list of exactly 10 user IDs as strings from 'user1' to 'user10'.
Create a variable called canary_percentage set to 20 to represent 20%.
Write a loop that assigns the first 20% of users to model version 'v2' (canary) and the rest to 'v1' (stable).
Print each user ID with their assigned model version.
💡 Why This Matters
🌍 Real World
Canary releases are used in real machine learning deployments to reduce risk when updating models. By exposing only a small group to the new model, teams can monitor performance and catch issues early.
💼 Career
Understanding canary releases is important for MLOps engineers and DevOps professionals who manage safe and reliable model updates in production systems.
Progress0 / 4 steps
1
Create the user list
Create a list called users with these exact string values: 'user1', 'user2', 'user3', 'user4', 'user5', 'user6', 'user7', 'user8', 'user9', 'user10'.
MLOps
Need a hint?

Use square brackets [] to create a list and put each user ID as a string inside quotes.

2
Set the canary percentage
Create an integer variable called canary_percentage and set it to 20 to represent 20%.
MLOps
Need a hint?

Use = to assign the value 20 to the variable canary_percentage.

3
Assign users to model versions
Write a for loop using the variable index to go through range(len(users)). Inside the loop, assign model version 'v2' to users with index less than len(users) * canary_percentage // 100, else assign 'v1'. Store these assignments in a dictionary called user_model with user IDs as keys and model versions as values.
MLOps
Need a hint?

Use integer division // to calculate the number of users for the canary group.

4
Print user assignments
Write a for loop using variables user and model to iterate over user_model.items(). Inside the loop, print the string "User {user} is assigned to model {model}" using an f-string.
MLOps
Need a hint?

Use for user, model in user_model.items(): and an f-string inside print() to show the assignments.