Spaces:
Sleeping
Sleeping
Thanh Quang commited on
Commit ·
122cdd6
1
Parent(s): e61da91
fix: proxy monitoring through Gradio SSR
Browse files- README.md +1 -1
- src/monitoring.py +1 -1
- tests/test_api.py +3 -3
- tests/test_entrypoints.py +2 -2
README.md
CHANGED
|
@@ -258,7 +258,7 @@ The same summary is available from the running FastAPI or Gradio application:
|
|
| 258 |
|
| 259 |
```bash
|
| 260 |
curl -H "X-API-Key: $RAG_API_KEY" \
|
| 261 |
-
http://127.0.0.1:7860/
|
| 262 |
```
|
| 263 |
|
| 264 |
The monitoring route returns `404` when `RAG_API_KEY` is not configured and
|
|
|
|
| 258 |
|
| 259 |
```bash
|
| 260 |
curl -H "X-API-Key: $RAG_API_KEY" \
|
| 261 |
+
http://127.0.0.1:7860/monitoring/retrieval/summary
|
| 262 |
```
|
| 263 |
|
| 264 |
The monitoring route returns `404` when `RAG_API_KEY` is not configured and
|
src/monitoring.py
CHANGED
|
@@ -8,7 +8,7 @@ from fastapi import FastAPI, Header, HTTPException, status
|
|
| 8 |
from src.config import settings
|
| 9 |
from src.retrieval_telemetry import load_retrieval_summary
|
| 10 |
|
| 11 |
-
MONITORING_PATH = "/
|
| 12 |
|
| 13 |
|
| 14 |
def retrieval_monitoring(
|
|
|
|
| 8 |
from src.config import settings
|
| 9 |
from src.retrieval_telemetry import load_retrieval_summary
|
| 10 |
|
| 11 |
+
MONITORING_PATH = "/monitoring/retrieval/summary"
|
| 12 |
|
| 13 |
|
| 14 |
def retrieval_monitoring(
|
tests/test_api.py
CHANGED
|
@@ -40,7 +40,7 @@ def test_configured_api_key_protects_documents(monkeypatch) -> None:
|
|
| 40 |
def test_monitoring_endpoint_is_disabled_without_api_key(monkeypatch) -> None:
|
| 41 |
monkeypatch.setattr(settings, "api_key", None)
|
| 42 |
|
| 43 |
-
response = TestClient(app).get("/
|
| 44 |
|
| 45 |
assert response.status_code == 404
|
| 46 |
|
|
@@ -53,9 +53,9 @@ def test_monitoring_endpoint_requires_key_and_returns_summary(monkeypatch) -> No
|
|
| 53 |
)
|
| 54 |
client = TestClient(app)
|
| 55 |
|
| 56 |
-
assert client.get("/
|
| 57 |
response = client.get(
|
| 58 |
-
"/
|
| 59 |
headers={"X-API-Key": "test-secret"},
|
| 60 |
)
|
| 61 |
|
|
|
|
| 40 |
def test_monitoring_endpoint_is_disabled_without_api_key(monkeypatch) -> None:
|
| 41 |
monkeypatch.setattr(settings, "api_key", None)
|
| 42 |
|
| 43 |
+
response = TestClient(app).get("/monitoring/retrieval/summary")
|
| 44 |
|
| 45 |
assert response.status_code == 404
|
| 46 |
|
|
|
|
| 53 |
)
|
| 54 |
client = TestClient(app)
|
| 55 |
|
| 56 |
+
assert client.get("/monitoring/retrieval/summary").status_code == 401
|
| 57 |
response = client.get(
|
| 58 |
+
"/monitoring/retrieval/summary",
|
| 59 |
headers={"X-API-Key": "test-secret"},
|
| 60 |
)
|
| 61 |
|
tests/test_entrypoints.py
CHANGED
|
@@ -34,7 +34,7 @@ def test_api_exposes_complete_learning_surface() -> None:
|
|
| 34 |
"/summarize",
|
| 35 |
"/quiz",
|
| 36 |
"/flashcards",
|
| 37 |
-
"/
|
| 38 |
} <= routes
|
| 39 |
|
| 40 |
|
|
@@ -44,6 +44,6 @@ def test_gradio_app_imports_without_optional_logo() -> None:
|
|
| 44 |
|
| 45 |
assert demo is not None
|
| 46 |
assert any(
|
| 47 |
-
getattr(route, "path", None) == "/
|
| 48 |
for route in demo.app.routes
|
| 49 |
)
|
|
|
|
| 34 |
"/summarize",
|
| 35 |
"/quiz",
|
| 36 |
"/flashcards",
|
| 37 |
+
"/monitoring/retrieval/summary",
|
| 38 |
} <= routes
|
| 39 |
|
| 40 |
|
|
|
|
| 44 |
|
| 45 |
assert demo is not None
|
| 46 |
assert any(
|
| 47 |
+
getattr(route, "path", None) == "/monitoring/retrieval/summary"
|
| 48 |
for route in demo.app.routes
|
| 49 |
)
|