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