""" Simple script to fetch and display HF Space logs """ import os from huggingface_hub import HfApi YOUR_USERNAME = "nocapdev" SPACE_NAME = "my-gradio-momask" TOKEN = os.getenv("HUGGINGFACE_TOKEN") print("=" * 80) print(" " * 25 + "HF Space Log Viewer") print("=" * 80) if not TOKEN: print("\nāš ļø HUGGINGFACE_TOKEN not set") print("Manual access:") print(f"Visit: https://huggingface.co/spaces/{YOUR_USERNAME}/{SPACE_NAME}/logs") else: api = HfApi(token=TOKEN) repo_id = f"{YOUR_USERNAME}/{SPACE_NAME}" print(f"\nšŸ“ Space: {repo_id}") print(f"šŸ”— Logs: https://huggingface.co/spaces/{repo_id}/logs") try: print("\n" + "─" * 80) print("šŸ”§ SPACE STATUS") print("─" * 80) runtime = api.get_space_runtime(repo_id=repo_id) print(f"\nStatus: {runtime.stage}") hardware = str(runtime.hardware) if runtime.hardware else "CPU basic (free tier)" print(f"Hardware: {hardware}") if runtime.stage == "RUNNING": print("āœ… Space is RUNNING") elif runtime.stage == "BUILDING": print("ā³ Space is BUILDING") elif runtime.stage == "STOPPED": print("āš ļø Space STOPPED (may have crashed)") # Hardware warning if not runtime.hardware or 'cpu' in str(runtime.hardware).lower(): print("\nāš ļø PERFORMANCE WARNING:") print(" Using CPU (free tier)") print(" Expected generation time: 15-30 minutes per prompt") print(" This is NORMAL for free tier!") print("\n" + "─" * 80) print("šŸ“‹ WHAT TO CHECK IN LOGS") print("─" * 80) print("\n1. Visit the logs manually:") print(f" https://huggingface.co/spaces/{repo_id}/logs") print("\n2. Look for these key lines:") print(" • 'Using device: cpu' or 'Using device: cuda'") print(" • 'Loading models...'") print(" • 'Models loaded successfully!'") print(" • Any lines with 'ERROR' or 'Exception'") print(" • 'Model checkpoints not found'") print(" • '[1/4] Generating motion tokens...'") print("\n3. Common issues to look for:") print(" • FileNotFoundError → Models not uploaded") print(" • Killed/SIGKILL → Out of memory") print(" • Stuck at [1/4] → CPU is slow (wait 20 mins)") print("\n" + "─" * 80) print("šŸ’” NEXT STEPS") print("─" * 80) print("\n1. Click the link above to view logs") print("2. Copy the LAST 50 LINES from the logs") print("3. Share them here so I can diagnose the issue") print("\nSpecifically look for:") print(" • Any ERROR messages") print(" • Any Exception or Traceback") print(" • What happened after you submitted your prompt") except Exception as e: print(f"\nāŒ Error: {e}") print(f"\nManual check required:") print(f"Visit: https://huggingface.co/spaces/{repo_id}/logs") print("\n" + "=" * 80)