Spaces:
				
			
			
	
			
			
		Runtime error
		
	
	
	
			
			
	
	
	
	
		
		
		Runtime error
		
	| import requests | |
| import os | |
| import time | |
| from datetime import datetime | |
| import sys | |
| def check_space(): | |
| url = "https://huggingface.co/api/spaces/nananie143/Agentic_llm" | |
| headers = {"Authorization": f"Bearer {os.environ['HUGGINGFACE_TOKEN']}"} | |
| try: | |
| response = requests.get(url, headers=headers) | |
| if response.ok: | |
| data = response.json() | |
| runtime = data.get('runtime', {}) | |
| stage = runtime.get('stage', 'UNKNOWN') | |
| hardware = runtime.get('hardware', {}) | |
| domains = runtime.get('domains', [{}])[0] | |
| status_time = datetime.now().strftime('%H:%M:%S') | |
| sys.stdout.write(f"\n[{status_time}] Space Status:\n") | |
| sys.stdout.write(f"Stage: {stage}\n") | |
| sys.stdout.write(f"Hardware: {hardware.get('current', 'Not assigned')} (requested: {hardware.get('requested', 'None')})\n") | |
| sys.stdout.write(f"Domain: {domains.get('domain', 'Not assigned')} (status: {domains.get('stage', 'Unknown')})\n") | |
| sys.stdout.flush() | |
| if stage == "RUNNING": | |
| sys.stdout.write("\nπ Space is now running!\n") | |
| sys.stdout.write(f"Access your Space at: https://{domains.get('domain', 'nananie143-agentic-llm.hf.space')}\n") | |
| sys.stdout.flush() | |
| return True | |
| elif stage == "FAILED": | |
| sys.stdout.write("\nβ Space build failed!\n") | |
| sys.stdout.flush() | |
| return True | |
| return False | |
| except Exception as e: | |
| sys.stdout.write(f"\n[{datetime.now().strftime('%H:%M:%S')}] Error checking status: {e}\n") | |
| sys.stdout.flush() | |
| return False | |
| sys.stdout.write("\nStarting automatic Space status check...\n") | |
| sys.stdout.write("Will check every 2 minutes until the Space is running or fails...\n") | |
| sys.stdout.write("Press Ctrl+C to stop checking\n\n") | |
| sys.stdout.flush() | |
| while True: | |
| should_stop = check_space() | |
| if should_stop: | |
| break | |
| time.sleep(120) # Wait 2 minutes | |