#!/usr/bin/env python3 """Test API connection to HF Space""" import sys sys.stdout.reconfigure(encoding='utf-8', errors='replace') import os from dotenv import load_dotenv load_dotenv() from gradio_client import Client hf_token = os.getenv("HF_TOKEN") print("Attempting to connect to Space...", flush=True) try: client = Client("evgueni-p/fbmc-chronos2", hf_token=hf_token) print("[OK] Connected successfully!", flush=True) # Check available endpoints print("\nAvailable API endpoints:", flush=True) print(f"Endpoints: {client.endpoints}", flush=True) print("\nSpace is running. Testing smoke test API call...", flush=True) # Try a smoke test - let Gradio auto-detect the endpoint result = client.predict( "2025-09-30", # run_date "smoke_test", # forecast_type ) print(f"[OK] API call successful!", flush=True) print(f"Result file: {result}", flush=True) except Exception as e: print(f"[ERROR] {type(e).__name__}: {str(e)}", flush=True) import traceback traceback.print_exc()