了解如何创建、列出和删除实体类型。
创建实体类型
创建实体类型,以便可以创建其相关特征。
网页界面
REST 和命令行
如需创建实体类型,请使用 featurestores.entityTypes.create 方法发送 POST 请求。
在使用任何请求数据之前,请先进行以下替换:
- LOCATION:特征存储区所在的区域,例如
us-central1
。 - PROJECT:您的项目 ID 或项目编号。
- FEATURESTORE_ID:特征存储区的 ID。
- ENTITY_TYPE_ID:实体类型的 ID。
- DESCRIPTION:实体类型的说明。
HTTP 方法和网址:
POST https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/featurestores/FEATURESTORE_ID/entityTypes?entityTypeId=ENTITY_TYPE_ID
请求 JSON 正文:
{ "description": "DESCRIPTION" }
如需发送请求,请选择以下方式之一:
curl
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
curl -X POST \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/featurestores/FEATURESTORE_ID/entityTypes?entityTypeId=ENTITY_TYPE_ID"
PowerShell
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
$cred = gcloud auth application-default print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/featurestores/FEATURESTORE_ID/entityTypes?entityTypeId=ENTITY_TYPE_ID" | Select-Object -Expand Content
您应该会看到类似如下所示的输出。您可以使用响应中的 OPERATION_ID 来获取操作的状态。
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION/featurestores/FEATURESTORE_ID/entityTypes/bikes/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1.CreateEntityTypeOperationMetadata", "genericMetadata": { "createTime": "2021-03-02T00:04:13.039166Z", "updateTime": "2021-03-02T00:04:13.039166Z" } } }
Python
如需了解如何安装和使用 Vertex AI 客户端库,请参阅 Vertex AI 客户端库。如需了解详情,请参阅 Vertex AI Python API 参考文档。
其他语言
您可以安装并使用以下 Vertex AI 客户端库来调用 Vertex AI API。Cloud 客户端库使用每种受支持语言的自然规范和样式,为开发者带来优化的体验。
列出实体类型
列出特征存储区中的所有实体类型。
网页界面
- 在 Google Cloud Console 的 Vertex AI 部分,转到特征页面。
- 从区域下拉列表中选择一个区域。
- 在特征表中,查看实体类型列,以了解您的项目中所选区域的实体类型。
REST 和命令行
如需列出实体类型,请使用 featurestores.entityTypes.list 方法发送 GET 请求。
在使用任何请求数据之前,请先进行以下替换:
- LOCATION:特征存储区所在的区域,例如
us-central1
。 - PROJECT:您的项目 ID 或项目编号。
- FEATURESTORE_ID:特征存储区的 ID。
HTTP 方法和网址:
GET https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/featurestores/FEATURESTORE_ID/entityTypes
如需发送请求,请选择以下方式之一:
curl
执行以下命令:
curl -X GET \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
"https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/featurestores/FEATURESTORE_ID/entityTypes"
PowerShell
执行以下命令:
$cred = gcloud auth application-default print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/featurestores/FEATURESTORE_ID/entityTypes" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{ "entityTypes": [ { "name": "projects/PROJECT_NUMBER/locations/LOCATION/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID_1", "description": "ENTITY_TYPE_DESCRIPTION", "createTime": "2021-02-25T01:20:43.082628Z", "updateTime": "2021-02-25T01:20:43.082628Z", "etag": "AMEw9yOBqKIdbBGZcxdKLrlZJAf9eTO2DEzcE81YDKA2LymDMFB8ucRbmKwKo2KnvOg=" }, { "name": "projects/PROJECT_NUMBER/locations/LOCATION/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID_2", "description": "ENTITY_TYPE_DESCRIPTION", "createTime": "2021-02-25T01:34:26.198628Z", "updateTime": "2021-02-25T01:34:26.198628Z", "etag": "AMEw9yNuv-ILYG8VLLm1lgIKc7asGIAVFErjvH2Cyc_wIQm7d6DL4ZGv59cwZmxTumU=" } ] }
其他语言
您可以安装并使用以下 Vertex AI 客户端库来调用 Vertex AI API。Cloud 客户端库使用每种受支持语言的自然规范和样式,为开发者带来优化的体验。
删除实体类型
删除实体类型。如果您使用 Cloud Console,Vertex AI Feature Store 会删除实体类型及其所有内容。如果您使用 API,请启用 force
查询参数删除实体类型及其所有内容。
网页界面
- 在 Google Cloud Console 的 Vertex AI 部分,转到特征页面。
- 从区域下拉列表中选择一个区域。
- 在特征表中,查看实体类型列并找到要删除的实体类型。
- 点击实体类型的名称。
- 在操作栏中,点击删除。
- 点击确认以删除实体类型。
REST 和命令行
如需删除实体类型,请使用 featurestores.entityTypes.delete 方法发送 DELETE 请求。
在使用任何请求数据之前,请先进行以下替换:
- LOCATION:特征存储区所在的区域,例如
us-central1
。 - PROJECT:您的项目 ID 或项目编号。
- FEATURESTORE_ID:特征存储区的 ID。
- ENTITY_TYPE_ID:实体类型的 ID。
- BOOLEAN:是否删除实体类型(即使该实体包含特征)。
force
查询参数是可选的,默认为false
。
HTTP 方法和网址:
DELETE https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID?force=BOOLEAN
如需发送请求,请选择以下方式之一:
curl
执行以下命令:
curl -X DELETE \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
"https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID?force=BOOLEAN"
PowerShell
执行以下命令:
$cred = gcloud auth application-default print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID?force=BOOLEAN" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION/featurestores/FEATURESTORE_ID/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1.DeleteOperationMetadata", "genericMetadata": { "createTime": "2021-02-26T17:32:56.008325Z", "updateTime": "2021-02-26T17:32:56.008325Z" } }, "done": true, "response": { "@type": "type.googleapis.com/google.protobuf.Empty" } }
其他语言
您可以安装并使用以下 Vertex AI 客户端库来调用 Vertex AI API。Cloud 客户端库使用每种受支持语言的自然规范和样式,为开发者带来优化的体验。
后续步骤
- 了解如何管理特征。
- 了解如何监控一段时间内提取的特征值。
- 查看 Vertex AI Feature Store 实体类型配额。
- 排查 Vertex AI Feature Store 常见问题。