app/: the web app in its own folder, with the Images and Labeling pages (D-138)
- app/serveur/ (FastAPI) and app/web/ (React, Mantine) moved out of API/, which keeps
only the agents; the Support page drives them
- Images page: view.py in React (slider, zoom, sensor names, displacement arrows on a range)
- Labeling page: labeling.py in React (two aligned plots, label bar, add, edit, delete);
labels are written to labeling/{auto,manual}/ of the repo (AIMSIGHT_LABELS)
- shared station and date selector kept in the address; buttons from a support session
- app/serveur/station.py: the data of both pages, copied computations listed in app/README.md
- app/serveur/check.py: server and station checks (labels in a temporary folder)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
374d91eb15
commit
bd93e708d2
26 files changed
+1263
-206
No files matched your search
+1
-57
@@ -262,63 +262,7 @@ def check_stations_dans_la_seance():
|
||||
assert "stations" in AVEC_SORTIE
|
||||
|
||||
|
||||
def check_serveur():
|
||||
# le vrai serveur sur un port libre, une séance au faux client : la garde, l'analyse, le flux, le PDF absent
|
||||
import json
|
||||
import shutil
|
||||
import socket
|
||||
import threading
|
||||
import time
|
||||
import urllib.request
|
||||
from urllib.error import HTTPError
|
||||
import uvicorn
|
||||
import seance
|
||||
import serveur
|
||||
with socket.socket() as so:
|
||||
so.bind(("127.0.0.1", 0))
|
||||
port = so.getsockname()[1]
|
||||
cases = seance.CASES
|
||||
seance.CASES, serveur.CLIENT = seance_temporaire(), FauxClient(reponse([Bloc(type="text", text="Bonjour Marc")], "end_turn"))
|
||||
srv = uvicorn.Server(uvicorn.Config(serveur.app, host="127.0.0.1", port=port, log_level="error"))
|
||||
threading.Thread(target=srv.run, daemon=True).start()
|
||||
while not srv.started:
|
||||
time.sleep(0.05)
|
||||
base = f"http://127.0.0.1:{port}"
|
||||
|
||||
def appel(chemin, corps=None, entetes=None):
|
||||
r = urllib.request.Request(base + chemin, json.dumps(corps).encode() if corps is not None else None,
|
||||
{"Content-Type": "application/json", **(entetes or {})})
|
||||
try:
|
||||
with urllib.request.urlopen(r) as rep:
|
||||
return rep.status
|
||||
except HTTPError as e:
|
||||
return e.code
|
||||
try:
|
||||
assert appel("/api/pdf", entetes={"Host": "evil.example:80"}) == 403
|
||||
assert appel("/api/analyser", {"mail": "x"}, {"Content-Type": "text/plain"}) == 403
|
||||
assert appel("/api/analyser", {"mail": " "}) == 400
|
||||
assert appel("/api/analyser", {"mail": "Bonjour", "contexte": "", "images": []}) == 200
|
||||
with urllib.request.urlopen(base + "/api/flux", timeout=10) as f:
|
||||
premier, textes = None, []
|
||||
for ligne in f:
|
||||
if ligne.startswith(b"data: "):
|
||||
m = json.loads(ligne[6:])
|
||||
premier = premier or m
|
||||
textes += [e["texte"] for e in m["evenements"]]
|
||||
if "Bonjour Marc" in textes and not m["occupe"]["support"]:
|
||||
break
|
||||
assert premier["depuis"] == 0 and premier["id"], premier
|
||||
assert appel("/api/pdf") == 404
|
||||
(serveur.etat["seance"].dossier / "v1.pdf").write_bytes(b"%PDF-1.4")
|
||||
with urllib.request.urlopen(base + "/api/pdf") as rep:
|
||||
assert rep.read() == b"%PDF-1.4" and rep.headers["Content-Disposition"].startswith("inline"), rep.headers
|
||||
finally:
|
||||
srv.should_exit = True
|
||||
shutil.rmtree(seance.CASES)
|
||||
seance.CASES = cases
|
||||
|
||||
|
||||
CHECKS = [check_serveur, check_lire_document, check_cartes, check_stabilite, check_image_proche, check_max_tokens, check_sans_repli, check_capture_reduite, check_stations_dans_la_seance, check_boucle, check_erreur, check_cout, check_source, check_outil_qui_leve, check_lecture_refusee,
|
||||
CHECKS = [check_lire_document, check_cartes, check_stabilite, check_image_proche, check_max_tokens, check_sans_repli, check_capture_reduite, check_stations_dans_la_seance, check_boucle, check_erreur, check_cout, check_source, check_outil_qui_leve, check_lecture_refusee,
|
||||
check_chemin, check_station_absente, check_detecteurs, check_plafond, check_image, check_compiler]
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in new issue
Block a user