feat(settings): add validation for settings.json to ensure required configuration is present

fix(usage_stats): handle initialization errors for usage statistics when no valid paths are configured, fixes #375
This commit is contained in:
Will Miao
2025-09-06 17:39:51 +08:00
parent c23ab04d90
commit 74507cef05
3 changed files with 64 additions and 3 deletions

View File

@@ -33,7 +33,13 @@ class StatsRoutes:
self.lora_scanner = await ServiceRegistry.get_lora_scanner()
self.checkpoint_scanner = await ServiceRegistry.get_checkpoint_scanner()
self.embedding_scanner = await ServiceRegistry.get_embedding_scanner()
self.usage_stats = UsageStats()
# Only initialize usage stats if we have valid paths configured
try:
self.usage_stats = UsageStats()
except RuntimeError as e:
logger.warning(f"Could not initialize usage statistics: {e}")
self.usage_stats = None
async def handle_stats_page(self, request: web.Request) -> web.Response:
"""Handle GET /statistics request"""