Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include environment variables in path manager order #347

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions simpa/utils/path_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ class PathManager:
one we provided in the `simpa_examples`) in the following places in this order:

1. The optional path you give the PathManager
2. Your $HOME$ directory
3. The current working directory
4. The SIMPA home directory path
2. Your set environment variables
3. Your $HOME$ directory
4. The current working directory
5. The SIMPA home directory path
"""

def __init__(self, environment_path=None):
Expand All @@ -32,6 +33,7 @@ def __init__(self, environment_path=None):
"""
self.logger = Logger()
self.path_config_file_name = 'path_config.env'
override = False
if environment_path is None:
environment_path = os.path.join(str(Path.home()), self.path_config_file_name)
self.logger.debug(f"Using $HOME$ path to search for config file: {environment_path}")
Expand All @@ -44,13 +46,14 @@ def __init__(self, environment_path=None):
f"for {self.path_config_file_name}")
environment_path = os.path.join(environment_path, self.path_config_file_name)
self.logger.debug(f"Using supplied path to search for config file: {environment_path}")
override = True

if environment_path is None or not os.path.exists(environment_path) or not os.path.isfile(environment_path):
error_message = f"Did not find a { self.path_config_file_name} file in any of the standard directories..."
self.logger.warning(error_message)

self.environment_path = environment_path
load_dotenv(environment_path, override=True)
load_dotenv(environment_path, override=override)

def detect_local_path_config(self):
"""
Expand Down
Loading