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")
|