mirror of
https://github.com/GoogleCloudPlatform/vertex-ai-samples.git
synced 2026-09-26 14:42:04 +00:00
Rephrase optimized notebook to address previous comment (#2473)
* Rephrase optimized notebook * Update format issue and change region * Update format issue and change region2 * Fix import format * Apply format * Change region
This commit is contained in:
+106
-105
@@ -273,7 +273,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"REGION = \"us-west1\" # @param {type: \"string\"}"
|
||||
"REGION = \"us-central1\" # @param {type: \"string\"}"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -386,7 +386,8 @@
|
||||
"from google.cloud.aiplatform_v1beta1.types import \\\n",
|
||||
" featurestore_service as featurestore_service_pb2\n",
|
||||
"from google.cloud.aiplatform_v1beta1.types import io as io_pb2\n",
|
||||
"from google.cloud.aiplatform_v1beta1.types import service_networking as service_networking_pb2"
|
||||
"from google.cloud.aiplatform_v1beta1.types import \\\n",
|
||||
" service_networking as service_networking_pb2"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -624,19 +625,24 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "Vwe_bEgr_Wph"
|
||||
},
|
||||
"source": [
|
||||
"#### Option 1: Create an online store instance for Optimized online serving with private endpoint\n",
|
||||
"\n",
|
||||
"Create a `FeatureOnlineStore` instance for Optimized online serving."
|
||||
],
|
||||
"metadata": {
|
||||
"id": "Vwe_bEgr_Wph"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "gOjA9YhJ_jNM"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"FEATURE_ONLINE_STORE_ID = \"the_look_demo_optimized_private\" #@param {type:\"string\"}\n",
|
||||
"FEATURE_ONLINE_STORE_ID = \"the_look_demo_optimized_private\" # @param {type:\"string\"}\n",
|
||||
"\n",
|
||||
"online_store_config = feature_online_store_pb2.FeatureOnlineStore(\n",
|
||||
" optimized=feature_online_store_pb2.FeatureOnlineStore.Optimized(),\n",
|
||||
@@ -652,16 +658,14 @@
|
||||
" feature_online_store_admin_service_pb2.CreateFeatureOnlineStoreRequest(\n",
|
||||
" parent=f\"projects/{PROJECT_ID}/locations/{REGION}\",\n",
|
||||
" feature_online_store_id=FEATURE_ONLINE_STORE_ID,\n",
|
||||
" feature_online_store = online_store_config))"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "gOjA9YhJ_jNM"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
" feature_online_store=online_store_config))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "60i5bYrgB0xE"
|
||||
},
|
||||
"source": [
|
||||
"#### Option 2: Create an online store instance for Optimized online serving with public endpoint\n",
|
||||
"\n",
|
||||
@@ -670,15 +674,17 @@
|
||||
"Create a `FeatureOnlineStore` instance for Optimized online serving.\n",
|
||||
"\n",
|
||||
"> **Note:** When you create a `FeatureOnlineStore` for Optimized online serving with public endpoint in a project for the first time, Vertex AI Feature Store requires some additional time for certificate creation."
|
||||
],
|
||||
"metadata": {
|
||||
"id": "60i5bYrgB0xE"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "eOPc2LBmCRFF"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"FEATURE_ONLINE_STORE_ID = \"the_look_demo_optimized_public\" #@param {type:\"string\"}\n",
|
||||
"FEATURE_ONLINE_STORE_ID = \"the_look_demo_optimized_public\" # @param {type:\"string\"}\n",
|
||||
"\n",
|
||||
"online_store_config = feature_online_store_pb2.FeatureOnlineStore(\n",
|
||||
" optimized=feature_online_store_pb2.FeatureOnlineStore.Optimized()\n",
|
||||
@@ -689,13 +695,8 @@
|
||||
" feature_online_store_admin_service_pb2.CreateFeatureOnlineStoreRequest(\n",
|
||||
" parent=f\"projects/{PROJECT_ID}/locations/{REGION}\",\n",
|
||||
" feature_online_store_id=FEATURE_ONLINE_STORE_ID,\n",
|
||||
" feature_online_store = online_store_config))"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "eOPc2LBmCRFF"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
" feature_online_store=online_store_config))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
@@ -1132,41 +1133,44 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "8CE6NFChMEbK"
|
||||
},
|
||||
"source": [
|
||||
"#### Option 1: Optimized online serving with private endpoint\n",
|
||||
"\n",
|
||||
"You'll need to connect to private endpoint over gRPC. Follow these instructions to set up [Private Service Connect](https://cloud.google.com/vpc/docs/private-service-connect)."
|
||||
],
|
||||
"metadata": {
|
||||
"id": "8CE6NFChMEbK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "TvmMyjD34y54"
|
||||
},
|
||||
"source": [
|
||||
"**Get Private Service Connect information**\n",
|
||||
"\n",
|
||||
"Retrieve the information to set up Private Service Connect from your `FeatureOnlineStore` instance."
|
||||
],
|
||||
"metadata": {
|
||||
"id": "TvmMyjD34y54"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "sIoIFvIcNE71"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Get Optimized online store\n",
|
||||
"admin_client.get_feature_online_store(\n",
|
||||
" name=f\"projects/{PROJECT_ID}/locations/{REGION}/featureOnlineStores/{FEATURE_ONLINE_STORE_ID}\")"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "sIoIFvIcNE71"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "kk7ec2RDN597"
|
||||
},
|
||||
"source": [
|
||||
"You'll see output similar to the following:\n",
|
||||
"\n",
|
||||
@@ -1180,13 +1184,13 @@
|
||||
"}\n",
|
||||
"optimized {}\n",
|
||||
"```"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "kk7ec2RDN597"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "DFp16C_X5HT0"
|
||||
},
|
||||
"source": [
|
||||
"* `your_allowlisted_project` represents the name of your allowlisted project\n",
|
||||
"\n",
|
||||
@@ -1195,13 +1199,13 @@
|
||||
"where you created your `FeatureOnlineStore` instance.\n",
|
||||
"\n",
|
||||
"* `service_attachment_string` represents the target service that you'll need to specify while [adding Private Service Connect to your network configuration]()."
|
||||
],
|
||||
"metadata": {
|
||||
"id": "DFp16C_X5HT0"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "4lKdzqzi5OnI"
|
||||
},
|
||||
"source": [
|
||||
"**Add Private Service Connect to your network configuration:**\n",
|
||||
"\n",
|
||||
@@ -1219,15 +1223,17 @@
|
||||
"After the connection is successfully added, it appears in the **Connected endpoints** tab on the **Private Service Connect** page.\n",
|
||||
"\n",
|
||||
"Retrieve the IP address of the new connection from the **IP addresses** column and replace `{endpoint_ip}` before running the following code."
|
||||
],
|
||||
"metadata": {
|
||||
"id": "4lKdzqzi5OnI"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "0hnVZkhX5YEh"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Uncomment below 2 parts after your PSC setup is completed and replace {endpoint_ip} with your selected one.\n",
|
||||
"# Uncomment the following code blocks after your PSC setup is complete. Replace {endpoint_ip} with the IP of the new connection.\n",
|
||||
"\n",
|
||||
"# from google.cloud.aiplatform_v1beta1.services.feature_online_store_service.transports.grpc import FeatureOnlineStoreServiceGrpcTransport\n",
|
||||
"# import grpc\n",
|
||||
@@ -1238,74 +1244,72 @@
|
||||
"# channel = grpc.insecure_channel(\"{endpoint_ip}:10002\")\n",
|
||||
"# )\n",
|
||||
"# )"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "0hnVZkhX5YEh"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "OPJNX1Uv5bEu"
|
||||
},
|
||||
"source": [
|
||||
"**Retrieve your features**\n",
|
||||
"\n",
|
||||
"After you've added the private connection endpoint, you can retrieve your features."
|
||||
],
|
||||
"metadata": {
|
||||
"id": "OPJNX1Uv5bEu"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "3cbk1VEh5dQY"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# data_client.fetch_feature_values(\n",
|
||||
"# feature_view=f\"projects/{PROJECT_ID}/locations/{REGION}/featureOnlineStores/{FEATURE_ONLINE_STORE_ID}/featureViews/{FEATURE_VIEW_ID}\",\n",
|
||||
"# id=\"16050\")"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "3cbk1VEh5dQY"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "u3lTTKwRO5_B"
|
||||
},
|
||||
"source": [
|
||||
"#### Option 2: Optimized online serving with public endpoint\n",
|
||||
"\n",
|
||||
"> **Note:** If you've set up and started Optimized online serving with private endpoint, skip this section and go to [Clean up](#scrollTo=OR1ve2OyyiKq)."
|
||||
],
|
||||
"metadata": {
|
||||
"id": "u3lTTKwRO5_B"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "qnrsIDyl5v3W"
|
||||
},
|
||||
"source": [
|
||||
"**Get Public Endpoint Domain Name information**\n",
|
||||
"\n",
|
||||
"Retrieve the information to connect to your `FeatureOnlineStore` instance."
|
||||
],
|
||||
"metadata": {
|
||||
"id": "qnrsIDyl5v3W"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "48rVCKQX5-lA"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Get Optimized online store\n",
|
||||
"response = admin_client.get_feature_online_store(\n",
|
||||
" name=f\"projects/{PROJECT_ID}/locations/{REGION}/featureOnlineStores/{FEATURE_ONLINE_STORE_ID}\")"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "48rVCKQX5-lA"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "uOed1KFe6JoT"
|
||||
},
|
||||
"source": [
|
||||
"You'll see output similar to the following:\n",
|
||||
"\n",
|
||||
@@ -1316,35 +1320,37 @@
|
||||
"```\n",
|
||||
"\n",
|
||||
"* `public_endpoint_domain_name_string` represents the target service domain name"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "uOed1KFe6JoT"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "c3pJS3AZbIsQ"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"data_client = FeatureOnlineStoreServiceClient(\n",
|
||||
" client_options={\"api_endpoint\": response.dedicated_serving_endpoint.public_endpoint_domain_name}\n",
|
||||
")"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "c3pJS3AZbIsQ"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"You can specify the response format using `FetchFeatureValuesRequest.Format`. If you don't specify a format, then the format is set to `KEY_VALUE`, by default. `PROTO_STRUCT` is another supported format."
|
||||
],
|
||||
"metadata": {
|
||||
"id": "o6TMOrx7bQNO"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"You can specify the response format using `FetchFeatureValuesRequest.Format`. If you don't specify a format, then the format is set to `KEY_VALUE`, by default. `PROTO_STRUCT` is another supported format."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "uHkuzmMlbWnm"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"data_client.fetch_feature_values(\n",
|
||||
" request=feature_online_store_service_pb2.FetchFeatureValuesRequest(\n",
|
||||
@@ -1353,12 +1359,7 @@
|
||||
" format=feature_online_store_service_pb2.FetchFeatureValuesRequest.Format.PROTO_STRUCT,\n",
|
||||
" )\n",
|
||||
")"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "uHkuzmMlbWnm"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
@@ -1412,12 +1413,12 @@
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": [],
|
||||
"collapsed_sections": [
|
||||
"2PwjwWbxs7SR",
|
||||
"igOmzHxx1C0X",
|
||||
"tYrwH7OOc1CY"
|
||||
],
|
||||
"name": "online_feature_serving_and_fetching_bigquery_data_with_feature_store_optimized.ipynb",
|
||||
"toc_visible": true
|
||||
},
|
||||
"kernelspec": {
|
||||
@@ -1427,4 +1428,4 @@
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user