Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refcator, chore(egen) : refactored code according to template guidelines , performed linter test #3215

Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,26 @@
"# Get started with Google Artifact Registry\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/ml_metadata/get_started_with_google_artifact_registry.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" <td style=\"text-align: center\">\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/lightweight_functions_component_io_kfp.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Google Colaboratory logo\"><br> Open in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/ml_metadata/get_started_with_google_artifact_registry.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
" View on GitHub\n",
" <td style=\"text-align: center\">\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/colab/import/https:%2F%2Fraw.githubusercontent.com%2FGoogleCloudPlatform%2Fvertex-ai-samples%2Fmain%2Fnotebooks%2Fnotebook_template.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-enterprise-logo-32px.png\" alt=\"Google Cloud Colab Enterprise logo\"><br> Open in Colab Enterprise\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://github.com/raw/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/official/ml_metadata/get_started_with_google_artifact_registry.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",
" <td style=\"text-align: center\">\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/lightweight_functions_component_io_kfp.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\"><br> View on GitHub\n",
" </a>\n",
" </td> \n",
" </td>\n",
" <td style=\"text-align: center\">\n",
"<a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://github.com/raw/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/official/pipelines/lightweight_functions_component_io_kfp.ipynb\" target='_blank'>\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\"><br> Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>\n",
"<br/><br/><br/>"
]
Expand All @@ -75,11 +78,11 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you learn how to use `Google Artifact Registry`.\n",
"In this tutorial, you learn how to use Google Artifact Registry.\n",
"\n",
"This tutorial uses the following Google Cloud ML services:\n",
"\n",
"- `Google Artifact Registry`\n",
"- Google Artifact Registry\n",
"\n",
"The steps performed include:\n",
"\n",
Expand All @@ -90,17 +93,6 @@
"- Deleting a private Docker repository."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "4ced09c1b4ce"
},
"source": [
"### Dataset\n",
"\n",
"No dataset is used in this tutorial. References to an example dataset are for demonstration purposes."
]
},
{
"cell_type": "markdown",
"metadata": {
Expand All @@ -114,7 +106,9 @@
"* Vertex AI\n",
"* Cloud Storage\n",
"\n",
"Learn about [Vertex AI pricing](https://cloud.google.com/vertex-ai/pricing) and [Cloud Storage pricing](https://cloud.google.com/storage/pricing), and use the [Pricing Calculator](https://cloud.google.com/products/calculator/) to generate a cost estimate based on your projected usage."
"Learn about [Vertex AI pricing](https://cloud.google.com/vertex-ai/pricing) and\n",
"[Cloud Storage pricing](https://cloud.google.com/storage/pricing), and use the\n",
"[Pricing Calculator](https://cloud.google.com/products/calculator/) to generate a cost estimate based on your projected usage."
]
},
{
Expand All @@ -123,9 +117,8 @@
"id": "install_mlops"
},
"source": [
"## Installations\n",
"\n",
"Install the packages required for executing the notebook."
"## Get started\n",
"Install Vertex AI SDK for Python and other required packages"
]
},
{
Expand All @@ -142,156 +135,76 @@
{
"cell_type": "markdown",
"metadata": {
"id": "hhq5zEbGg0XX"
"id": "8d726e21c0bb"
},
"source": [
"### Colab only: Uncomment the following cell to restart the kernel."
"### Restart runtime (Colab only)\n",
"To use the newly installed packages, you must restart the runtime on Google Colab."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "EzrelQZ22IZj"
"id": "3b9119a60525"
},
"outputs": [],
"source": [
"# Automatically restart kernel after installs so that your environment can access the new packages\n",
"# import IPython\n",
"import sys\n",
"\n",
"# app = IPython.Application.instance()\n",
"# app.kernel.do_shutdown(True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "lWEdiXsJg0XY"
},
"source": [
"## Before you begin"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "8bc8a29f9001"
},
"source": [
"#### Set your project ID\n",
"if \"google.colab\" in sys.modules:\n",
"\n",
"**If you don't know your project ID**, try the following:\n",
"* Run `gcloud config list`.\n",
"* Run `gcloud projects list`.\n",
"* See the support page: [Locate the project ID](https://support.google.com/googleapi/answer/7014113)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "cde8e0876d62"
},
"outputs": [],
"source": [
"PROJECT_ID = \"[your-project-id]\" # @param {type:\"string\"}\n",
" import IPython\n",
"\n",
"# Set the project id\n",
"! gcloud config set project {PROJECT_ID}"
" app = IPython.Application.instance()\n",
" app.kernel.do_shutdown(True)"
Jayakrishna2801 marked this conversation as resolved.
Show resolved Hide resolved
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "47bc07d4231b"
"id": "1d7064423926"
},
"source": [
"#### Region\n",
"\n",
"You can also change the `REGION` variable used by Vertex AI. Learn more about [Vertex AI regions](https://cloud.google.com/vertex-ai/docs/general/locations)."
"### Authenticate your notebook environment (Colab only)\n",
"Authenticate your environment on Google Colab."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "959545da671a"
"id": "405401bbd1c7"
},
"outputs": [],
"source": [
"REGION = \"us-central1\" # @param {type: \"string\"}"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dr--iN2kAylZ"
},
"source": [
"### Authenticate your Google Cloud account\n",
Jayakrishna2801 marked this conversation as resolved.
Show resolved Hide resolved
"if \"google.colab\" in sys.modules:\n",
"\n",
"Depending on your Jupyter environment, you may have to manually authenticate. Follow the relevant instructions below."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "sBCra4QMA2wR"
},
"source": [
"**1. Vertex AI Workbench**\n",
"* Do nothing as you are already authenticated."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "ad1138a125ea"
},
"source": [
"**2. Local JupyterLab instance, uncomment and run:**"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "ce6043da7b33"
},
"outputs": [],
"source": [
"# ! gcloud auth login"
" from google.colab import auth\n",
"\n",
" auth.authenticate_user()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "0367eac06a10"
"id": "d183adfc792a"
},
"source": [
"**3. Colab, uncomment and run:**"
"### Set Google Cloud project information\n",
"To get started using Vertex AI, you must have an existing Google Cloud project. [Learn more about setting up a project and a development environment.](https://cloud.google.com/vertex-ai/docs/start/cloud-environment)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "PyQmSRbKA8r-"
"id": "cde8e0876d62"
},
"outputs": [],
"source": [
"# from google.colab import auth\n",
"# auth.authenticate_user()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "c13224697bfb"
},
"source": [
"**4. Service account or other**\n",
"* See how to grant Cloud Storage permissions to your service account at https://cloud.google.com/storage/docs/gsutil/commands/iam#ch-examples."
"PROJECT_ID = \"[your-project-id]\" # @param {type:\"string\"}\n",
"LOCATION = \"us-central1\" # @param {type:\"string\"}"
]
},
{
Expand Down Expand Up @@ -322,7 +235,7 @@
"id": "-EcIXiGsCePi"
},
"source": [
"**Only if your bucket doesn't already exist**: Run the following cell to create your Cloud Storage bucket."
"**If your bucket doesn't already exist**: Run the following cell to create your Cloud Storage bucket."
]
},
{
Expand All @@ -333,19 +246,7 @@
},
"outputs": [],
"source": [
"! gsutil mb -l {REGION} -p {PROJECT_ID} {BUCKET_URI}"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "setup_vars"
},
"source": [
"### Set up variables\n",
"\n",
"Next, set up some variables used throughout the tutorial.\n",
"### Import libraries and define constants"
"! gsutil mb -l {LOCATION} -p {PROJECT_ID} {BUCKET_URI}"
]
},
{
Expand All @@ -356,7 +257,7 @@
"source": [
"## Introduction to Google Artifact Registry\n",
"\n",
"The `Google Artifact Registry` is a service for storing and managing artifacts in private repositories, including container images, Helm charts, and language packages. It is the recommended container image registry for Google Cloud.\n",
"The Google Artifact Registry is a service for storing and managing artifacts in private repositories, including container images, Helm charts, and language packages. It's the recommended container image registry for Google Cloud.\n",
"\n",
"Learn more about [Quick start for Docker](https://cloud.google.com/artifact-registry/docs/docker/quickstart)"
]
Expand All @@ -369,7 +270,7 @@
"source": [
"### Enable Artifact Registry API\n",
"\n",
"First, you must enable the Artifact Registry API service for your project.\n",
"First, enable the Artifact Registry API service for your project.\n",
"\n",
"Learn more about [Enabling service](https://cloud.google.com/artifact-registry/docs/enable-service)."
]
Expand Down Expand Up @@ -410,7 +311,7 @@
"source": [
"PRIVATE_REPO = \"my-docker-repo\"\n",
"\n",
"! gcloud artifacts repositories create {PRIVATE_REPO} --repository-format=docker --location={REGION} --description=\"Docker repository\"\n",
"! gcloud artifacts repositories create {PRIVATE_REPO} --repository-format=docker --location={LOCATION} --description=\"Docker repository\"\n",
"\n",
"! gcloud artifacts repositories list"
]
Expand All @@ -423,7 +324,7 @@
"source": [
"### Configure authentication to your private repo\n",
"\n",
"Before you push or pull container images, configure Docker to use the `gcloud` command-line tool to authenticate requests to `Artifact Registry` for your region."
"Before you push or pull container images, configure Docker to use the gcloud command-line tool to authenticate requests to Artifact Registry for your region."
]
},
{
Expand All @@ -434,7 +335,7 @@
},
"outputs": [],
"source": [
"! gcloud auth configure-docker {REGION}-docker.pkg.dev --quiet"
"! gcloud auth configure-docker {LOCATION}-docker.pkg.dev --quiet"
]
},
{
Expand Down Expand Up @@ -471,7 +372,7 @@
"\n",
"- Tagging the Docker image with a repository name configures the docker push command to push the image to a specific location, e.g., us-central1-docker.pkg.dev.\n",
"\n",
"- `:my-tag` is a tag you're adding to the Docker image. If a tag is not specified, it defaults to `:latest`."
"- :my-tag is a tag you're adding to the Docker image. It defaults to :latest."
]
},
{
Expand Down Expand Up @@ -506,7 +407,7 @@
},
"outputs": [],
"source": [
"! docker push {REGION}-docker.pkg.dev/{PROJECT_ID}/{PRIVATE_REPO}/{CONTAINER_NAME}"
"! docker push {LOCATION}-docker.pkg.dev/{PROJECT_ID}/{PRIVATE_REPO}/{CONTAINER_NAME}"
]
},
{
Expand All @@ -528,7 +429,7 @@
},
"outputs": [],
"source": [
"! docker pull {REGION}-docker.pkg.dev/{PROJECT_ID}/{PRIVATE_REPO}/{CONTAINER_NAME}"
"! docker pull {LOCATION}-docker.pkg.dev/{PROJECT_ID}/{PRIVATE_REPO}/{CONTAINER_NAME}"
]
},
{
Expand All @@ -539,7 +440,7 @@
"source": [
"### Deleting your private Docker repostory\n",
"\n",
"Finally, once your private repository becomes obsolete, use the command `gcloud artifacts repositories delete` to delete it `Google Artifact Registry`."
"Finally, once your private repository becomes obsolete, use the `gcloud artifacts repositories delete` command to remove the repository from the Google Artifact Registry."
]
},
{
Expand All @@ -550,7 +451,7 @@
},
"outputs": [],
"source": [
"! gcloud artifacts repositories delete {PRIVATE_REPO} --location={REGION} --quiet"
"! gcloud artifacts repositories delete {PRIVATE_REPO} --location={LOCATION} --quiet"
]
}
],
Expand Down