@@ -60,7 +60,7 @@ def __init__(self):
60
60
configuration file.
61
61
62
62
"""
63
- config_path = os .getenv ("Aali_CONFIG_PATH" , "config.yaml" )
63
+ config_path = os .getenv ("AALI_CONFIG_PATH" , os . getenv ( " Aali_CONFIG_PATH" , "config.yaml" ) )
64
64
self ._yaml = self ._load_config (config_path )
65
65
66
66
# Define the configuration variables to be parsed from the YAML file
@@ -99,23 +99,26 @@ def _load_config(self, config_path: str) -> dict:
99
99
Raises
100
100
------
101
101
FileNotFoundError
102
- If the configuration file is not found at the given path.
103
-
102
+ If the configuration file is not found at any given path.
104
103
"""
105
- try :
106
- with Path (config_path ).open ("r" ) as file :
107
- return yaml .safe_load (file )
108
- except FileNotFoundError :
109
- print (f"Configuration file not found at: { config_path } , using default location." )
104
+ search_paths : list [Path ] = []
105
+
106
+ # 1. Use explicitly set path first
107
+ if config_path :
108
+ search_paths .append (Path (config_path ))
109
+
110
+ # 2. Fallbacks for local dev
111
+ search_paths .append (Path ("configs/config.yaml" ))
112
+ search_paths .append (Path ("../../configs/config.yaml" ))
113
+
114
+ for path in search_paths :
110
115
try :
111
- with Path ( "configs/config.yaml" ) .open ("r" ) as file :
116
+ with path .open ("r" ) as file :
112
117
return yaml .safe_load (file )
113
118
except FileNotFoundError :
114
- try :
115
- with Path ("../../configs/config.yaml" ).open ("r" ) as file :
116
- return yaml .safe_load (file )
117
- except FileNotFoundError :
118
- raise FileNotFoundError ("Configuration file not found at the default location." )
119
+ continue
120
+
121
+ raise FileNotFoundError ("Configuration file not found at any default location." )
119
122
120
123
def _get_config_from_azure_key_vault (self ):
121
124
"""Extract configuration from Azure Key Vault and set attributes."""
0 commit comments