File size: 1,267 Bytes
5a81b95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

import sys
import os
from huggingface_hub import HfApi

# Force UTF-8 encoding for stdout/stderr to handle emojis
sys.stdout.reconfigure(encoding='utf-8')
sys.stderr.reconfigure(encoding='utf-8')

SPACE_ID = "Kraft102/widgetdc-cortex"

def fetch_logs():
    api = HfApi()
    print(f"📊 Fetching status for Space: {SPACE_ID}")
    
    try:
        # Get Space Status
        info = api.space_info(repo_id=SPACE_ID)
        print(f"   Status: {info.runtime.stage}")
        print(f"   Hardware: {info.runtime.hardware}")
        
        # Unfortunately, getting raw logs programmatically via this API is limited without specific calls.
        # But we can try to see if there are any hints in the runtime info.
        
        # If the stage is "BUILD_ERROR" or "RUNTIME_ERROR", it's bad.
        if info.runtime.stage in ["BUILD_ERROR", "RUNTIME_ERROR"]:
            print(f"❌ Critical Error: {info.runtime.stage}")
        elif info.runtime.stage == "RUNNING":
            print(f"✅ Space is marked RUNNING (but might be failing health check)")
        else:
            print(f"⏳ Status: {info.runtime.stage} (Building/Starting)")

    except Exception as e:
        print(f"❌ Failed to fetch info: {e}")

if __name__ == "__main__":
    fetch_logs()