|
import sys |
|
from pathlib import Path |
|
import asyncio |
|
|
|
|
|
project_root = Path(__file__).parent |
|
sys.path.append(str(project_root)) |
|
|
|
from core.coordinator import coordinator |
|
from core.session import session_manager |
|
from services.hf_endpoint_monitor import hf_monitor |
|
from utils.config import config |
|
|
|
def test_hf_space_readiness(): |
|
"""Test if system is ready for HF Space deployment""" |
|
print("=== HF Space Deployment Readiness Test ===") |
|
print() |
|
|
|
readiness_score = 0 |
|
total_tests = 5 |
|
|
|
|
|
print("1. Core Infrastructure:") |
|
try: |
|
from core.redis_client import redis_client |
|
from core.llm_factory import llm_factory |
|
print("β
Core modules import successfully") |
|
readiness_score += 1 |
|
except Exception as e: |
|
print(f"β Core modules failed: {e}") |
|
print() |
|
|
|
|
|
print("2. Coordinator System:") |
|
try: |
|
|
|
test_coordinator = coordinator |
|
print("β
Coordinator system ready") |
|
readiness_score += 1 |
|
except Exception as e: |
|
print(f"β Coordinator system failed: {e}") |
|
print() |
|
|
|
|
|
print("3. Service Monitors:") |
|
try: |
|
|
|
hf_monitor_instance = hf_monitor |
|
print("β
Service monitors ready") |
|
readiness_score += 1 |
|
except Exception as e: |
|
print(f"β Service monitors failed: {e}") |
|
print() |
|
|
|
|
|
print("4. Session Management:") |
|
try: |
|
|
|
session = session_manager.get_session("test_user_hf") |
|
session_manager.clear_session("test_user_hf") |
|
print("β
Session management ready") |
|
readiness_score += 1 |
|
except Exception as e: |
|
print(f"β Session management failed: {e}") |
|
print() |
|
|
|
|
|
print("5. Configuration Awareness:") |
|
print(f" HF Space Detected: {'β
' if config.is_hf_space else 'βΉοΈ Local'}") |
|
print(f" Ollama Configured: {'β
' if config.ollama_host else 'β'}") |
|
print(f" HF Token Available: {'β
' if config.hf_token else 'β'}") |
|
readiness_score += 1 |
|
print() |
|
|
|
|
|
print("=== Readiness Assessment ===") |
|
percentage = (readiness_score / total_tests) * 100 |
|
print(f"Readiness Score: {readiness_score}/{total_tests} ({percentage:.0f}%)") |
|
|
|
if percentage >= 80: |
|
print("π System is ready for HF Space deployment!") |
|
print("β
All core systems operational") |
|
print("β
Coordinator architecture implemented") |
|
print("β
Service monitoring ready") |
|
else: |
|
print("β οΈ System needs attention before HF Space deployment") |
|
|
|
return readiness_score >= 4 |
|
|
|
if __name__ == "__main__": |
|
test_hf_space_readiness() |
|
|