Spaces:
Building
Building
Update config_provider.py
Browse files- config_provider.py +7 -3
config_provider.py
CHANGED
@@ -339,6 +339,7 @@ class ConfigProvider:
|
|
339 |
_instance: Optional[ServiceConfig] = None
|
340 |
_CONFIG_PATH = Path(__file__).parent / "service_config.jsonc"
|
341 |
_lock = threading.Lock() # Thread-safe access için lock
|
|
|
342 |
|
343 |
@classmethod
|
344 |
def get(cls) -> ServiceConfig:
|
@@ -349,7 +350,10 @@ class ConfigProvider:
|
|
349 |
if cls._instance is None:
|
350 |
cls._instance = cls._load()
|
351 |
cls._instance.build_index()
|
352 |
-
|
|
|
|
|
|
|
353 |
return cls._instance
|
354 |
|
355 |
@classmethod
|
@@ -358,6 +362,7 @@ class ConfigProvider:
|
|
358 |
with cls._lock:
|
359 |
log("🔄 Reloading configuration...")
|
360 |
cls._instance = None
|
|
|
361 |
return cls.get()
|
362 |
|
363 |
@classmethod
|
@@ -417,7 +422,7 @@ class ConfigProvider:
|
|
417 |
pcc = config_data['config'].get('parameter_collection_config')
|
418 |
if pcc is None:
|
419 |
# Yoksa default değerlerle ekle
|
420 |
-
config_data['config']['parameter_collection_config'] = ParameterCollectionConfig()
|
421 |
|
422 |
config_section.setdefault('users', [])
|
423 |
|
@@ -520,7 +525,6 @@ class ConfigProvider:
|
|
520 |
|
521 |
log("✅ Default environment variables set.")
|
522 |
|
523 |
-
|
524 |
# Forward references
|
525 |
GlobalConfig.model_rebuild()
|
526 |
VersionConfig.model_rebuild()
|
|
|
339 |
_instance: Optional[ServiceConfig] = None
|
340 |
_CONFIG_PATH = Path(__file__).parent / "service_config.jsonc"
|
341 |
_lock = threading.Lock() # Thread-safe access için lock
|
342 |
+
_environment_checked = False # Environment kontrolü için flag
|
343 |
|
344 |
@classmethod
|
345 |
def get(cls) -> ServiceConfig:
|
|
|
350 |
if cls._instance is None:
|
351 |
cls._instance = cls._load()
|
352 |
cls._instance.build_index()
|
353 |
+
# Environment kontrolünü sadece ilk yüklemede yap
|
354 |
+
if not cls._environment_checked:
|
355 |
+
cls._check_environment_setup()
|
356 |
+
cls._environment_checked = True
|
357 |
return cls._instance
|
358 |
|
359 |
@classmethod
|
|
|
362 |
with cls._lock:
|
363 |
log("🔄 Reloading configuration...")
|
364 |
cls._instance = None
|
365 |
+
# reload'da environment kontrolünü tekrar yapmıyoruz, flag'i reset etmiyoruz
|
366 |
return cls.get()
|
367 |
|
368 |
@classmethod
|
|
|
422 |
pcc = config_data['config'].get('parameter_collection_config')
|
423 |
if pcc is None:
|
424 |
# Yoksa default değerlerle ekle
|
425 |
+
config_data['config']['parameter_collection_config'] = ParameterCollectionConfig().model_dump()
|
426 |
|
427 |
config_section.setdefault('users', [])
|
428 |
|
|
|
525 |
|
526 |
log("✅ Default environment variables set.")
|
527 |
|
|
|
528 |
# Forward references
|
529 |
GlobalConfig.model_rebuild()
|
530 |
VersionConfig.model_rebuild()
|