From fcb082cbcfa1d8e57ea98d511d8b10110b44f202 Mon Sep 17 00:00:00 2001 From: JJJ000 Date: Thu, 23 Feb 2023 19:28:43 -0800 Subject: [PATCH 1/2] fix --- knowledge_repo/utils/gcs.py | 7 ++++--- knowledge_repo/utils/s3.py | 6 +++--- requirements.txt | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/knowledge_repo/utils/gcs.py b/knowledge_repo/utils/gcs.py index 89aa273eb..971d001cf 100644 --- a/knowledge_repo/utils/gcs.py +++ b/knowledge_repo/utils/gcs.py @@ -5,9 +5,11 @@ import logging import re import json +from dotenv import load_dotenv logger = logging.getLogger(__name__) -GOOGLE_AUTH_PATH = '.configs/google_auth.json' + +load_dotenv() def parse_gcs_uri(uri): @@ -25,8 +27,7 @@ def parse_gcs_uri(uri): def get_gcs_client(): - with open(GOOGLE_AUTH_PATH) as source: - credentials_dict = json.load(source) + credentials_dict = os.getenv('GOOGLE_APPLICATION_CREDENTIALS') credentials = ServiceAccountCredentials.from_json_keyfile_dict( credentials_dict diff --git a/knowledge_repo/utils/s3.py b/knowledge_repo/utils/s3.py index cf28b58fa..11389b734 100644 --- a/knowledge_repo/utils/s3.py +++ b/knowledge_repo/utils/s3.py @@ -4,10 +4,11 @@ import os import json import re +from dotenv import load_dotenv logger = logging.getLogger(__name__) -AWS_S3_AUTH_PATH = '.configs/aws_s3_auth.json' +load_dotenv() def parse_s3_uri(s3_uri): """Get s3_path for S3 Object URL @@ -33,8 +34,7 @@ def get_s3_client(): :return: a boto3 client for s3 operations """ - with open(AWS_S3_AUTH_PATH) as source: - credentials_dict = json.load(source) + credentials_dict = os.getenv('AWS_S3_CREDENTIALS') return boto3.client( "s3", diff --git a/requirements.txt b/requirements.txt index 52926534d..34ebbb702 100644 --- a/requirements.txt +++ b/requirements.txt @@ -33,3 +33,4 @@ weasyprint==54.3 s3path==0.3.4 notion-client==2.0.0 gcloud==0.18.3 +python-dotenv==0.21.1 \ No newline at end of file From 2d7511ec66068f6d7e54c30b0b7a976a904e085f Mon Sep 17 00:00:00 2001 From: JJJ000 Date: Thu, 23 Feb 2023 19:28:59 -0800 Subject: [PATCH 2/2] add gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 9e1428e9c..ef17a1733 100644 --- a/.gitignore +++ b/.gitignore @@ -79,6 +79,8 @@ celerybeat-schedule # dotenv .env +.env_dev +.env_prod # docker docker/config.py