模型阶段

MLflow 入门

Weston Bassler

Senior MLOps Engineer

软件环境

开发、预发布和生产环境示意图

MLflow 入门

MLflow 模型阶段

  • 分配给模型版本
  • 预定义阶段:

    • None
    • Staging
    • Production
    • Archived
  • 一次仅处于一个阶段

MLflow 入门

预定义阶段

预定义阶段

MLflow 入门

None

None 阶段

MLflow 入门

Staging

Staging 阶段

MLflow 入门

生产

生产阶段

MLflow 入门

已归档

归档阶段

MLflow 入门

切换模型阶段

transition-ui

# Import MLFlow Client
from mlflow import MlflowClient
client = MlflowClient()

# Transition to Staging client.transition_model_version_stage( name="Unicorn", version=3, stage="Staging" )
MLflow 入门

将模型版本切到 Staging

# Transition to Staging
client.transition_model_version_stage(name="Unicorn", version=3, stage="Staging")
<ModelVersion: creation_timestamp=1679693470034, current_stage='Staging', 
description=None, last_updated_timestamp=1679699050734, name='Unicorn', 
run_id='a1454f2865e449f8835f38f71e53e547', run_link=None, 
source='./mlruns/1/a1454f2865e449f8835f38f71e53e547/artifacts/model', 
status='READY', status_message=None, tags={}, user_id=None, version=3>
MLflow 入门

注册表界面

staging-ui

MLflow 入门

切换到生产环境

# Transition to Production
client.transition_model_version_stage(name="Unicorn", version=3, 
                                      stage="Production")
<ModelVersion: creation_timestamp=1679693470034, current_stage='Production', 
description=None, last_updated_timestamp=1679699633297, name='Unicorn', 
run_id='a1454f2865e449f8835f38f71e53e547', run_link=None, 
source='./mlruns/1/a1454f2865e449f8835f38f71e53e547/artifacts/model', 
status='READY', status_message=None, tags={}, user_id=None, version=3>
MLflow 入门

¡Vamos a practicar!

MLflow 入门

Preparing Video For Download...