Complete the code to promote a model to the 'Staging' stage using MLflow.
mlflow_client.transition_model_version_stage(name='my_model', version=[1], stage='Staging')
The version parameter expects the model version number as an integer or string. Here, 1 is the correct version number to promote.
Complete the code to check the current stage of a model version.
model_version = mlflow_client.get_model_version(name='my_model', version=[1]) current_stage = model_version.[2]
The version parameter must be the model version number, here 1. The current stage is accessed via model_version.stage.
Fix the error in the code to promote a model version to 'Production' stage.
mlflow_client.transition_model_version_stage(name='my_model', version=2, stage=[1])
The stage name must be a title case string exactly matching MLflow's expected stage names. Use 'Production' with capital 'P'.
Fill both blanks to create a dictionary mapping model versions to their stages.
version_stage_map = {mv.version: mv.[1] for mv in mlflow_client.search_model_versions('name="my_model"') if mv.[2] != 'Archived'}The attribute stage holds the stage name of the model version. We use it both to get the stage and to filter out 'Archived' versions.
Fill all three blanks to promote all 'Staging' models to 'Production' stage.
for mv in mlflow_client.search_model_versions('name="my_model"'): if mv.[1] == '[2]': mlflow_client.transition_model_version_stage(name='my_model', version=mv.[3], stage='Production')
We check the stage attribute to find models in 'Staging'. Then we use the version attribute to promote each model to 'Production'.