0
0
MLOpsdevops~30 mins

Blue-green deployment for models in MLOps - Mini Project: Build & Apply

Choose your learning style9 modes available
Blue-green deployment for models
📖 Scenario: You work in a team that manages machine learning models in production. To avoid downtime and risks when updating models, your team uses a blue-green deployment strategy. This means you have two identical environments: blue and green. One environment serves the live traffic, while the other is used to deploy and test the new model version. After testing, you switch traffic to the new environment.In this project, you will simulate a simple blue-green deployment system for ML models using Python dictionaries and variables.
🎯 Goal: You will build a small program that manages two model environments (blue and green) with their versions. You will set the active environment, deploy a new model version to the inactive environment, switch the active environment, and print the current active model version.
📋 What You'll Learn
Create a dictionary to hold model versions for blue and green environments
Create a variable to track the currently active environment
Write code to deploy a new model version to the inactive environment
Write code to switch the active environment to the inactive one
Print the active environment and its model version
💡 Why This Matters
🌍 Real World
Blue-green deployment is a common technique in MLOps to update machine learning models without downtime or risk. It allows teams to test new models in a safe environment before switching live traffic.
💼 Career
Understanding blue-green deployment helps you work with production ML systems, ensuring smooth updates and high availability, which is a key skill for MLOps engineers and DevOps professionals.
Progress0 / 4 steps
1
Create model version dictionary
Create a dictionary called model_versions with keys 'blue' and 'green'. Set the value for 'blue' to 'v1.0' and for 'green' to 'v0.9'.
MLOps
Need a hint?

Use curly braces {} to create a dictionary with keys 'blue' and 'green' and their version strings as values.

2
Set active environment variable
Create a variable called active_env and set it to the string 'blue' to represent the currently active environment.
MLOps
Need a hint?

Just assign the string 'blue' to the variable active_env.

3
Deploy new model version to inactive environment
Create a variable called inactive_env that is the opposite of active_env (if active_env is 'blue', inactive_env should be 'green', and vice versa). Then update the model_versions dictionary for the inactive_env key to the new version string 'v1.1'.
MLOps
Need a hint?

Use a conditional expression to set inactive_env. Then assign 'v1.1' to model_versions[inactive_env].

4
Switch active environment and print status
Switch the active_env to the inactive_env. Then print the string "Active environment: {active_env}, Model version: {version}" where {active_env} is the current active environment and {version} is the model version from model_versions for that environment.
MLOps
Need a hint?

Assign active_env = inactive_env. Use an f-string in print to show the active environment and its model version.