

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

# 更新私有中樞內的資源
<a name="jumpstart-curated-hubs-update"></a>

您可以更新私有中樞內的資源，以變更其中繼資料。您可以更新的資源包括 Amazon SageMaker JumpStart 模型、自訂模型、筆記本、資料集和 JsonDoc 的模型參考。

更新模型、筆記本、資料集或 JsonDoc 資源時，您可以更新內容描述、顯示名稱、關鍵字和支援狀態。更新 JumpStart 模型的模型參考時，您只能更新指定所要使用最低模型版本的欄位。
+ 「更新模型或筆記本資源」以包含 DataSet/JsonDoc。在 CLI 命令中，DataSets/JsonDocs 應新增至 hub-content-type 引數。

依照所要更新資源特有的章節進行。

## 更新模型或筆記本資源
<a name="jumpstart-curated-hubs-update-model-notebook"></a>

若要更新模型或筆記本資源，請使用 [UpdateHubContent](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_UpdateHubContent.html) API。

您可以使用此 API 更新的有效中繼資料欄位如下：
+ `HubContentDescription` – 資源的描述。
+ `HubContentDisplayName` – 資源的顯示名稱。
+ `HubContentMarkdown` – 資源的描述，採用 Markdown 格式。
+ `HubContentSearchKeywords` – 資源的可搜尋關鍵字。
+ `SupportStatus` – 資源的目前狀態。

在您的請求中，包含一或多個上述欄位的變更。如果您嘗試更新任何其他欄位，例如中樞內容類型，您會收到錯誤。

------
#### [ 適用於 Python (Boto3) 的 AWS SDK ]

下列範例顯示如何使用 適用於 Python (Boto3) 的 AWS SDK 提交 [ UpdateHubContent](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_UpdateHubContent.html) 請求。

**注意**  
您在請求中指定的 `HubContentVersion` 表示特定版本的中繼資料已更新。若要尋找您中樞內容的所有可用版本，您可以使用 [ListHubContentVersions](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_ListHubContentVersions.html) API。

```
import boto3
sagemaker_client = boto3.Session(region_name=<AWS-region>).client("sagemaker")

sagemaker_client.update_hub_contents(
    HubName={{<hub-name>}},
    HubContentName={{<resource-content-name>}},
    HubContentType={{<"Model"|"Notebook">}},
    HubContentVersion='1.0.0', # specify the correct version that you want to update
    HubContentDescription={{<updated-description-string>}}
)
```

------
#### [ AWS CLI ]

下列範例顯示如何使用 AWS CLI 提交 [ update-hub-content](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/sagemaker/update-hub-content.html) 請求。

```
aws sagemaker update-hub-content \
--hub-name {{<hub-name>}} \
--hub-content-name {{<resource-content-name>}} \
--hub-content-type {{<"Model"|"Notebook">}} \
--hub-content-version "1.0.0" \
--hub-content-description {{<updated-description-string>}}
```

------

## 更新模型參考
<a name="jumpstart-curated-hubs-update-model-reference"></a>

若要更新 JumpStart 模型的模型參考，請使用 [UpdateHubContentReference](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_UpdateHubContentReference.html) API。

您只能更新模型參考的 `MinVersion` 欄位。

------
#### [ 適用於 Python (Boto3) 的 AWS SDK ]

下列範例示範如何使用 適用於 Python (Boto3) 的 AWS SDK 提交 [ UpdateHubContentReference](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_UpdateHubContentReference.html) 請求。

```
import boto3
sagemaker_client = boto3.Session(region_name=<AWS-region>).client("sagemaker")

update_response = sagemaker_client.update_hub_content_reference(
    HubName={{<hub-name>}},
    HubContentName={{<model-reference-content-name>}},
    HubContentType='ModelReference',
    MinVersion='1.0.0'
)
```

------
#### [ AWS CLI ]

下列範例示範如何使用 AWS CLI 提交 [ update-hub-content-reference](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/sagemaker/update-hub-content-reference.html) 請求。

```
aws sagemaker update-hub-content-reference \
 --hub-name {{<hub-name>}} \
 --hub-content-name {{<model-reference-content-name>}} \
 --hub-content-type "ModelReference" \
 --min-version "1.0.0"
```

------