Sdk feature store ver1 (#790)

* Added condition to create Featurestore if it doesn't exist

* Ran Linter Test

* Made changes mentioned in review

* Ran Linter Test

* Attached uuid to featurestore_id to avoid error while creating featurestore with existing name

* Ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
This commit is contained in:
SamyuktaDR
2022-09-01 08:57:16 -07:00
committed by GitHub
co-authored by Andrew Ferlitsch
parent 55e37f795c
commit 6cac60f74a
@@ -29,6 +29,8 @@
"id": "JAPoU8Sm5E6e"
},
"source": [
"# Online and Batch predictions using Vertex AI Feature Store\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/feature_store/sdk-feature-store.ipynb\">\n",
@@ -51,19 +53,22 @@
{
"cell_type": "markdown",
"metadata": {
"id": "tvgnzT1CKxrO"
"id": "c4aaea3bab5e"
},
"source": [
"## Overview\n",
"\n",
"This notebook introduces Vertex AI Feature Store, a managed cloud service for machine learning engineers and data scientists to store, serve, manage and share machine learning features at a large scale.\n",
"\n",
"This notebook assumes that you understand basic Google Cloud concepts such as [Project](https://cloud.google.com/storage/docs/projects), [Storage](https://cloud.google.com/storage) and [Vertex AI](https://cloud.google.com/vertex-ai/docs). Some machine learning knowledge is also helpful but not required.\n",
"\n",
"### Dataset\n",
"\n",
"This notebook uses a movie recommendation dataset as an example throughout all the sessions. The task is to train a model to predict if a user is going to watch a movie and serve this model online. \n",
"\n",
"This notebook assumes that you understand basic Google Cloud concepts such as [Project](https://cloud.google.com/storage/docs/projects), [Storage](https://cloud.google.com/storage) and [Vertex AI](https://cloud.google.com/vertex-ai/docs). Some machine learning knowledge is also helpful but not required.\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "71779c8088bf"
},
"source": [
"### Objective\n",
"\n",
"In this notebook, you will learn how to use `Vertex AI Feature Store` to import feature data, and to access the feature data for both online serving and offline tasks, such as training.\n",
@@ -79,8 +84,26 @@
"- Create featurestore, entity type, and feature resources.\n",
"- Import feature data into `Vertex AI Feature Store` resource.\n",
"- Serve online prediction requests using the imported features.\n",
"- Access imported features in offline jobs, such as training jobs.\n",
"- Access imported features in offline jobs, such as training jobs."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "55e01a856f57"
},
"source": [
"### Dataset\n",
"\n",
"This notebook uses a movie recommendation dataset as an example throughout all the sessions. The task is to train a model to predict if a user is going to watch a movie and serve this model online."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "tvgnzT1CKxrO"
},
"source": [
"### Costs \n",
"\n",
"This tutorial uses billable components of Google Cloud:\n",
@@ -262,7 +285,15 @@
},
"outputs": [],
"source": [
"PROJECT_ID = \"[your-project-id]\" # @param {type:\"string\"}"
"import os\n",
"\n",
"PROJECT_ID = \"\"\n",
"\n",
"# Get your Google Cloud project ID from gcloud\n",
"if not os.getenv(\"IS_TESTING\"):\n",
" shell_output = !gcloud config list --format 'value(core.project)' 2>/dev/null\n",
" PROJECT_ID = shell_output[0]\n",
" print(\"Project ID: \", PROJECT_ID)"
]
},
{
@@ -275,10 +306,7 @@
"source": [
"if PROJECT_ID == \"\" or PROJECT_ID is None:\n",
" PROJECT_ID = \"[your-project-id]\" # @param {type:\"string\"}\n",
" # Get your GCP project id from gcloud\n",
" shell_output = ! gcloud config list --format 'value(core.project)' 2>/dev/null\n",
" PROJECT_ID = shell_output[0]\n",
" print(\"Project ID:\", PROJECT_ID)"
"print(\"Project ID: \", PROJECT_ID)"
]
},
{
@@ -320,7 +348,9 @@
},
"outputs": [],
"source": [
"REGION = \"us-central1\" # @param {type: \"string\"}"
"REGION = \"[your-region]\" # @param {type:\"string\"}\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
@@ -329,9 +359,9 @@
"id": "timestamp"
},
"source": [
"#### Timestamp\n",
"#### UUID\n",
"\n",
"If you are in a live tutorial session, you might be using a shared test account or project. To avoid name collisions between users on resources created, you create a timestamp for each instance session, and append the timestamp onto the name of resources you create in this tutorial."
"If you are in a live tutorial session, you might be using a shared test account or project. To avoid name collisions between users on resources created, you create a uuid for each instance session, and append it onto the name of resources you create in this tutorial."
]
},
{
@@ -342,9 +372,16 @@
},
"outputs": [],
"source": [
"from datetime import datetime\n",
"import random\n",
"import string\n",
"\n",
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
"\n",
"# Generate a uuid of a specifed length(default=8)\n",
"def generate_uuid(length: int = 8) -> str:\n",
" return \"\".join(random.choices(string.ascii_lowercase + string.digits, k=length))\n",
"\n",
"\n",
"UUID = generate_uuid()"
]
},
{
@@ -441,7 +478,7 @@
"source": [
"from google.cloud.aiplatform import Feature, Featurestore\n",
"\n",
"FEATURESTORE_ID = \"movie_prediction\"\n",
"FEATURESTORE_ID = \"movie_prediction\" + UUID\n",
"INPUT_CSV_FILE = \"gs://cloud-samples-data-us-central1/vertex-ai/feature-store/datasets/movie_prediction.csv\"\n",
"ONLINE_STORE_FIXED_NODE_COUNT = 1"
]