Skip to content

Commit 994bc5c

Browse files
t-karasovatetiana-karasovakweinmeister
authored
docs(samples): improve the setup scripts (#207)
* update README * fix: sleep is added to the setup script * improve the setup scripts Co-authored-by: tetiana-karasova <[email protected]> Co-authored-by: Karl Weinmeister <[email protected]>
1 parent fd3e846 commit 994bc5c

File tree

3 files changed

+20
-32
lines changed

3 files changed

+20
-32
lines changed

generated_samples/interactive-tutorials/README.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,6 @@ After the project is created, set your PROJECT_ID to a ```project``` variable:
5858

5959
1. Ensure that the Retail API is enabled for your project in the [API & Services page](https://console.cloud.google.com/apis/api/retail.googleapis.com/).
6060

61-
1. Log in with your user credentials to run a code sample from the Cloud Shell:
62-
63-
```bash
64-
gcloud auth login
65-
```
66-
67-
1. Type `Y` and press **Enter**. Click the link in the Terminal. A browser window
68-
should appear asking you to log in using your Gmail account.
69-
70-
1. Provide the Google Auth Library with access to your credentials and paste
71-
the code from the browser to the Terminal.
72-
7361
## Prepare your work environment
7462

7563
To prepare the work environment you should perform the following steps:
@@ -167,7 +155,7 @@ The bucket name must be unique. For convenience, you can name it `<YOUR_PROJECT_
167155
1. Go to the **product** directory and run the following command in the Terminal:
168156

169157
```bash
170-
python setup_product/products_create_gcs_bucket.py
158+
python product/setup_product/products_create_gcs_bucket.py
171159
```
172160

173161
Now you can see the bucket is created in the [Cloud Storage](https://console.cloud.google.com/storage/browser), and the files are uploaded.
@@ -189,7 +177,7 @@ The bucket name must be unique. For convenience, you can name it `<YOUR_PROJECT_
189177
To import the prepared products to a catalog, open python-retail/samples/interactive-tutorials/product/import_products_gcs.py file and run the following command in the Terminal:
190178

191179
```bash
192-
python import_products_gcs.py
180+
python product/import_products_gcs.py
193181
```
194182

195183
## Run your code sample

generated_samples/interactive-tutorials/user_environment_setup.sh

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,36 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
# set the Google Cloud project Id
17+
# set the Google Cloud Project ID
1818
project_id=$1
19-
echo Project ID: $project_id
20-
gcloud config set project project_id
19+
echo "Project ID: $project_id"
20+
gcloud config set project "$project_id"
2121

2222
timestamp=$(date +%s)
2323

24-
service_account_id="service-acc-"$timestamp
25-
echo Service Account: $service_account_id
24+
service_account_id="service-acc-$timestamp"
25+
echo "Service Account: $service_account_id"
2626

27-
# create service account (your project_id+timestamp)
28-
gcloud iam service-accounts create $service_account_id
27+
# create service account
28+
gcloud iam service-accounts create "$service_account_id"
2929

30-
# assign needed roles to your new service account
30+
# assign necessary roles to your new service account
3131
for role in {retail.admin,editor,bigquery.admin}
3232
do
33-
gcloud projects add-iam-policy-binding $project_id --member="serviceAccount:"$service_account_id"@"$project_id".iam.gserviceaccount.com" --role="roles/${role}"
33+
gcloud projects add-iam-policy-binding "$project_id" --member="serviceAccount:$service_account_id@$project_id.iam.gserviceaccount.com" --role=roles/"${role}"
3434
done
3535

36-
echo Wait 70 seconds to be sure the appropriate roles have been assigned to your service account
37-
sleep 70
36+
echo "Wait ~60 seconds to be sure the appropriate roles have been assigned to your service account"
37+
sleep 60
3838

3939
# upload your service account key file
40-
service_acc_email=$service_account_id"@"$project_id".iam.gserviceaccount.com"
41-
gcloud iam service-accounts keys create ~/key.json --iam-account $service_acc_email
40+
service_acc_email="$service_account_id@$project_id.iam.gserviceaccount.com"
41+
gcloud iam service-accounts keys create ~/key.json --iam-account "$service_acc_email"
4242

4343
# activate the service account using the key
4444
gcloud auth activate-service-account --key-file ~/key.json
4545

46-
# install needed Google client libraries
46+
# install necessary Google client libraries
4747
virtualenv -p python3 myenv
4848
source myenv/bin/activate
4949
sleep 2
@@ -53,7 +53,7 @@ pip install google-cloud-retail
5353
pip install google-cloud.storage
5454
pip install google-cloud.bigquery
5555

56-
echo ========================================
56+
echo "======================================="
5757
echo "The Google Cloud setup is completed."
5858
echo "Please proceed with the Tutorial steps"
59-
echo ========================================
59+
echo "======================================="

generated_samples/interactive-tutorials/user_import_data_to_catalog.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ export BUCKET_NAME=$bucket_name
3131
# Import products to the Retail catalog
3232
python ~/cloudshell_open/python-retail/samples/interactive-tutorials/product/import_products_gcs.py
3333

34-
echo =====================================
34+
echo "====================================="
3535
echo "Your Retail catalog is ready to use!"
36-
echo =====================================
36+
echo "====================================="

0 commit comments

Comments
 (0)