Adds the updated telecom-subscriber-churn-prediction notebook to official and removes from community (#506)

* updates and adds the telecom-subscriber-churn-prediction notebook to official and removes from the community

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
This commit is contained in:
Krishna Chaitanya Movva
2022-06-05 12:53:21 -07:00
committed by GitHub
co-authored by Andrew Ferlitsch
parent 1aaa833153
commit dbf19acde4
@@ -1,12 +1,56 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "18ebbd838e32"
},
"outputs": [],
"source": [
"# Copyright 2022 Google LLC\n",
"#\n",
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
"# You may obtain a copy of the License at\n",
"#\n",
"# https://www.apache.org/licenses/LICENSE-2.0\n",
"#\n",
"# Unless required by applicable law or agreed to in writing, software\n",
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
"# See the License for the specific language governing permissions and\n",
"# limitations under the License."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "64f7165bd1ac"
},
"source": [
"# Telecom subscriber churn prediction on Vertex AI"
"# Telecom subscriber churn prediction on Vertex AI\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/workbench/subscriber_churn_prediction/telecom-subscriber-churn-prediction.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
" View on GitHub\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/workbench/subscriber_churn_prediction/telecom-subscriber-churn-prediction.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\\\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/workbench/subscriber_churn_prediction/telecom-subscriber-churn-prediction.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>\n",
"<br/><br/><br/>"
]
},
{
@@ -39,9 +83,7 @@
"## Overview\n",
"<a name=\"section-1\"></a>\n",
"\n",
"This example demonstrates building a subscriber churn prediction model on a [telecom customer churn dataset](https://www.kaggle.com/c/customer-churn-prediction-2020/overview). The generated churn model is further deployed to Vertex AI Endpoints and explanations are generated using the Explainable AI feature of Vertex AI. \n",
"\n",
"*Note: This notebook file was designed to run in a [Vertex AI Workbench managed notebooks](https://cloud.google.com/vertex-ai/docs/workbench/managed/create-instance) instance using the `Python (Local)` kernel. Some components of this notebook may not work in other notebook environments.*"
"This example demonstrates building a subscriber churn prediction model on a [telecom customer churn dataset](https://www.kaggle.com/c/customer-churn-prediction-2020/overview). The generated churn model is further deployed to Vertex AI Endpoints and explanations are generated using the Explainable AI feature of Vertex AI. "
]
},
{
@@ -53,7 +95,7 @@
"## Dataset\n",
"<a name=\"section-2\"></a>\n",
"\n",
"The dataset used in this tutorial is publicly available at Kaggle. See [Customer Churn Prediction 2020](https://www.kaggle.com/c/customer-churn-prediction-2020/data). "
"The dataset used in this tutorial is Telecom-Customer Churn dataset publicly available on Kaggle. See [Customer Churn Prediction 2020](https://www.kaggle.com/c/customer-churn-prediction-2020/data). This dataset is used to build and deploy a churn prediction model using Vertex AI in this notebook."
]
},
{
@@ -65,7 +107,7 @@
"## Objective\n",
"<a name=\"section-3\"></a>\n",
"\n",
"This tutorial shows you how to do exploratory data analysis, preprocess data, and train a churn prediction model on a tabular churn dataset. The steps include the following:\n",
"This tutorial shows you how to do exploratory data analysis, preprocess data, train, deploy and get predictions from a churn prediction model on a tabular churn dataset. The objectives of this tutorial are as follows:\n",
"\n",
"- Load data from a Cloud Storage path\n",
"- Perform exploratory data analysis (EDA)\n",
@@ -107,7 +149,9 @@
"id": "44b8ae8e2d19"
},
"source": [
"## Installation"
"## Installation\n",
"\n",
"Install the following packages to run this notebook."
]
},
{
@@ -129,17 +173,6 @@
" USER_FLAG = \"--user\""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "606337930991"
},
"source": [
"Install the latest version of the Vertex AI client library.\n",
"\n",
"Run the following command in your virtual environment to install the Vertex SDK for Python:"
]
},
{
"cell_type": "code",
"execution_count": null,
@@ -148,67 +181,43 @@
},
"outputs": [],
"source": [
"! pip install {USER_FLAG} --upgrade google-cloud-aiplatform"
"! pip install {USER_FLAG} --upgrade google-cloud-aiplatform \\\n",
" google-cloud-storage \\\n",
" category_encoders \\\n",
" seaborn \\\n",
" sklearn \\\n",
" pandas \\\n",
" fsspec \\\n",
" gcsfs -q"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "e67139e68463"
"id": "b24902cde81b"
},
"source": [
"Install the Cloud Storage library:"
"### Restart the kernel\n",
"\n",
"Once you've installed the additional packages, you need to restart the notebook kernel so it can find the packages."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "2ad918f94f5d"
"id": "c61d171395d7"
},
"outputs": [],
"source": [
"! pip install {USER_FLAG} --upgrade google-cloud-storage"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "eb0c1e24a8f0"
},
"source": [
"Install the `category_encoders` library:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "deb95a7f2104"
},
"outputs": [],
"source": [
"! pip install --upgrade category_encoders"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "184560c1b742"
},
"source": [
"Install the `seaborn` library for the EDA step. If a Vertex AI Workbench managed notebooks instance is being used, this step is optional as the library is already available in the `Python (Local)` kernel."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "0d99cdcdc470"
},
"outputs": [],
"source": [
"! pip install --upgrade seaborn"
"import os\n",
"\n",
"if not os.getenv(\"IS_TESTING\"):\n",
" # Automatically restart kernel after installs\n",
" import IPython\n",
"\n",
" app = IPython.Application.instance()\n",
" app.kernel.do_shutdown(True)"
]
},
{
@@ -243,7 +252,7 @@
"id": "96ff17f75e21"
},
"source": [
"#### Set your project ID\n",
"### Set your project ID\n",
"\n",
"**If you don't know your project ID**, you may be able to get your project ID using `gcloud`."
]
@@ -256,11 +265,13 @@
},
"outputs": [],
"source": [
"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",
" shell_output = !gcloud config list --format 'value(core.project)' 2>/dev/null\n",
" PROJECT_ID = shell_output[0]\n",
" print(\"Project ID: \", PROJECT_ID)"
]
@@ -286,13 +297,58 @@
" PROJECT_ID = \"[your-project-id]\" # @param {type:\"string\"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "f2e3c0f2cbfb"
},
"outputs": [],
"source": [
"! gcloud config set project $PROJECT_ID"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "60d535f443ac"
},
"source": [
"### Region\n",
"\n",
"You can also change the `REGION` variable, which is used for operations\n",
"throughout the rest of this notebook. Below are regions supported for Vertex AI. We recommend that you choose the region closest to you.\n",
"\n",
"- Americas: `us-central1`\n",
"- Europe: `europe-west4`\n",
"- Asia Pacific: `asia-east1`\n",
"\n",
"You may not use a multi-regional bucket for training with Vertex AI. Not all regions provide support for all Vertex AI services.\n",
"\n",
"Learn more about [Vertex AI regions](https://cloud.google.com/vertex-ai/docs/general/locations)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "3aaadaaf9b30"
},
"outputs": [],
"source": [
"REGION = \"[your-region]\" # @param {type: \"string\"}\n",
"\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "e663bd062c6f"
},
"source": [
"#### Timestamp\n",
"### Timestamp\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 it onto the name of resources you create in this tutorial."
]
@@ -310,6 +366,63 @@
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "3ffa6b6c7cdb"
},
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Google Cloud Notebooks**, your environment is already authenticated. Skip this step.\n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions when prompted to authenticate your account via oAuth.\n",
"\n",
"**Otherwise**, follow these steps:\n",
"\n",
"In the Cloud Console, go to the [Create service account key](https://console.cloud.google.com/apis/credentials/serviceaccountkey) page.\n",
"\n",
"1. **Click Create service account**.\n",
"\n",
"2. In the **Service account name** field, enter a name, and click **Create**.\n",
"\n",
"3. In the **Grant this service account access to project** section, click the Role drop-down list. Type \"Vertex AI\" into the filter box, and select **Vertex AI Administrator**. Type \"Storage Object Admin\" into the filter box, and select **Storage Object Admin**.\n",
"\n",
"4. Click Create. A JSON file that contains your key downloads to your local environment.\n",
"\n",
"5. Enter the path to your service account key as the GOOGLE_APPLICATION_CREDENTIALS variable in the cell below and run the cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "2b72272258fc"
},
"outputs": [],
"source": [
"# If you are running this notebook in Colab, run this cell and follow the\n",
"# instructions to authenticate your GCP account. This provides access to your\n",
"# Cloud Storage bucket and lets you submit training jobs and prediction\n",
"# requests.\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"# If on Google Cloud Notebook, then don't execute this code\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\"):\n",
" if \"google.colab\" in sys.modules:\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
"\n",
" # If you are running this notebook locally, replace the string below with the\n",
" # path to your service account key and run this cell to authenticate your GCP\n",
" # account.\n",
" elif not os.getenv(\"IS_TESTING\"):\n",
" %env GOOGLE_APPLICATION_CREDENTIALS ''"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -327,12 +440,7 @@
"online predictions.\n",
"\n",
"Set the name of your Cloud Storage bucket below. It must be unique across all\n",
"Cloud Storage buckets.\n",
"\n",
"You may also change the `REGION` variable, which is used for operations\n",
"throughout the rest of this notebook. Make sure to [choose a region where Vertex AI services are\n",
"available](https://cloud.google.com/vertex-ai/docs/general/locations#available_regions). You may\n",
"not use a Multi-Regional Storage bucket for training with Vertex AI."
"Cloud Storage buckets."
]
},
{
@@ -343,8 +451,8 @@
},
"outputs": [],
"source": [
"BUCKET_NAME = \"gs://[your-bucket-name]\" # @param {type:\"string\"}\n",
"REGION = \"[your-region]\" # @param {type:\"string\"}"
"BUCKET_NAME = \"[your-bucket-name]\" # @param {type:\"string\"}\n",
"BUCKET_URI = f\"gs://{BUCKET_NAME}\""
]
},
{
@@ -355,8 +463,9 @@
},
"outputs": [],
"source": [
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"gs://[your-bucket-name]\":\n",
" BUCKET_NAME = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
"if BUCKET_URI == \"\" or BUCKET_URI is None or BUCKET_URI == \"gs://[your-bucket-name]\":\n",
" BUCKET_NAME = PROJECT_ID + \"aip-\" + TIMESTAMP\n",
" BUCKET_URI = \"gs://\" + BUCKET_NAME"
]
},
{
@@ -376,7 +485,7 @@
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_NAME"
"! gsutil mb -l $REGION $BUCKET_URI"
]
},
{
@@ -396,7 +505,7 @@
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_NAME"
"! gsutil ls -al $BUCKET_URI"
]
},
{
@@ -450,7 +559,13 @@
"id": "e37354341588"
},
"source": [
"### Load data from Cloud Storage path using Pandas"
"### Load data from Cloud Storage using Pandas\n",
"\n",
"The Telecom-Customer Churn dataset from [Kaggle](https://www.kaggle.com/c/customer-churn-prediction-2020/overview) is made available on a public Cloud Storage bucket at: \n",
"\n",
"```gs://cloud-samples-data/vertex-ai/managed_notebooks/telecom_churn_prediction/train.csv```\n",
"\n",
"Use Pandas to read data directly from the URI."
]
},
{
@@ -1116,6 +1231,8 @@
" \"[your-blob-path]\" # leave blank if no folders inside the bucket are needed.\n",
")\n",
"\n",
"if BLOB_PATH == (\"[your-blob-path]\"):\n",
" BLOB_PATH = \"\"\n",
"\n",
"BLOB_NAME = BLOB_PATH + FILE_NAME\n",
"\n",
@@ -1133,7 +1250,9 @@
"## Create a model with Explainable AI support in Vertex AI\n",
"<a name=\"section-9\"></a>\n",
"\n",
"Before creating a model, configure the explanations for the model. For further details, see [Configuring explanations in Vertex AI](https://cloud.google.com/vertex-ai/docs/explainable-ai/configuring-explanations#scikit-learn-and-xgboost-pre-built-containers)."
"Before creating a model, configure the explanations for the model. For further details, see [Configuring explanations in Vertex AI](https://cloud.google.com/vertex-ai/docs/explainable-ai/configuring-explanations#scikit-learn-and-xgboost-pre-built-containers).\n",
"\n",
"Set a display name for the model resource."
]
},
{
@@ -1144,10 +1263,13 @@
},
"outputs": [],
"source": [
"MODEL_DISPLAY_NAME = \"[your-model-display-name]\"\n",
"# Set the model display name\n",
"MODEL_DISPLAY_NAME = \"[your-model-display-name]\" # @param {type:\"string\"}\n",
"\n",
"if MODEL_DISPLAY_NAME == \"[your-model-display-name]\":\n",
" MODEL_DISPLAY_NAME = \"subscriber_churn_model\"\n",
"\n",
"ARTIFACT_GCS_PATH = f\"gs://{BUCKET_NAME}/{BLOB_PATH}\"\n",
"PROJECT = \"[your-project-id]\"\n",
"LOCATION = REGION\n",
"\n",
"# Feature-name(Inp_feature) and Output-name(Model_output) can be arbitrary\n",
"exp_metadata = {\"inputs\": {\"Inp_feature\": {}}, \"outputs\": {\"Model_output\": {}}}"
@@ -1161,17 +1283,20 @@
},
"outputs": [],
"source": [
"from google.cloud.aiplatform_v1.types import SampledShapleyAttribution\n",
"# Create a Vertex AI model resource with support for explanations\n",
"from google.cloud.aiplatform_v1.types.explanation import ExplanationParameters\n",
"\n",
"aiplatform.init(project=PROJECT, location=LOCATION)\n",
"explanation_parameters = {\"sampledShapleyAttribution\": {\"pathCount\": 25}}\n",
"aiplatform.init(project=PROJECT_ID, location=REGION)\n",
"\n",
"model = aiplatform.Model.upload(\n",
" display_name=MODEL_DISPLAY_NAME,\n",
" artifact_uri=ARTIFACT_GCS_PATH,\n",
" serving_container_image_uri=\"us-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.0-24:latest\",\n",
" serving_container_image_uri=\"us-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.1-0:latest\",\n",
" explanation_metadata=exp_metadata,\n",
" explanation_parameters=explanation_parameters,\n",
" explanation_parameters=ExplanationParameters(\n",
" sampled_shapley_attribution=SampledShapleyAttribution(path_count=25)\n",
" ),\n",
")\n",
"\n",
"model.wait()\n",
@@ -1192,7 +1317,7 @@
"gcloud beta ai models upload \\\n",
" --region=$REGION \\\n",
" --display-name=$MODEL_DISPLAY_NAME \\\n",
" --container-image-uri=\"us-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.0-24:latest\" \\\n",
" --container-image-uri=\"us-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.1-0:latest\" \\\n",
" --artifact-uri=$ARTIFACT_GCS_PATH \\\n",
" --explanation-method=sampled-shapley \\\n",
" --explanation-path-count=25 \\\n",
@@ -1217,7 +1342,9 @@
},
"outputs": [],
"source": [
"ENDPOINT_DISPLAY_NAME = \"[your-endpoint-display-name]\""
"ENDPOINT_DISPLAY_NAME = \"[your-endpoint-display-name]\" # @param {type:\"string\"}\n",
"if ENDPOINT_DISPLAY_NAME == \"[your-endpoint-display-name]\":\n",
" ENDPOINT_DISPLAY_NAME = \"subsc_churn_endpoint\""
]
},
{
@@ -1229,33 +1356,13 @@
"outputs": [],
"source": [
"endpoint = aiplatform.Endpoint.create(\n",
" display_name=ENDPOINT_DISPLAY_NAME, project=PROJECT, location=LOCATION\n",
" display_name=ENDPOINT_DISPLAY_NAME, project=PROJECT_ID, location=REGION\n",
")\n",
"\n",
"print(endpoint.display_name)\n",
"print(endpoint.resource_name)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "ae4c69ef8a8c"
},
"source": [
"Save the endpoint ID after the endpoint is created."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "6aa73d9a88d3"
},
"outputs": [],
"source": [
"ENDPOINT_ID = \"[your-endpoint-id]\""
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -1275,8 +1382,11 @@
},
"outputs": [],
"source": [
"DEPLOYED_MODEL_NAME = \"[deployment-model-name]\"\n",
"MACHINE_TYPE = \"n1-standard-4\""
"DEPLOYED_MODEL_NAME = \"[deployment-model-name]\" # @param {type:\"string\"}\n",
"MACHINE_TYPE = \"n1-standard-4\"\n",
"\n",
"if DEPLOYED_MODEL_NAME == \"[deployment-model-name]\":\n",
" DEPLOYED_MODEL_NAME = \"subsc_churn_deployment\""
]
},
{
@@ -1306,7 +1416,7 @@
"id": "359c43e630cb"
},
"source": [
"Save the ID of the deployed model. The ID of the deployed model can also checked using the `endpoint.list_models()` method."
"To ensure the model is deployed, the ID of the deployed model can be checked using the `endpoint.list_models()` method."
]
},
{
@@ -1317,7 +1427,7 @@
},
"outputs": [],
"source": [
"DEPLOYED_MODEL_ID = \"[your-deployed-model-id]\""
"endpoint.list_models()"
]
},
{
@@ -1336,7 +1446,7 @@
"id": "7b50c31e0552"
},
"source": [
"Get explanations for some test instances from the hosted model."
"Get explanations for a test instance from the hosted model."
]
},
{
@@ -1347,8 +1457,8 @@
},
"outputs": [],
"source": [
"# format the top 2 test instances as the request's payload\n",
"test_json = {\"instances\": [X_test.iloc[0].tolist(), X_test.iloc[1].tolist()]}"
"# format a test instance as the request's payload\n",
"test_json = [X_test.iloc[0].tolist()]"
]
},
{
@@ -1385,15 +1495,13 @@
" return\n",
"\n",
"\n",
"def explain_tabular_sample(\n",
" project: str, location: str, endpoint_id: str, instances: list\n",
"):\n",
"def explain_tabular_sample(project: str, location: str, endpoint, instances: list):\n",
" \"\"\"\n",
" Function to make an explanation request for the specified payload and generate feature attribution plots\n",
" \"\"\"\n",
" aiplatform.init(project=project, location=location)\n",
"\n",
" endpoint = aiplatform.Endpoint(endpoint_id)\n",
" # endpoint = aiplatform.Endpoint(endpoint_id)\n",
"\n",
" response = endpoint.explain(instances=instances)\n",
" print(\"#\" * 10 + \"Explanations\" + \"#\" * 10)\n",
@@ -1422,8 +1530,8 @@
" return response\n",
"\n",
"\n",
"test_json = [X_test.iloc[0].tolist(), X_test.iloc[1].tolist()]\n",
"prediction = explain_tabular_sample(PROJECT, LOCATION, ENDPOINT_ID, test_json)"
"# Get explanations for the test instance\n",
"prediction = explain_tabular_sample(PROJECT_ID, REGION, endpoint, test_json)"
]
},
{
@@ -1438,7 +1546,12 @@
"To clean up all Google Cloud resources used in this project, you can [delete the Google Cloud\n",
"project](https://cloud.google.com/resource-manager/docs/creating-managing-projects#shutting_down_projects) you used for the tutorial.\n",
"\n",
"Otherwise, you can delete the individual resources you created in this tutorial:"
"Otherwise, you can delete the individual resources you created in this tutorial:\n",
"* Vertex AI Model\n",
"* Vertex AI Endpoint\n",
"* Cloud Storage bucket\n",
"\n",
"Set `delete_bucket` to *True* to delete the Cloud Storage bucket."
]
},
{
@@ -1449,8 +1562,8 @@
},
"outputs": [],
"source": [
"# undeploy the model\n",
"endpoint.undeploy(deployed_model_id=DEPLOYED_MODEL_ID)"
"# Undeploy model\n",
"endpoint.undeploy_all()"
]
},
{
@@ -1461,7 +1574,7 @@
},
"outputs": [],
"source": [
"# delete the endpoint\n",
"# Delete the endpoint\n",
"endpoint.delete()"
]
},
@@ -1473,7 +1586,7 @@
},
"outputs": [],
"source": [
"# delete the model\n",
"# Delete the model\n",
"model.delete()"
]
},
@@ -1485,8 +1598,10 @@
},
"outputs": [],
"source": [
"# remove the contents of the Cloud Storage bucket\n",
"! gsutil -m rm -r $BUCKET_NAME"
"# Delete the Cloud Storage bucket\n",
"delete_bucket = True\n",
"if delete_bucket or os.getenv(\"IS_TESTING\"):\n",
" ! gsutil -m rm -r $BUCKET_URI"
]
}
],