ciyidogan commited on
Commit
80b72e4
Β·
verified Β·
1 Parent(s): af94b83

Update config_provider.py

Browse files
Files changed (1) hide show
  1. config_provider.py +31 -0
config_provider.py CHANGED
@@ -181,6 +181,37 @@ class ConfigProvider:
181
  cls._check_environment_setup()
182
  return cls._instance
183
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
  @classmethod
185
  def _check_environment_setup(cls):
186
  """Check if environment is properly configured based on work_mode"""
 
181
  cls._check_environment_setup()
182
  return cls._instance
183
 
184
+ @classmethod
185
+ def _load(cls) -> ServiceConfig:
186
+ """Load configuration from service_config.jsonc"""
187
+ try:
188
+ log(f"πŸ“‚ Loading config from: {cls._CONFIG_PATH}")
189
+
190
+ if not cls._CONFIG_PATH.exists():
191
+ raise FileNotFoundError(f"Config file not found: {cls._CONFIG_PATH}")
192
+
193
+ with open(cls._CONFIG_PATH, 'r', encoding='utf-8') as f:
194
+ config_data = commentjson.load(f)
195
+
196
+ # Create ServiceConfig instance
197
+ service_config = ServiceConfig(**config_data)
198
+
199
+ log("βœ… Configuration loaded successfully")
200
+ return service_config
201
+
202
+ except FileNotFoundError as e:
203
+ log(f"❌ Config file not found: {e}")
204
+ raise
205
+ except json.JSONDecodeError as e:
206
+ log(f"❌ Invalid JSON in config file: {e}")
207
+ raise
208
+ except ValidationError as e:
209
+ log(f"❌ Config validation error: {e}")
210
+ raise
211
+ except Exception as e:
212
+ log(f"❌ Unexpected error loading config: {e}")
213
+ raise
214
+
215
  @classmethod
216
  def _check_environment_setup(cls):
217
  """Check if environment is properly configured based on work_mode"""