anderson-ufrj
commited on
Commit
·
cecd7e5
1
Parent(s):
a02ad56
test(e2e): add HuggingFace Spaces deployment verification
Browse files
tests/e2e/test_hf_spaces_deployment.py
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Simple test to check HuggingFace Space deployment
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import asyncio
|
| 7 |
+
import httpx
|
| 8 |
+
|
| 9 |
+
async def test_hf_space():
|
| 10 |
+
"""Test HuggingFace Space is running."""
|
| 11 |
+
|
| 12 |
+
print("🧪 TESTING HUGGINGFACE SPACE DEPLOYMENT")
|
| 13 |
+
print("=" * 50)
|
| 14 |
+
|
| 15 |
+
base_url = "https://neural-thinker-cidadao-ai-models.hf.space"
|
| 16 |
+
|
| 17 |
+
async with httpx.AsyncClient(timeout=30.0) as client:
|
| 18 |
+
try:
|
| 19 |
+
# Test health endpoint
|
| 20 |
+
print("1️⃣ TESTING HEALTH ENDPOINT")
|
| 21 |
+
print("-" * 30)
|
| 22 |
+
|
| 23 |
+
response = await client.get(f"{base_url}/health")
|
| 24 |
+
print(f"Status: {response.status_code}")
|
| 25 |
+
|
| 26 |
+
if response.status_code == 200:
|
| 27 |
+
health_data = response.json()
|
| 28 |
+
print("✅ HuggingFace Space is healthy")
|
| 29 |
+
print(f"Service: {health_data.get('service', 'unknown')}")
|
| 30 |
+
print(f"Status: {health_data.get('status', 'unknown')}")
|
| 31 |
+
print(f"Version: {health_data.get('version', 'unknown')}")
|
| 32 |
+
else:
|
| 33 |
+
print(f"❌ Health check failed: {response.status_code}")
|
| 34 |
+
print(f"Response: {response.text}")
|
| 35 |
+
|
| 36 |
+
print()
|
| 37 |
+
|
| 38 |
+
# Test root endpoint
|
| 39 |
+
print("2️⃣ TESTING ROOT ENDPOINT")
|
| 40 |
+
print("-" * 30)
|
| 41 |
+
|
| 42 |
+
response = await client.get(f"{base_url}/")
|
| 43 |
+
print(f"Status: {response.status_code}")
|
| 44 |
+
|
| 45 |
+
if response.status_code == 200:
|
| 46 |
+
print("✅ Root endpoint accessible")
|
| 47 |
+
# Don't print full HTML response
|
| 48 |
+
if "html" in response.headers.get("content-type", ""):
|
| 49 |
+
print("📄 HTML interface available")
|
| 50 |
+
else:
|
| 51 |
+
print(f"Response: {response.text[:200]}...")
|
| 52 |
+
else:
|
| 53 |
+
print(f"❌ Root endpoint failed: {response.status_code}")
|
| 54 |
+
|
| 55 |
+
print()
|
| 56 |
+
|
| 57 |
+
# Test docs endpoint
|
| 58 |
+
print("3️⃣ TESTING DOCS ENDPOINT")
|
| 59 |
+
print("-" * 30)
|
| 60 |
+
|
| 61 |
+
response = await client.get(f"{base_url}/docs")
|
| 62 |
+
print(f"Status: {response.status_code}")
|
| 63 |
+
|
| 64 |
+
if response.status_code == 200:
|
| 65 |
+
print("✅ API docs accessible")
|
| 66 |
+
else:
|
| 67 |
+
print(f"⚠️ Docs not available: {response.status_code}")
|
| 68 |
+
|
| 69 |
+
except Exception as e:
|
| 70 |
+
print(f"❌ Connection failed: {e}")
|
| 71 |
+
print("💡 HuggingFace Space may still be building...")
|
| 72 |
+
return False
|
| 73 |
+
|
| 74 |
+
print()
|
| 75 |
+
print("🏁 HUGGINGFACE SPACE TEST COMPLETE")
|
| 76 |
+
print("=" * 50)
|
| 77 |
+
return True
|
| 78 |
+
|
| 79 |
+
if __name__ == "__main__":
|
| 80 |
+
print("🤖 CIDADÃO.AI MODELS DEPLOYMENT TEST")
|
| 81 |
+
print()
|
| 82 |
+
|
| 83 |
+
try:
|
| 84 |
+
success = asyncio.run(test_hf_space())
|
| 85 |
+
if success:
|
| 86 |
+
print("✅ Test completed successfully!")
|
| 87 |
+
else:
|
| 88 |
+
print("❌ Test failed!")
|
| 89 |
+
except KeyboardInterrupt:
|
| 90 |
+
print("\n⚠️ Test interrupted by user")
|
| 91 |
+
except Exception as e:
|
| 92 |
+
print(f"\n❌ Test failed with error: {e}")
|