From 793a3c3ccf56836346487056fb2bbb7042e37522 Mon Sep 17 00:00:00 2001 From: tetiana-karasova Date: Thu, 24 Mar 2022 15:10:48 +0100 Subject: [PATCH] fix: sleep is added to the setup script --- samples/interactive-tutorials/README.md | 4 ++-- .../interactive-tutorials/user_environment_setup.sh | 11 +++++++---- .../user_import_data_to_catalog.sh | 3 +++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/samples/interactive-tutorials/README.md b/samples/interactive-tutorials/README.md index fa23aaf5..e1abc308 100644 --- a/samples/interactive-tutorials/README.md +++ b/samples/interactive-tutorials/README.md @@ -138,8 +138,8 @@ To run Python code samples for the Retail API tutorial, you need to set up your ```bash pip install google pip install google-cloud-retail - pip install google.cloud.storage - pip install google.cloud.bigquery + pip install google-cloud-storage + pip install google-cloud-bigquery ``` diff --git a/samples/interactive-tutorials/user_environment_setup.sh b/samples/interactive-tutorials/user_environment_setup.sh index a0353d9e..a1b545af 100644 --- a/samples/interactive-tutorials/user_environment_setup.sh +++ b/samples/interactive-tutorials/user_environment_setup.sh @@ -14,21 +14,23 @@ # See the License for the specific language governing permissions and # limitations under the License. -# get the project_id from gcloud config +echo Project ID: project_id=$(gcloud config get-value project) echo $project_id timestamp=$(date +%s) -echo $timestamp +echo Service Account: service_account_id="service-acc-"$timestamp +echo $service_account_id # create service account (your project_id+timestamp) gcloud iam service-accounts create $service_account_id # assign needed roles to your new service account -for role in {retail.admin,storage.admin,bigquery.admin} +for role in {retail.admin,editor,bigquery.admin} do gcloud projects add-iam-policy-binding $project_id --member="serviceAccount:"$service_account_id"@"$project_id".iam.gserviceaccount.com" --role="roles/${role}" - done +done +sleep 70 # upload your service account key file service_acc_email=$service_account_id"@"$project_id".iam.gserviceaccount.com" @@ -43,6 +45,7 @@ export GOOGLE_APPLICATION_CREDENTIALS=~/key.json # install needed Google client libraries virtualenv -p python3 myenv source myenv/bin/activate +sleep 2 pip install google pip install google-cloud-retail diff --git a/samples/interactive-tutorials/user_import_data_to_catalog.sh b/samples/interactive-tutorials/user_import_data_to_catalog.sh index f715b2c1..4a775819 100644 --- a/samples/interactive-tutorials/user_import_data_to_catalog.sh +++ b/samples/interactive-tutorials/user_import_data_to_catalog.sh @@ -14,6 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# activate the python virtual env +source ~/cloudshell_open/myenv/bin/activate + # Change the working directory current_path=$(pwd) temp_path="${current_path%cloudshell_open*}"