SIngtel-Bill-Scanner / spaces_monitor.py
Cosmo125's picture
Upload 26 files
795183d verified
"""
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")