Skip to content

Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.

fix(ci): restore router lifecycle tests and admin key translation

myhlolibde8b672c40f
diff --git a/mineru/utils/translations.py b/mineru/utils/translations.py
index c15ab557..c4f49586 100644
--- a/mineru/utils/translations.py
+++ b/mineru/utils/translations.py
@@ -490,6 +490,7 @@ ZH_MESSAGES: dict[str, str] = {
"Allow URL sources to use plain HTTP": "允许 URL 来源使用明文 HTTP",
"Initialize VLM client and local Hybrid models at startup": "启动时初始化 VLM 客户端与本地 Hybrid 模型",
"Optional fixed API key": "可选的固定 API key",
+ "Bearer key enabling Router upstream management APIs": "用于启用 Router upstream 管理 API 的 Bearer key",
"Remote VLM URL; empty value selects local VLM": "远程 VLM URL;留空选择本地 VLM",
"Bearer key for the remote VLM server": "远程 VLM 服务的 Bearer key",
"Remote VLM model name; empty value enables discovery": "远程 VLM 模型名;留空启用自动发现",
diff --git a/tests/unittest/test_engine_dead_lifecycle.py b/tests/unittest/test_engine_dead_lifecycle.py
index 21d84fe3..5ef1eb95 100644
--- a/tests/unittest/test_engine_dead_lifecycle.py
+++ b/tests/unittest/test_engine_dead_lifecycle.py
@@ -66,6 +66,16 @@ def test_api_engine_failure_drains_running_and_queued_jobs(tmp_path: Path, monke
source = tmp_path / f"{name}.pdf"
source.write_bytes(name.encode())
jobs.append(submit_task(client, source, tier="flash"))
+
+ async def wait_for_submissions() -> None:
+ """确认两个作业运行、其余作业已提交,再触发排队取消与引擎死亡。"""
+ async with asyncio.timeout(5):
+ while len(entered) < 2 or not all(
+ file.submitted for record in app.state.task_store._records.values() for file in record.file_states
+ ):
+ await asyncio.sleep(0.01)
+
+ client.portal.call(wait_for_submissions)
assert client.post(task_url(client, jobs[-1]) + "/cancel").status_code == 200
client.portal.call(gate.set)
for job in jobs:
@@ -111,7 +121,7 @@ def test_router_single_generation_replacement_and_backoff(monkeypatch: pytest.Mo
async def scenario() -> None:
"""在同一事件循环并发刷新,验证锁和 generation 隔离。"""
now = [0.0]
- monkeypatch.setattr(workers.time, "monotonic", lambda: now[0])
+ monkeypatch.setattr(workers, "time", SimpleNamespace(monotonic=lambda: now[0]))
local = SimpleNamespace(process=SimpleNamespace(poll=lambda: None), base_url="http://old")
starts: list[int] = []
stops: list[int] = []
@@ -140,6 +150,7 @@ def test_router_single_generation_replacement_and_backoff(monkeypatch: pytest.Mo
pool = workers.WorkerPool(workers.RouterSettings(local_gpus="none"), transport=httpx.MockTransport(handle))
state = workers.WorkerState("local", "http://old", "local", local_worker=local, generation=1)
+ pool._workers[state.worker_id] = state
try:
await pool.refresh(state)
assert not state.healthy and state.restart_requested
@@ -153,9 +164,10 @@ def test_router_single_generation_replacement_and_backoff(monkeypatch: pytest.Mo
now[0] = 15
await asyncio.gather(*(pool.refresh(state) for _ in range(3)))
assert len(stops) == 1 and state.healthy and state.generation == 2
- remote = workers.WorkerState("remote", "http://old", "remote")
+ remote, _ = pool.register_remote("http://old")
await pool.refresh(remote)
assert not remote.healthy and not remote.restart_requested
+ assert remote.last_error == "engine_dead"
finally:
await pool.client.aclose()