From ac4637700b665e93c51465c60c8196228111bdbf Mon Sep 17 00:00:00 2001 From: Diogo Matos Chaves Date: Fri, 23 Feb 2024 18:09:26 -0300 Subject: [PATCH] Add error handling case --- INSTALLATION.md | 4 ++-- model/service/cloud_storage/_cloud_storage.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/INSTALLATION.md b/INSTALLATION.md index 3efedc5..366da78 100644 --- a/INSTALLATION.md +++ b/INSTALLATION.md @@ -34,7 +34,7 @@ BINANCE_API_SECRET_TEST # Your personal Binance API secret (binance testnet) USE_CLOUD_STORAGE # Either true or false - tells the app whether to use a cloud storage AWS_ACCESS_KEY_ID # Your Personal AWS access key AWS_SECRET_ACCESS_KEY # Your Personal AWS secret access key -AWS_BUCKET # The name of the bucket where you'll keep you files +AWS_BUCKET # The name of the S3 bucket where you'll keep your files ``` *Note: The remote cloud storage ones (AWS) are only required to be set if you want to have that option enabled for local usage. @@ -46,7 +46,7 @@ The database is handled by a postgres docker container as a service, which ensur from local installations. When the database service is up, the database can be accessed on the local server on the port `5433`, instead of the usual `5432`. -In order to setup the database we need to start the services in detached mode via `docker-compose`, as follows: +In order to set up the database we need to start the services in detached mode via `docker-compose`, as follows: $ docker-compose up -d --build diff --git a/model/service/cloud_storage/_cloud_storage.py b/model/service/cloud_storage/_cloud_storage.py index 81f0848..b4c687a 100644 --- a/model/service/cloud_storage/_cloud_storage.py +++ b/model/service/cloud_storage/_cloud_storage.py @@ -2,7 +2,7 @@ import os import boto3 -from botocore.exceptions import ClientError, NoCredentialsError +from botocore.exceptions import ClientError, NoCredentialsError, ParamValidationError from dotenv import load_dotenv, find_dotenv @@ -40,12 +40,13 @@ def check_aws_config(): try: s3.list_objects(Bucket=bucket) return True - except ClientError: + except (ClientError, ParamValidationError): logging.warning(f"Bucket {bucket} does not exist. AWS_BUCKET must be set.") return False except NoCredentialsError: logging.warning(f"The provided credentials are wrong. " f"AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY must be set.") + return False def upload_models(local_models_dir):