From 0daf1ff3bd7628c82ee0a9a7609fda89dfc173ed Mon Sep 17 00:00:00 2001 From: wakonig_k Date: Fri, 7 Feb 2025 10:58:16 +0100 Subject: [PATCH] refactor: moved func accounts to dedicated deployment dir --- backend/bec_atlas/datasources/mongodb/mongodb.py | 3 ++- .../mongodb => deployment}/.functional_accounts.json | 0 backend/bec_atlas/utils/env_loader.py | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) rename backend/bec_atlas/{datasources/mongodb => deployment}/.functional_accounts.json (100%) diff --git a/backend/bec_atlas/datasources/mongodb/mongodb.py b/backend/bec_atlas/datasources/mongodb/mongodb.py index ae4025f..776c08b 100644 --- a/backend/bec_atlas/datasources/mongodb/mongodb.py +++ b/backend/bec_atlas/datasources/mongodb/mongodb.py @@ -54,7 +54,8 @@ class MongoDBDatasource: Load the functional accounts to the database. """ functional_accounts_file = os.path.join( - os.path.dirname(__file__), ".functional_accounts.json" + os.path.dirname(os.path.dirname(os.path.dirname(__file__))), + "deployment/.functional_accounts.json", ) if not os.path.exists(functional_accounts_file): raise FileNotFoundError( diff --git a/backend/bec_atlas/datasources/mongodb/.functional_accounts.json b/backend/bec_atlas/deployment/.functional_accounts.json similarity index 100% rename from backend/bec_atlas/datasources/mongodb/.functional_accounts.json rename to backend/bec_atlas/deployment/.functional_accounts.json diff --git a/backend/bec_atlas/utils/env_loader.py b/backend/bec_atlas/utils/env_loader.py index 64cfeaf..12b8070 100644 --- a/backend/bec_atlas/utils/env_loader.py +++ b/backend/bec_atlas/utils/env_loader.py @@ -17,6 +17,10 @@ def load_env() -> dict: current_dir = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) env_file = os.path.join(current_dir, ".env.yaml") + if not os.path.exists(env_file): + # check if there is an env file in the deployment directory + env_file = os.path.join(os.path.dirname(os.path.dirname(__file__)), "deployment/.env.yaml") + if not os.path.exists(env_file): raise FileNotFoundError(f"Could not find .env file in {os.getcwd()} or {current_dir}")