Compare commits

...
@@ -24,6 +24,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "l2mMvIUG9meX"
@@ -91,6 +92,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "zfXf0r-K81Y-"
@@ -102,6 +104,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "I3KFLvpq87rs"
@@ -122,6 +125,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "ze4-nDLfK4pw"
@@ -144,6 +148,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "aUw6ibN-n5Za"
@@ -168,6 +173,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "LgFWLeJfoGQu"
@@ -189,6 +195,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "8ckyxpX_oSzD"
@@ -217,6 +224,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "mSQjVQmMosMl"
@@ -239,6 +247,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "IfJRIMBpo5Pg"
@@ -246,25 +255,11 @@
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"Depending on your Jupyter environment, you may have to manually authenticate. Follow the relevant instructions below."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "acFN0s3So9-Y"
},
"source": [
"Depending on your Jupyter environment, you may have to manually authenticate. Follow the relevant instructions below.\n",
"\n",
"**1. Vertex AI Workbench**\n",
"* Do nothing as you are already authenticated."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dQ_mNwuapE5T"
},
"source": [
"* Do nothing as you are already authenticated.\n",
"\n",
"**2. Local JupyterLab instance, uncomment and run:**"
]
},
@@ -280,6 +275,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "h-MuVI_ypJfw"
@@ -301,6 +297,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "3ivZkPUjpaFz"
@@ -322,6 +319,35 @@
"SERVICE_ACCOUNT = \"[your-service-account]\" # @param {type:\"string\"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "autoset_service_account"
},
"outputs": [],
"source": [
"import sys\n",
"\n",
"IS_COLAB = \"google.colab\" in sys.modules\n",
"if (\n",
" SERVICE_ACCOUNT == \"\"\n",
" or SERVICE_ACCOUNT is None\n",
" or SERVICE_ACCOUNT == \"[your-service-account]\"\n",
"):\n",
" # Get your service account from gcloud\n",
" if not IS_COLAB:\n",
" shell_output = !gcloud auth list 2>/dev/null\n",
" SERVICE_ACCOUNT = shell_output[2].replace(\"*\", \"\").strip()\n",
"\n",
" if IS_COLAB:\n",
" shell_output = ! gcloud projects describe $PROJECT_ID\n",
" project_number = shell_output[-1].split(\":\")[1].strip().replace(\"'\", \"\")\n",
" SERVICE_ACCOUNT = f\"{project_number}-compute@developer.gserviceaccount.com\"\n",
"\n",
" print(\"Service Account:\", SERVICE_ACCOUNT)"
]
},
{
"cell_type": "code",
"execution_count": null,
@@ -347,6 +373,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "OKtKGmr9pfr6"
@@ -365,10 +392,11 @@
},
"outputs": [],
"source": [
"BUCKET_URI = \"gs://your-bucket-name-unique\" # @param {type:\"string\"}"
"BUCKET_URI = f\"gs://your-bucket-name-{PROJECT_ID}-unique\" # @param {type:\"string\"}"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "GOaOsIjxp0oB"
@@ -385,10 +413,11 @@
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION -p $PROJECT_ID $BUCKET_URI"
"! gsutil mb -l {REGION} -p {PROJECT_ID} {BUCKET_URI}"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "ankcS-vtp7Wv"
@@ -405,10 +434,13 @@
},
"outputs": [],
"source": [
"import os\n",
"\n",
"from google.cloud import aiplatform"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "OMrAJ8RGqBQu"
@@ -431,6 +463,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "-ayTbNdi62_t"
@@ -442,6 +475,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "9c3QrDTZdaxk"
@@ -462,6 +496,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "vJrWKK0mY7H7"
@@ -507,6 +542,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "syw3GabNGgJz"
@@ -573,6 +609,7 @@
"\n",
"REQUIRED_PACKAGES = [\n",
" 'google-cloud-aiplatform[cloud_profiler]>=1.20.0',\n",
" 'protobuf==3.20.2',\n",
"]\n",
"\n",
"setup(\n",
@@ -587,6 +624,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "hyAwgsoQmaYI"
@@ -706,6 +744,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "ihYFahRAr6sj"
@@ -732,6 +771,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "k4e6OYmimqTR"
@@ -779,6 +819,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "51hKGTbU32Eg"
@@ -810,6 +851,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "JkEe2Nb_85UD"
@@ -823,6 +865,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "TpV-iwP9qw9c"
@@ -849,7 +892,7 @@
"job.delete()\n",
"tensorboard.delete()\n",
"\n",
"if delete_bucket and \"BUCKET_URI\" in globals():\n",
"if delete_bucket or os.getenv(\"IS_TESTING\"):\n",
" ! gsutil -m rm -r $BUCKET_URI"
]
}