mirror of
https://github.com/GoogleCloudPlatform/vertex-ai-samples.git
synced 2026-09-26 14:42:04 +00:00
Optimized colab changes for PSC ga (#3514)
This commit is contained in:
+16
-81
@@ -296,8 +296,6 @@
|
||||
"from google.cloud.aiplatform_v1beta1.types import \\\n",
|
||||
" feature_group as feature_group_pb2\n",
|
||||
"from google.cloud.aiplatform_v1beta1.types import \\\n",
|
||||
" feature_online_store as feature_online_store_pb2\n",
|
||||
"from google.cloud.aiplatform_v1beta1.types import \\\n",
|
||||
" feature_online_store_admin_service as \\\n",
|
||||
" feature_online_store_admin_service_pb2\n",
|
||||
"from google.cloud.aiplatform_v1beta1.types import \\\n",
|
||||
@@ -307,8 +305,6 @@
|
||||
"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 \\\n",
|
||||
" service_networking as service_networking_pb2\n",
|
||||
"from vertexai.resources.preview import (FeatureOnlineStore, FeatureView,\n",
|
||||
" FeatureViewBigQuerySource)"
|
||||
]
|
||||
@@ -544,47 +540,11 @@
|
||||
"FEATURE_ONLINE_STORE_ID = \"thelook_opt_private_unique\" # @param {type:\"string\"}\n",
|
||||
"ALLOW_LISTED_PROJECT = f\"{PROJECT_ID}\" # @param {type:\"string\"}\n",
|
||||
"\n",
|
||||
"online_store_config = feature_online_store_pb2.FeatureOnlineStore(\n",
|
||||
" optimized=feature_online_store_pb2.FeatureOnlineStore.Optimized(),\n",
|
||||
" dedicated_serving_endpoint=feature_online_store_pb2.FeatureOnlineStore.DedicatedServingEndpoint(\n",
|
||||
" private_service_connect_config=service_networking_pb2.PrivateServiceConnectConfig(\n",
|
||||
" enable_private_service_connect=True,\n",
|
||||
" project_allowlist=[\n",
|
||||
" ALLOW_LISTED_PROJECT,\n",
|
||||
" ],\n",
|
||||
" )\n",
|
||||
" ),\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"create_store_lro = admin_client.create_feature_online_store(\n",
|
||||
" feature_online_store_admin_service_pb2.CreateFeatureOnlineStoreRequest(\n",
|
||||
" parent=f\"projects/{PROJECT_ID}/locations/{LOCATION}\",\n",
|
||||
" feature_online_store_id=FEATURE_ONLINE_STORE_ID,\n",
|
||||
" feature_online_store=online_store_config,\n",
|
||||
" )\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"print(create_store_lro.result())"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "34yy_HOfR3Ia"
|
||||
},
|
||||
"source": [
|
||||
"#### Use SDK to get FeatureOnlineStore"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "MutKQwGlR43o"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"FeatureOnlineStore(FEATURE_ONLINE_STORE_ID)"
|
||||
"my_fos = FeatureOnlineStore.create_optimized_store(\n",
|
||||
" FEATURE_ONLINE_STORE_ID,\n",
|
||||
" True,\n",
|
||||
" [ALLOW_LISTED_PROJECT],\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -1150,43 +1110,18 @@
|
||||
"source": [
|
||||
"# # 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",
|
||||
"# from google.cloud.aiplatform_v1beta1 import FeatureOnlineStoreServiceClient\n",
|
||||
"# import grpc\n",
|
||||
"# from vertexai.resources.preview.feature_store import utils as fs_utils\n",
|
||||
"# # Depends on the FeatureView you created, the FEATURE_VIEW_ID here can be different\n",
|
||||
"# data = (\n",
|
||||
"# FeatureView(name=FEATURE_VIEW_ID, feature_online_store_id=FEATURE_ONLINE_STORE_ID)\n",
|
||||
"# .read(key=[\"13842\"],\n",
|
||||
"# connection_options=fs_utils.ConnectionOptions(\n",
|
||||
"# host=\"{endpoint_ip}\",\n",
|
||||
"# transport=fs_utils.ConnectionOptions.InsecureGrpcChannel()))\n",
|
||||
"# .to_dict()\n",
|
||||
"# )\n",
|
||||
"\n",
|
||||
"# data_client = FeatureOnlineStoreServiceClient(\n",
|
||||
"# transport = FeatureOnlineStoreServiceGrpcTransport(\n",
|
||||
"# # Add the IP address of the Endpoint you just created.\n",
|
||||
"# channel = grpc.insecure_channel(\"{endpoint_ip}:10002\")\n",
|
||||
"# )\n",
|
||||
"# )"
|
||||
]
|
||||
},
|
||||
{
|
||||
"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."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "3cbk1VEh5dQY"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# from google.cloud.aiplatform_v1beta1.types import \\\n",
|
||||
"# feature_online_store_service as feature_online_store_service_pb2\n",
|
||||
"# data_client.fetch_feature_values(\n",
|
||||
"# request=feature_online_store_service_pb2.FetchFeatureValuesRequest(\n",
|
||||
"# feature_view=f\"projects/{PROJECT_ID}/locations/{LOCATION}/featureOnlineStores/{FEATURE_ONLINE_STORE_ID}/featureViews/{FEATURE_VIEW_ID}\",\n",
|
||||
"# id=\"16050\"))"
|
||||
"# print(data)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user