

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 更新私有中心中的资源
<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 提交[更新中心内容请求。](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 内容引用请求。](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"
```

------