

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 更新模型套件階段和狀態範例 (boto3)
<a name="model-registry-staging-construct-update-boto3"></a>

若要更新模型套件階段和狀態，您需要擔任具有相關許可的執行角色。以下提供如何使用 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_UpdateModelPackage.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_UpdateModelPackage.html) API 或使用 適用於 Python (Boto3) 的 AWS SDK更新階段狀態的範例。

在此範例中，[https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_UpdateModelPackage.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_UpdateModelPackage.html) API 動作的 `ModelLifeCycle` 階段 `"Development"` 和階段狀態 `"Approved"` 條件金鑰已授予您的執行角色。您也可以在 `{{stage-description}}` 中包括描述。如需詳細資訊，請參閱[設定預備建構模組範例](model-registry-staging-construct-set-up.md)。

```
from sagemaker import get_execution_role, session 
import boto3 

region = boto3.Session().region_name role = get_execution_role() 
sm_client = boto3.client('sagemaker', region_name=region)

model_package_update_input_dict = {
    "ModelLifeCycle" : { 
        "stage" : "Development",
        "stageStatus" : "Approved",
        "stageDescription" : "{{stage-description}}"
    }
} 
model_package_update_response = sm_client.update_model_package(**model_package_update_input_dict)
```