Spaces:
Sleeping
Sleeping
GAIA Developer
Claude
commited on
Commit
Β·
7724e0e
1
Parent(s):
35c9619
π Add comprehensive startup health check for deployment monitoring
Browse filesAdded startup diagnostics to catch deployment issues early:
- Verify all critical files exist in expected locations
- Test GAIASolver import before app starts
- Check environment variables are properly set
- Detailed logging for troubleshooting
- Applied to both /home/user/app.py and /home/user/app/app.py
This will prevent silent failures and provide clear diagnostics
if deployment issues occur in the future.
π€ Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- app.py +51 -0
- app/app.py +51 -0
app.py
CHANGED
|
@@ -19,6 +19,57 @@ from pathlib import Path
|
|
| 19 |
sys.path.insert(0, '/home/user/app')
|
| 20 |
sys.path.insert(0, '/home/user')
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
# --- Constants ---
|
| 23 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 24 |
|
|
|
|
| 19 |
sys.path.insert(0, '/home/user/app')
|
| 20 |
sys.path.insert(0, '/home/user')
|
| 21 |
|
| 22 |
+
# --- Startup Health Check ---
|
| 23 |
+
def startup_health_check():
|
| 24 |
+
"""Comprehensive startup health check to catch deployment issues early."""
|
| 25 |
+
print("π Running startup health check...")
|
| 26 |
+
issues = []
|
| 27 |
+
|
| 28 |
+
# Check critical files exist
|
| 29 |
+
critical_files = [
|
| 30 |
+
'/home/user/app/main.py',
|
| 31 |
+
'/home/user/app/gaia_tools.py',
|
| 32 |
+
'/home/user/app/question_classifier.py',
|
| 33 |
+
'/home/user/main.py',
|
| 34 |
+
'/home/user/gaia_tools.py',
|
| 35 |
+
'/home/user/question_classifier.py'
|
| 36 |
+
]
|
| 37 |
+
|
| 38 |
+
for file_path in critical_files:
|
| 39 |
+
if not os.path.exists(file_path):
|
| 40 |
+
issues.append(f"Missing critical file: {file_path}")
|
| 41 |
+
else:
|
| 42 |
+
print(f"β
Found: {file_path}")
|
| 43 |
+
|
| 44 |
+
# Test GAIASolver import
|
| 45 |
+
try:
|
| 46 |
+
from main import GAIASolver
|
| 47 |
+
print("β
GAIASolver import successful")
|
| 48 |
+
except Exception as e:
|
| 49 |
+
issues.append(f"GAIASolver import failed: {e}")
|
| 50 |
+
print(f"β GAIASolver import failed: {e}")
|
| 51 |
+
|
| 52 |
+
# Test environment variables
|
| 53 |
+
env_vars = ['GEMINI_API_KEY', 'HUGGINGFACE_TOKEN']
|
| 54 |
+
for var in env_vars:
|
| 55 |
+
if os.getenv(var):
|
| 56 |
+
print(f"β
Environment variable {var} is set")
|
| 57 |
+
else:
|
| 58 |
+
print(f"β οΈ Environment variable {var} not found")
|
| 59 |
+
|
| 60 |
+
# Report results
|
| 61 |
+
if issues:
|
| 62 |
+
print(f"β Startup health check found {len(issues)} issues:")
|
| 63 |
+
for issue in issues:
|
| 64 |
+
print(f" - {issue}")
|
| 65 |
+
return False
|
| 66 |
+
else:
|
| 67 |
+
print("β
Startup health check passed!")
|
| 68 |
+
return True
|
| 69 |
+
|
| 70 |
+
# Run health check
|
| 71 |
+
startup_health_check()
|
| 72 |
+
|
| 73 |
# --- Constants ---
|
| 74 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 75 |
|
app/app.py
CHANGED
|
@@ -19,6 +19,57 @@ from pathlib import Path
|
|
| 19 |
sys.path.insert(0, '/home/user/app')
|
| 20 |
sys.path.insert(0, '/home/user')
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
# --- Constants ---
|
| 23 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 24 |
|
|
|
|
| 19 |
sys.path.insert(0, '/home/user/app')
|
| 20 |
sys.path.insert(0, '/home/user')
|
| 21 |
|
| 22 |
+
# --- Startup Health Check ---
|
| 23 |
+
def startup_health_check():
|
| 24 |
+
"""Comprehensive startup health check to catch deployment issues early."""
|
| 25 |
+
print("π Running startup health check...")
|
| 26 |
+
issues = []
|
| 27 |
+
|
| 28 |
+
# Check critical files exist
|
| 29 |
+
critical_files = [
|
| 30 |
+
'/home/user/app/main.py',
|
| 31 |
+
'/home/user/app/gaia_tools.py',
|
| 32 |
+
'/home/user/app/question_classifier.py',
|
| 33 |
+
'/home/user/main.py',
|
| 34 |
+
'/home/user/gaia_tools.py',
|
| 35 |
+
'/home/user/question_classifier.py'
|
| 36 |
+
]
|
| 37 |
+
|
| 38 |
+
for file_path in critical_files:
|
| 39 |
+
if not os.path.exists(file_path):
|
| 40 |
+
issues.append(f"Missing critical file: {file_path}")
|
| 41 |
+
else:
|
| 42 |
+
print(f"β
Found: {file_path}")
|
| 43 |
+
|
| 44 |
+
# Test GAIASolver import
|
| 45 |
+
try:
|
| 46 |
+
from main import GAIASolver
|
| 47 |
+
print("β
GAIASolver import successful")
|
| 48 |
+
except Exception as e:
|
| 49 |
+
issues.append(f"GAIASolver import failed: {e}")
|
| 50 |
+
print(f"β GAIASolver import failed: {e}")
|
| 51 |
+
|
| 52 |
+
# Test environment variables
|
| 53 |
+
env_vars = ['GEMINI_API_KEY', 'HUGGINGFACE_TOKEN']
|
| 54 |
+
for var in env_vars:
|
| 55 |
+
if os.getenv(var):
|
| 56 |
+
print(f"β
Environment variable {var} is set")
|
| 57 |
+
else:
|
| 58 |
+
print(f"β οΈ Environment variable {var} not found")
|
| 59 |
+
|
| 60 |
+
# Report results
|
| 61 |
+
if issues:
|
| 62 |
+
print(f"β Startup health check found {len(issues)} issues:")
|
| 63 |
+
for issue in issues:
|
| 64 |
+
print(f" - {issue}")
|
| 65 |
+
return False
|
| 66 |
+
else:
|
| 67 |
+
print("β
Startup health check passed!")
|
| 68 |
+
return True
|
| 69 |
+
|
| 70 |
+
# Run health check
|
| 71 |
+
startup_health_check()
|
| 72 |
+
|
| 73 |
# --- Constants ---
|
| 74 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 75 |
|