Skip to content

Commit

Permalink
fix: add an error message on user import data script in case of any e…
Browse files Browse the repository at this point in the history
…rrors. (#288)

Co-authored-by: Anthonios Partheniou <partheniou@google.com>
  • Loading branch information
2 people authored and dandhlee committed Dec 2, 2022
1 parent ee9943a commit 0ccb3c9
Showing 1 changed file with 24 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,31 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# set the service account key as a GOOGLE_APPLICATION_CREDENTIALS
export GOOGLE_APPLICATION_CREDENTIALS=~/key.json
{
# set the service account key as a GOOGLE_APPLICATION_CREDENTIALS
export GOOGLE_APPLICATION_CREDENTIALS=~/key.json

# activate the python virtual env
source ~/cloudshell_open/myenv/bin/activate
# activate the python virtual env
source ~/cloudshell_open/myenv/bin/activate

# Create a GCS bucket and upload the product data to the bucket
output=$(python ~/cloudshell_open/python-retail/samples/interactive-tutorials/product/setup_product/products_create_gcs_bucket.py)
# Create a GCS bucket and upload the product data to the bucket
output=$(python ~/cloudshell_open/python-retail/samples/interactive-tutorials/product/setup_product/products_create_gcs_bucket.py)

# Get the bucket name and store it in the env variable BUCKET_NAME
temp="${output#*The gcs bucket }"
bucket_name="${temp% was created*}"
export BUCKET_NAME=$bucket_name
# Get the bucket name and store it in the env variable BUCKET_NAME
temp="${output#*The gcs bucket }"
bucket_name="${temp% was created*}"
export BUCKET_NAME=$bucket_name

# Import products to the Retail catalog
python ~/cloudshell_open/python-retail/samples/interactive-tutorials/product/import_products_gcs.py

echo "====================================="
echo "Your Retail catalog is ready to use!"
echo "====================================="
# Import products to the Retail catalog
python ~/cloudshell_open/python-retail/samples/interactive-tutorials/product/import_products_gcs.py
} && {
# Print success message
echo "====================================="
echo "Your Retail catalog is ready to use!"
echo "====================================="
} || {
# Print error message
echo "====================================="
echo "Your Retail catalog wasn't created! Please fix the errors above!"
echo "====================================="
}

0 comments on commit 0ccb3c9

Please sign in to comment.