import sys | |
from pathlib import Path | |
# Add project root to path | |
project_root = Path(__file__).parent | |
sys.path.append(str(project_root)) | |
from services.hf_endpoint_monitor import hf_monitor | |
def test_hf_monitor(): | |
"""Test the HF endpoint monitor""" | |
print("=== HF Endpoint Monitor Test ===") | |
print() | |
# Show current status | |
print("Current HF Endpoint Status:") | |
status = hf_monitor.check_endpoint_status() | |
print(f" Available: {status['available']}") | |
print(f" Status Code: {status['status_code']}") | |
print(f" Initialized: {status.get('initialized', 'Unknown')}") | |
if 'error' in status: | |
print(f" Error: {status['error']}") | |
print() | |
# Show human-readable status | |
print("Human-Readable Status:") | |
print(hf_monitor.get_status_summary()) | |
print() | |
# Try to warm up endpoint if not available | |
if not status['available']: | |
print("Attempting to warm up endpoint...") | |
success = hf_monitor.warm_up_endpoint() | |
print(f"Warm-up result: {'Success' if success else 'Failed'}") | |
print() | |
# Check status again | |
print("Status after warm-up attempt:") | |
print(hf_monitor.get_status_summary()) | |
if __name__ == "__main__": | |
test_hf_monitor() | |