Barre de progression en etapes (7 étapes) dans l'UI
- pipeline : nouveau callback on_step emis par run_pipeline (fetch, translate, zip, clean) et _run_ocr_typeset (ocr, translate) ; typeset_chapter emet inpaint/typeset par image - server : STEP_LABELS (libelles FR), le job background remonte progress.step via GET /jobs/<id> - UI : barre d'étapes en pastilles (done=vert, active=degradé pulsant) au-dessus de la barre globale % chapitres ; libellé de l'étape courante dans le label - tests : séquence d'étapes OCR (ocr->translate->inpaint->typeset), étapes run_pipeline (fetch/translate/zip/clean), step dans /jobs, labels dans la page Suite : 94 passed, 1 skipped. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
1 parent
5c2c102518
commit
a1b01946cc
7 files changed
+131
-10
No files matched your search
@@ -351,6 +351,26 @@ class TestOCRTypeset(unittest.TestCase):
|
||||
self.assertTrue((d / "export" / "images-clean" / "p1.png").exists(), "étape 3 : inpainting -> images-clean")
|
||||
self.assertTrue((d / "export" / "images-fr" / "p1.png").exists(), "étape 4 : retypographie -> images-fr")
|
||||
|
||||
def test_pipeline_ocr_typeset_reports_steps_in_order(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
d = Path(tmp)
|
||||
(d / "images").mkdir()
|
||||
self._make_image(d / "images" / "p1.png")
|
||||
regions = [{"index": 0, "image": "p1.png", "box": [10, 10, 280, 60], "text": "Hello world"}]
|
||||
|
||||
def fake_ocr(chapter_dir, client, lang="eng"):
|
||||
(Path(chapter_dir) / "ocr.json").write_text(
|
||||
json.dumps({"lang": lang, "regions": regions}), encoding="utf-8"
|
||||
)
|
||||
return regions
|
||||
|
||||
steps = []
|
||||
with mock.patch("scalper.ocr.ocr_chapter", side_effect=fake_ocr):
|
||||
out = pipeline._run_ocr_typeset(d, {"language": "en"}, "fr", FakeLLM(), {},
|
||||
inpaint_engine="simple", on_step=steps.append)
|
||||
self.assertTrue(out.startswith("ok"), out)
|
||||
self.assertEqual(steps, ["ocr", "translate", "inpaint", "typeset"], steps)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -93,6 +93,17 @@ class TestExporter(unittest.TestCase):
|
||||
with self.assertRaises(KeyError):
|
||||
get_adapter("inconnu")
|
||||
|
||||
def test_run_pipeline_reports_steps(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
steps = []
|
||||
res = pipeline.run_pipeline("demo", "demo-1", "fr", out_root=tmp, mock_llm=True,
|
||||
zip_export=True, on_step=steps.append)
|
||||
self.assertEqual(res["status"], "done")
|
||||
self.assertIn("fetch", steps)
|
||||
self.assertIn("translate", steps)
|
||||
self.assertEqual(steps[-2:], ["zip", "clean"], steps)
|
||||
self.assertIn("export_zip", res)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -116,6 +116,31 @@ class TestServer(unittest.TestCase):
|
||||
self.assertIn("Scalper", body)
|
||||
self.assertIn("/run", body)
|
||||
|
||||
def test_web_ui_has_step_bar(self):
|
||||
with urllib.request.urlopen(f"http://127.0.0.1:{self.port}/") as r:
|
||||
body = r.read().decode("utf-8")
|
||||
self.assertIn('id="steps"', body)
|
||||
for label in ("Téléchargement des images", "Récupération des textes (OCR)", "Traduction des textes",
|
||||
"Effacement des bulles", "images cleaned", "Compression (zip)", "Suppression du reste"):
|
||||
self.assertIn(label, body)
|
||||
|
||||
def test_background_job_progress_has_step(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
status, body = self._post("/run", {"source": "demo", "series": "demo-1", "lang": "fr",
|
||||
"mock_llm": True, "out": tmp, "background": True,
|
||||
"zip_export": True})
|
||||
self.assertEqual(status, 202)
|
||||
job = body["job"]
|
||||
j = {}
|
||||
for _ in range(200):
|
||||
s, j = self._get(f"/jobs/{job}")
|
||||
if j["status"] != "running":
|
||||
break
|
||||
time.sleep(0.05)
|
||||
self.assertEqual(j["status"], "done")
|
||||
self.assertIn("step", j["progress"])
|
||||
self.assertEqual(j["progress"]["step"], "clean", j["progress"]) # zip_export -> zip puis clean
|
||||
|
||||
def test_run_demo_mock_llm(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
status, body = self._post("/run", {"source": "demo", "series": "demo-1", "lang": "fr", "mock_llm": True, "out": tmp})
|
||||
|
||||
Reference in new issue
Block a user