Upload 59 files
Browse files- api_server_extended.py +13 -13
api_server_extended.py
CHANGED
|
@@ -110,7 +110,7 @@ def init_database():
|
|
| 110 |
|
| 111 |
conn.commit()
|
| 112 |
conn.close()
|
| 113 |
-
print(f"
|
| 114 |
|
| 115 |
|
| 116 |
def save_price_to_db(price_data: Dict[str, Any]):
|
|
@@ -616,47 +616,47 @@ async def call_provider_safe(
|
|
| 616 |
async def lifespan(app: FastAPI):
|
| 617 |
"""Application lifespan manager"""
|
| 618 |
print("=" * 80)
|
| 619 |
-
print("
|
| 620 |
print("=" * 80)
|
| 621 |
init_database()
|
| 622 |
|
| 623 |
# Load providers
|
| 624 |
config = load_providers_config()
|
| 625 |
_provider_state["providers"] = config.get("providers", {})
|
| 626 |
-
print(f"
|
| 627 |
|
| 628 |
# Load auto-discovery report
|
| 629 |
apl_report = load_auto_discovery_report()
|
| 630 |
if apl_report:
|
| 631 |
-
print(f"
|
| 632 |
|
| 633 |
# Load API registry
|
| 634 |
api_registry = load_api_registry()
|
| 635 |
if api_registry:
|
| 636 |
metadata = api_registry.get("metadata", {})
|
| 637 |
-
print(f"
|
| 638 |
|
| 639 |
# Initialize AI models
|
| 640 |
try:
|
| 641 |
from ai_models import initialize_models, registry_status
|
| 642 |
model_init_result = initialize_models()
|
| 643 |
registry_info = registry_status()
|
| 644 |
-
print(f"
|
| 645 |
-
print(f"
|
| 646 |
except Exception as e:
|
| 647 |
-
print(f"
|
| 648 |
|
| 649 |
# Validate unified resources
|
| 650 |
try:
|
| 651 |
from backend.services.resource_validator import validate_unified_resources
|
| 652 |
validation_report = validate_unified_resources(str(WORKSPACE_ROOT / "api-resources" / "crypto_resources_unified_2025-11-11.json"))
|
| 653 |
-
print(f"
|
| 654 |
if validation_report['local_backend_routes']['duplicate_signatures'] > 0:
|
| 655 |
-
print(f"
|
| 656 |
except Exception as e:
|
| 657 |
-
print(f"
|
| 658 |
|
| 659 |
-
print(f"
|
| 660 |
print("=" * 80)
|
| 661 |
yield
|
| 662 |
print("Shutting down...")
|
|
@@ -3012,7 +3012,7 @@ async def fetch_and_save_news(limit: int = 50):
|
|
| 3012 |
conn.commit()
|
| 3013 |
conn.close()
|
| 3014 |
|
| 3015 |
-
logger.info(f"
|
| 3016 |
|
| 3017 |
return {
|
| 3018 |
"success": True,
|
|
|
|
| 110 |
|
| 111 |
conn.commit()
|
| 112 |
conn.close()
|
| 113 |
+
print(f"[OK] Database initialized at {DB_PATH}")
|
| 114 |
|
| 115 |
|
| 116 |
def save_price_to_db(price_data: Dict[str, Any]):
|
|
|
|
| 616 |
async def lifespan(app: FastAPI):
|
| 617 |
"""Application lifespan manager"""
|
| 618 |
print("=" * 80)
|
| 619 |
+
print("Starting Crypto Monitor Admin API")
|
| 620 |
print("=" * 80)
|
| 621 |
init_database()
|
| 622 |
|
| 623 |
# Load providers
|
| 624 |
config = load_providers_config()
|
| 625 |
_provider_state["providers"] = config.get("providers", {})
|
| 626 |
+
print(f"[OK] Loaded {len(_provider_state['providers'])} providers from config")
|
| 627 |
|
| 628 |
# Load auto-discovery report
|
| 629 |
apl_report = load_auto_discovery_report()
|
| 630 |
if apl_report:
|
| 631 |
+
print(f"[OK] Loaded auto-discovery report with validation data")
|
| 632 |
|
| 633 |
# Load API registry
|
| 634 |
api_registry = load_api_registry()
|
| 635 |
if api_registry:
|
| 636 |
metadata = api_registry.get("metadata", {})
|
| 637 |
+
print(f"[OK] Loaded API registry: {metadata.get('name', 'unknown')} v{metadata.get('version', 'unknown')}")
|
| 638 |
|
| 639 |
# Initialize AI models
|
| 640 |
try:
|
| 641 |
from ai_models import initialize_models, registry_status
|
| 642 |
model_init_result = initialize_models()
|
| 643 |
registry_info = registry_status()
|
| 644 |
+
print(f"[OK] AI Models initialized: {model_init_result}")
|
| 645 |
+
print(f"[OK] HF Registry status: {registry_info}")
|
| 646 |
except Exception as e:
|
| 647 |
+
print(f"[WARN] AI Models initialization failed: {e}")
|
| 648 |
|
| 649 |
# Validate unified resources
|
| 650 |
try:
|
| 651 |
from backend.services.resource_validator import validate_unified_resources
|
| 652 |
validation_report = validate_unified_resources(str(WORKSPACE_ROOT / "api-resources" / "crypto_resources_unified_2025-11-11.json"))
|
| 653 |
+
print(f"[OK] Resource validation: {validation_report['local_backend_routes']['routes_count']} local routes")
|
| 654 |
if validation_report['local_backend_routes']['duplicate_signatures'] > 0:
|
| 655 |
+
print(f"[WARN] Found {validation_report['local_backend_routes']['duplicate_signatures']} duplicate route signatures")
|
| 656 |
except Exception as e:
|
| 657 |
+
print(f"[WARN] Resource validation failed: {e}")
|
| 658 |
|
| 659 |
+
print(f"[OK] Server ready on port {PORT}")
|
| 660 |
print("=" * 80)
|
| 661 |
yield
|
| 662 |
print("Shutting down...")
|
|
|
|
| 3012 |
conn.commit()
|
| 3013 |
conn.close()
|
| 3014 |
|
| 3015 |
+
logger.info(f"[OK] Saved {saved_count} news articles to database")
|
| 3016 |
|
| 3017 |
return {
|
| 3018 |
"success": True,
|