Étiqueter les événements de progression par run pour filtrer les retardataires

This commit is contained in:
Antoine Jacquin
2026-09-18 21:10:31 +02:00
parent ecd21d5b46
commit fbb56936f8
3 changed files with 46 additions and 13 deletions

View File

@ -831,18 +831,31 @@ def test_rebuild_index_background(tmp_path, monkeypatch):
def test_status_exposes_tiles_from_events(tmp_path, monkeypatch):
"""/api/status agrège les événements en tuiles (nom court + étapes)."""
"""/api/status agrège les événements en tuiles (nom court + étapes).
Les événements sont filtrés par identifiant de run : ceux d'un run
annulé (workers survivants écrivant après la troncature) n'apparaissent
pas dans la file du run courant."""
import lidar_pipeline.webapp as webapp
from lidar_pipeline.progress import report_event, reset_events
monkeypatch.setattr(webapp, "OUTPUT_DIR", tmp_path)
reset_events(tmp_path)
report_event(tmp_path, "LHD_FXX_1054_6882_PTS_LAMB93_IGN69", "viz",
"start", "aspect", res=0.5)
s = webapp.status()
with monkeypatch.context() as m:
m.setitem(webapp._job, "run_id", "run-courant")
reset_events(tmp_path)
m.setenv("LIDAR_RUN_ID", "run-courant")
report_event(tmp_path, "LHD_FXX_1054_6882_PTS_LAMB93_IGN69", "viz",
"start", "aspect", res=0.5)
# Worker retardataire d'un run annulé : réappend après le reset
m.setenv("LIDAR_RUN_ID", "run-annule")
report_event(tmp_path, "LHD_FXX_1055_6882_PTS_LAMB93_IGN69", "viz",
"start", "aspect", res=0.5)
m.delenv("LIDAR_RUN_ID")
s = webapp.status()
match = [t for t in s["tiles"] if t["short"] == "1054-6882"]
assert len(match) == 1
assert match[0]["state"] == "running"
assert any(step["label"] == "Aspect" for step in match[0]["steps"])
assert all(t["short"] != "1055-6882" for t in s["tiles"])
def test_generate_resets_progress_events(tmp_path, monkeypatch):