모델 관리를 SDK v2로 업그레이드

이 문서에서는 SDK v1과 SDK v2의 시나리오를 비교합니다.

모델 만들기

  • SDK v1

    import urllib.request
    from azureml.core.model import Model
    
    # Register model
    model = Model.register(ws, model_name="local-file-example", model_path="mlflow-model/model.pkl")
    
  • SDK v2

    from azure.ai.ml.entities import Model
    from azure.ai.ml.constants import AssetTypes
    
    file_model = Model(
        path="mlflow-model/model.pkl",
        type=AssetTypes.CUSTOM_MODEL,
        name="local-file-example",
        description="Model created from local file."
    )
    ml_client.models.create_or_update(file_model)
    

실험/작업에서 모델 사용

  • SDK v1

    model = run.register_model(model_name='run-model-example',
                               model_path='outputs/model/')
    print(model.name, model.id, model.version, sep='\t')
    
  • SDK v2

    from azure.ai.ml.entities import Model
    from azure.ai.ml.constants import AssetTypes
    
    run_model = Model(
        path="azureml://jobs/$RUN_ID/outputs/artifacts/paths/model/",
        name="run-model-example",
        description="Model created from run.",
        type=AssetTypes.CUSTOM_MODEL
    )
    
    ml_client.models.create_or_update(run_model)
    

모델에 대한 자세한 내용은 Azure Machine Learning에서 모델 작업을 참조하세요.

SDK v1 및 SDK v2의 주요 기능 매핑

SDK v1의 기능 SDK v2의 대략적인 매핑
Model.register ml_client.models.create_or_update
run.register_model ml_client.models.create_or_update
Model.deploy ml_client.begin_create_or_update(blue_deployment)

다음 단계

자세한 내용은 다음 설명서를 참조하세요.