File size: 3,845 Bytes
795183d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
"""

Monitor the Hugging Face Spaces upload and deployment

"""

import time
import requests

def check_space_status(repo_id="Cosmo125/Singtel_Bill_Scanner"):
    """Check if the Hugging Face Space is live"""
    try:
        url = f"https://huggingface.co/spaces/{repo_id}"
        response = requests.get(url, timeout=10)
        
        if response.status_code == 200:
            if "Building" in response.text:
                return "building"
            elif "Runtime error" in response.text:
                return "error"
            else:
                return "live"
        else:
            return "not_found"
    except Exception:
        return "checking"

def monitor_deployment():
    """Monitor the deployment progress"""
    print("πŸš€ HUGGING FACE SPACES DEPLOYMENT MONITOR")
    print("=" * 50)
    
    repo_id = "Cosmo125/Singtel_Bill_Scanner"
    space_url = f"https://huggingface.co/spaces/{repo_id}"
    
    print(f"πŸ“± Space URL: {space_url}")
    print("⏳ Monitoring deployment status...")
    print()
    
    for i in range(20):  # Check for up to 20 iterations (10 minutes)
        status = check_space_status(repo_id)
        timestamp = time.strftime("%H:%M:%S")
        
        if status == "live":
            print(f"πŸŽ‰ [{timestamp}] SUCCESS! Your app is LIVE!")
            print("βœ… Deployment completed successfully!")
            break
        elif status == "building":
            print(f"πŸ”¨ [{timestamp}] Building... (this is normal)")
        elif status == "error":
            print(f"❌ [{timestamp}] Runtime error detected")
            print("πŸ’‘ Check the logs at the space URL")
            break
        elif status == "not_found":
            print(f"πŸ“€ [{timestamp}] Upload in progress...")
        else:
            print(f"πŸ” [{timestamp}] Checking status...")
        
        if i < 19:  # Don't wait after the last check
            time.sleep(30)  # Wait 30 seconds between checks
    
    print(f"\nπŸ”— Visit your space: {space_url}")
    print("πŸ’‘ If still building, wait a few more minutes and refresh")

def show_quick_status():
    """Show quick status without monitoring"""
    print("πŸ“± SINGTEL BILL SCANNER - SPACES STATUS")
    print("=" * 45)
    
    repo_id = "Cosmo125/Singtel_Bill_Scanner"
    space_url = f"https://huggingface.co/spaces/{repo_id}"
    
    print(f"πŸ”— Space URL: {space_url}")
    print()
    
    status = check_space_status(repo_id)
    
    if status == "live":
        print("πŸŽ‰ STATUS: LIVE AND READY!")
        print("βœ… Your app is working and accessible")
    elif status == "building":
        print("πŸ”¨ STATUS: BUILDING...")
        print("⏳ Please wait 2-3 more minutes")
    elif status == "error":
        print("❌ STATUS: ERROR")
        print("πŸ”§ Check the space for error details")
    elif status == "not_found":
        print("πŸ“€ STATUS: UPLOAD IN PROGRESS")
        print("⏳ Still uploading files to Hugging Face")
    else:
        print("πŸ” STATUS: CHECKING...")
        print("⏳ Unable to determine status right now")
    
    print()
    print("🎯 What to expect:")
    print("   πŸ“€ Upload: Files being transferred")
    print("   πŸ”¨ Building: Installing dependencies")
    print("   πŸš€ Live: Ready for use!")

if __name__ == "__main__":
    import sys
    
    if len(sys.argv) > 1 and sys.argv[1] == "monitor":
        monitor_deployment()
    else:
        show_quick_status()
        
        choice = input("\nStart continuous monitoring? (y/n): ").lower()
        if choice in ['y', 'yes']:
            print("\n" + "="*50)
            monitor_deployment()
        else:
            print("πŸ’‘ Run 'python spaces_monitor.py monitor' for continuous monitoring")