Vertex AI Feature Store 可让您为以下类型的资源添加或更新标签:
- 特征组 (
FeatureGroup
) - 特征 (
Feature
) - 在线存储区实例 (
FeatureOnlineStore
) - 特征视图实例 (
FeatureView
)
您可以在资源创建期间添加标签,也可以向现有资源添加标签。请注意,向这些资源添加标签是可选操作。
准备工作
向 Vertex AI 进行身份验证,除非您已完成此操作。
如需在本地开发环境中使用本页面上的 REST API 示例,请使用您提供给 gcloud CLI 的凭据。
Install the Google Cloud CLI, then initialize it by running the following command:
gcloud init
如需了解详情,请参阅 Google Cloud 身份验证文档中的使用 REST 时进行身份验证。
更新特征组的标签
使用以下示例可更新现有特征组的标签。
REST
如需更新现有 FeatureGroup
资源的标签,请使用 featureGroups.patch 方法发送 PATCH
请求。
在使用任何请求数据之前,请先进行以下替换:
- LOCATION_ID:特征组所在的区域,例如
us-central1
。 - PROJECT_ID:您的项目 ID。
- FEATUREGROUP_NAME:您要更新的特征组的名称。
- LABELS_JSON:要附加到特征组作为键值对的 JSON 格式的标签。
例如:
{"label1_key": "label1_value", "label2_key": "label2_value", ...}
HTTP 方法和网址:
PATCH https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups?feature_group_id=FEATUREGROUP_NAME
请求 JSON 正文:
{ "labels": LABELS_JSON }
如需发送请求,请选择以下方式之一:
curl
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups?feature_group_id=FEATUREGROUP_NAME"
PowerShell
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method PATCH `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups?feature_group_id=FEATUREGROUP_NAME" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1.UpdateFeatureGroupOperationMetadata", "genericMetadata": { "createTime": "2023-09-18T03:00:13.060636Z", "updateTime": "2023-09-18T03:00:13.060636Z" } }, "done": true, "response": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1.FeatureGroup", "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME" } }
更新特征的标签
使用以下示例可更新现有特征的标签。
REST
如需更新现有 Feature
资源的标签,请使用 features.patch 方法发送 PATCH
请求。
在使用任何请求数据之前,请先进行以下替换:
- LOCATION_ID:包含特征的特征组所在的区域,例如
us-central1
。 - PROJECT_ID:您的项目 ID。
- FEATUREGROUP_NAME:包含特征的特征组的名称。
- FEATURE_NAME:要更新的特征的名称。
- LABELS_JSON:要附加到特征作为键值对的 JSON 格式的标签。
例如:
{"label1_key": "label1_value", "label2_key": "label2_value", ...}
HTTP 方法和网址:
PATCH https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/features?feature_id=FEATURE_NAME
请求 JSON 正文:
{ "labels": LABELS_JSON }
如需发送请求,请选择以下方式之一:
curl
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/features?feature_id=FEATURE_NAME"
PowerShell
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method PATCH `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/features?feature_id=FEATURE_NAME" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/features/FEATURE_NAME/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1.UpdateFeatureOperationMetadata", "genericMetadata": { "createTime": "2023-09-18T02:36:22.870679Z", "updateTime": "2023-09-18T02:36:22.870679Z" } }, "done": true, "response": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1.Feature", "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/features/FEATURE_NAME" } }
更新在线存储区的标签
使用以下示例可更新现有在线存储区实例的标签。
REST
如需更新现有 FeatureOnlineStore
资源的标签,请使用 featureOnlineStores.patch 方法发送 PATCH
请求。
在使用任何请求数据之前,请先进行以下替换:
- REGION_ID:在线存储区所在的区域,例如
us-central1
。 - PROJECT_ID:您的项目 ID。
- FEATUREONLINESTORE_NAME:您要更新的在线存储区的名称。
- LABELS_JSON:要附加到在线存储区作为键值对的 JSON 格式的标签。
例如:
{"label1_key": "label1_value", "label2_key": "label2_value", ...}
HTTP 方法和网址:
PATCH https://REGION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores?feature_online_store_id=FEATUREONLINESTORE_NAME
请求 JSON 正文:
{ "labels": LABELS_JSON }
如需发送请求,请选择以下方式之一:
curl
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://REGION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores?feature_online_store_id=FEATUREONLINESTORE_NAME"
PowerShell
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method PATCH `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://REGION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores?feature_online_store_id=FEATUREONLINESTORE_NAME" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1.CreateFeatureOnlineStoreOperationMetadata", "genericMetadata": { "createTime": "2023-09-18T17:49:23.847496Z", "updateTime": "2023-09-18T17:49:23.847496Z" } }, "done": true, "response": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1.FeatureView", "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME" } }
更新特征视图的标签
使用以下示例可更新现有特征视图的标签。
REST
如需更新现有 FeatureView
资源的标签,请使用 featureViews.patch 方法发送 PATCH
请求。
在使用任何请求数据之前,请先进行以下替换:
- LOCATION_ID:在线存储区所在的区域,例如
us-central1
。 - PROJECT_ID:您的项目 ID。
- FEATUREONLINESTORE_NAME:包含特征视图的在线存储区的名称。
- FEATUREVIEW_NAME:要更新的特征视图的名称。
- LABELS_JSON:要附加到特征视图作为键值对的 JSON 格式的标签。
例如:
{"label1_key": "label1_value", "label2_key": "label2_value", ...}
HTTP 方法和网址:
PATCH https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME
请求 JSON 正文:
{ "labels": LABELS_JSON }
如需发送请求,请选择以下方式之一:
curl
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME"
PowerShell
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method PATCH `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1.UpdateFeatureViewOperationMetadata", "genericMetadata": { "createTime": "2023-09-15T04:53:34.832192Z", "updateTime": "2023-09-15T04:53:34.832192Z" } }, "done": true, "response": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1.FeatureView", "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME" } }