anderson-ufrj commited on
Commit
dbf0a5e
·
1 Parent(s): 0d31b85

test: add HuggingFace Spaces deployment test

Browse files
Files changed (1) hide show
  1. test_hf_spaces.py +74 -0
test_hf_spaces.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ 🔍 Teste de HuggingFace Spaces
4
+ Verifica se os Spaces estão rodando e quais endpoints respondem
5
+ """
6
+
7
+ import asyncio
8
+ import httpx
9
+
10
+ async def test_hf_spaces():
11
+ """🔍 Testa diferentes endpoints dos HF Spaces"""
12
+ print("🔍 VERIFICANDO HUGGINGFACE SPACES")
13
+ print("=" * 50)
14
+
15
+ # URLs para testar
16
+ backend_urls = [
17
+ "https://neural-thinker-cidadao-ai-backend.hf.space",
18
+ "https://neural-thinker-cidadao-ai-backend.hf.space/",
19
+ "https://neural-thinker-cidadao-ai-backend.hf.space/health",
20
+ "https://neural-thinker-cidadao-ai-backend.hf.space/docs",
21
+ "https://huggingface.co/spaces/neural-thinker/cidadao.ai-backend"
22
+ ]
23
+
24
+ models_urls = [
25
+ "https://neural-thinker-cidadao-ai-models.hf.space",
26
+ "https://neural-thinker-cidadao-ai-models.hf.space/",
27
+ "https://neural-thinker-cidadao-ai-models.hf.space/health",
28
+ "https://huggingface.co/spaces/neural-thinker/cidadao.ai-models"
29
+ ]
30
+
31
+ async with httpx.AsyncClient(timeout=10.0) as client:
32
+
33
+ print("🏛️ TESTANDO BACKEND SPACES:")
34
+ for url in backend_urls:
35
+ try:
36
+ response = await client.get(url)
37
+ status = "✅" if response.status_code == 200 else f"❌ {response.status_code}"
38
+ print(f" {status} {url}")
39
+
40
+ if response.status_code == 200 and 'application/json' in response.headers.get('content-type', ''):
41
+ try:
42
+ data = response.json()
43
+ if 'status' in data:
44
+ print(f" 📊 Status: {data.get('status')}")
45
+ if 'agents' in data:
46
+ print(f" 🤖 Agentes: {list(data.get('agents', {}).keys())}")
47
+ except:
48
+ print(f" 📝 HTML response (não JSON)")
49
+
50
+ except Exception as e:
51
+ print(f" ❌ {url} - Erro: {str(e)[:50]}...")
52
+
53
+ print("\n🤖 TESTANDO MODELS SPACES:")
54
+ for url in models_urls:
55
+ try:
56
+ response = await client.get(url)
57
+ status = "✅" if response.status_code == 200 else f"❌ {response.status_code}"
58
+ print(f" {status} {url}")
59
+
60
+ if response.status_code == 200 and 'application/json' in response.headers.get('content-type', ''):
61
+ try:
62
+ data = response.json()
63
+ if 'api' in data:
64
+ print(f" 📊 API: {data.get('api')}")
65
+ if 'version' in data:
66
+ print(f" 🔢 Version: {data.get('version')}")
67
+ except:
68
+ print(f" 📝 HTML response (não JSON)")
69
+
70
+ except Exception as e:
71
+ print(f" ❌ {url} - Erro: {str(e)[:50]}...")
72
+
73
+ if __name__ == "__main__":
74
+ asyncio.run(test_hf_spaces())