Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.
Python ai4sciencedocument-analysisdocxextract-datalayout-analysisocrparserpdfpdf-converterpdf-extractor-llmpdf-extractor-pretrainpdf-extractor-ragpdf-parserpptxpythonxlsx
fix(ci): align hardware and tier changes with repository checks
myhloli17e885e97421
diff --git a/mineru/model/runtime/gpu.py b/mineru/model/runtime/gpu.pyindex efad7b41..a138f44c 100644--- a/mineru/model/runtime/gpu.py+++ b/mineru/model/runtime/gpu.py@@ -1,3 +1,4 @@+# Copyright (c) Opendatalab. All rights reserved."""共享 GPU 分类、已有身份匹配和候选优先级;不导入或初始化推理运行时。"""from __future__ import annotationsdiff --git a/mineru/model/runtime/hardware.py b/mineru/model/runtime/hardware.pyindex dcd64c82..15a3f2ae 100644--- a/mineru/model/runtime/hardware.py+++ b/mineru/model/runtime/hardware.py@@ -1,3 +1,4 @@+# Copyright (c) Opendatalab. All rights reserved."""只读聚合问题反馈所需的环境信息;不调用模型加载或自动校准。"""from __future__ import annotationsdiff --git a/mineru/model/runtime/hardware_probe.py b/mineru/model/runtime/hardware_probe.pyindex 65daafc5..8fa9d451 100644--- a/mineru/model/runtime/hardware_probe.py+++ b/mineru/model/runtime/hardware_probe.py@@ -1,3 +1,4 @@+# Copyright (c) Opendatalab. All rights reserved."""隔离运行时导入和原生设备探测;不在模块导入时读取配置或初始化模型。"""from __future__ import annotationsdiff --git a/mineru/model/runtime/hardware_system.py b/mineru/model/runtime/hardware_system.pyindex 1bde7863..e30f3033 100644--- a/mineru/model/runtime/hardware_system.py+++ b/mineru/model/runtime/hardware_system.py@@ -1,3 +1,4 @@+# Copyright (c) Opendatalab. All rights reserved."""标准库与平台原生工具实现的只读 CPU、内存和系统显卡库存采集。"""from __future__ import annotationsdiff --git a/mineru/model/runtime/hardware_types.py b/mineru/model/runtime/hardware_types.pyindex 9775bb72..6168144e 100644--- a/mineru/model/runtime/hardware_types.py+++ b/mineru/model/runtime/hardware_types.py@@ -1,3 +1,4 @@+# Copyright (c) Opendatalab. All rights reserved."""硬件诊断的可序列化报告类型,不导入推理运行时。"""from __future__ import annotationsdiff --git a/mineru/model/runtime/onnx_calibration_cache.py b/mineru/model/runtime/onnx_calibration_cache.pyindex 849c07d5..b8f1880a 100644--- a/mineru/model/runtime/onnx_calibration_cache.py+++ b/mineru/model/runtime/onnx_calibration_cache.py@@ -1,3 +1,4 @@+# Copyright (c) Opendatalab. All rights reserved."""保存可验证的 OCR 校准证据,供服务启动推荐和只读诊断复用。"""from __future__ import annotationsdiff --git a/mineru/model/runtime/tier_recommendation.py b/mineru/model/runtime/tier_recommendation.pyindex fc450a09..d69ed42c 100644--- a/mineru/model/runtime/tier_recommendation.py+++ b/mineru/model/runtime/tier_recommendation.py@@ -1,3 +1,4 @@+# Copyright (c) Opendatalab. All rights reserved."""通过硬件初选与启动阶段的 OCR 设备校准,确定 API 服务开放档位。"""from __future__ import annotationsdiff --git a/mineru/utils/translations.py b/mineru/utils/translations.pyindex 71afd10a..a6708545 100644--- a/mineru/utils/translations.py+++ b/mineru/utils/translations.py@@ -480,7 +480,7 @@ ZH_MESSAGES: dict[str, str] = {"Maximum pages per PDF conversion; omitted: unlimited": "PDF 单次转换的最大页数;省略时不限制","Show local examples": "显示本地示例","Expose the Gradio event API": "开放 Gradio 事件 API",- "Managed API server capability tier": "托管 API server 的能力档位",+ "Managed API server tier ceiling": "托管 API server 的档位上限","Managed server job concurrency": "托管服务的任务并发数","Disable managed server image analysis": "禁用托管服务的图像分析","Preload managed server models": "预加载托管服务的模型",@@ -493,7 +493,9 @@ ZH_MESSAGES: dict[str, str] = {"Upstream Tasks API base URL": "上游 Tasks API 基础 URL","Upstream Bearer API key": "上游 Bearer API 密钥","File parse recovery state directory": "同步解析请求恢复目录",- "Server capability tier: flash, basic, or standard": "服务能力档位: flash、basic 或 standard",+ "PDF/image tier ceiling: flash, basic, standard, advanced; or auto": (+ "PDF/图片档位上限: flash、basic、standard、advanced;或 auto 自动选择"+ ),"Disable Flash tier advertisement and execution": "禁用 Flash 档位的广播与执行","Disable Advanced tier advertisement and execution": "禁用 Advanced 档位的广播与执行","Terminal retention seconds (default 86400; 0 disables collection)": "终态资源保留秒数(默认 86400;0 表示禁用回收)",@@ -543,6 +545,14 @@ ZH_MESSAGES: dict[str, str] = {"mlx_vlm.server 不可用。请安装 'mlx-vlm>=0.7.0,<0.8.0'。"),"MLX-VLM is not installed. Install 'mlx-vlm>=0.7.0,<0.8.0'.": "未安装 MLX-VLM。请安装 'mlx-vlm>=0.7.0,<0.8.0'。",+ # -------------------------------------------------------- kit hardware+ "Detect recommended tiers or inspect hardware and runtime information.": "检测推荐档位或查看硬件与运行时信息。",+ "Recommend the API tier ceiling using hardware and applicable OCR calibration.": (+ "根据硬件和适用的 OCR 校准结果推荐 API 档位上限。"+ ),+ "Read hardware, installed versions and runtime diagnostics without calibration.": (+ "读取硬件、已安装软件版本与运行时诊断信息,不执行校准。"+ ),# ---------------------------------------------------------- kit models"Download, inspect, and verify local MinerU models.": "下载、查看与校验本地 MinerU 模型。","Download an explicit repo or the tier resources required by the current backend combination.": (@@ -586,7 +596,7 @@ ZH_MESSAGES: dict[str, str] = {"Existing MinerU V1 API base URL; repeat to add upstreams": "既有的 MinerU V1 API 基础 URL;可重复传入以添加多个上游","Local workers: auto, none, or GPU CSV": "本地 worker: auto、none 或 GPU 列表(CSV)","Host for managed api-server workers": "托管 api-server worker 的主机",- "Managed worker tier: flash, basic, standard": "托管 worker 档位: flash、basic、standard",+ "Managed worker tier ceiling: flash, basic, standard, advanced": "托管 worker 档位上限: flash、basic、standard、advanced","Concurrency per managed worker": "每个托管 worker 的并发数","Preload models in managed workers": "在托管 worker 中预加载模型",# -------------------------------------------------------- kit commondiff --git a/tests/unittest/test_doclib_app_startup.py b/tests/unittest/test_doclib_app_startup.pyindex e815f387..e3e1fa44 100644--- a/tests/unittest/test_doclib_app_startup.py+++ b/tests/unittest/test_doclib_app_startup.py@@ -5,6 +5,7 @@ import tomllibimport uuidfrom logging.handlers import RotatingFileHandlerfrom pathlib import Path+from unittest.mock import Mockimport pytestfrom fastapi.testclient import TestClient@@ -131,8 +132,14 @@ def test_config_set_rejects_invalid_known_config_values(key: str, value: str, moassert config_response.json()["source"] == "default"-def test_config_set_managed_tier_rejects_missing_models(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:[email protected](("tier", "model_tier"), [("basic", "basic"), ("standard", "standard"), ("advanced", "standard")])+def test_config_set_managed_tier_rejects_missing_models(+ tier: str, model_tier: str, monkeypatch: pytest.MonkeyPatch, tmp_path: Path+) -> None:+ """托管档位缺少模型时拒绝保存,Advanced 提示下载共享的 Standard 模型。"""+def _skip_background_task(*args, **kwargs):+ """跳过后台任务,隔离配置接口与模型就绪检查。"""return Nonemonkeypatch.setattr(doclib_app, "_create_background_task", _skip_background_task)@@ -140,10 +147,12 @@ def test_config_set_managed_tier_rejects_missing_models(monkeypatch: pytest.Monkmonkeypatch.setattr(model_download.get_config().model, "base_dir", str(tmp_path / "models"))# 无 torch 环境会把小模型后端解析为 onnx,显式固定以保持仓库名断言确定。monkeypatch.setattr(model_download.get_config().model, "small_backend", "torch")+ monkeypatch.setattr(model_download.get_config().model.vlm, "engine", "llama-cpp")+ monkeypatch.setattr(model_download.get_config().model.vlm, "server_url", "")cfg = PatchedConfig(doclib={"data_dir": str(tmp_path), "sqlite": {"path": str(tmp_path / "doclib.db")}})with TestClient(doclib_app.create_app(cfg)) as client:- response = client.put("/api/v1/configs/parse_server.local.managed_tier", json={"value": "basic"})+ response = client.put("/api/v1/configs/parse_server.local.managed_tier", json={"value": tier})config_response = client.get("/api/v1/configs/parse_server.local.managed_tier")assert response.status_code == 400@@ -151,27 +160,36 @@ def test_config_set_managed_tier_rejects_missing_models(monkeypatch: pytest.Monkassert payload["error"]["code"] == "parse_server_model_not_ready"assert payload["error"]["param"] == "parse_server.local.managed_tier"assert "MinerU-4_models_torch" in payload["error"]["message"]- assert "mineru-kit models download --tier basic" in payload["error"]["message"]+ assert f"mineru-kit models download --tier {model_tier}" in payload["error"]["message"]assert config_response.json()["value"] == "standard"assert config_response.json()["source"] == "default"-def test_config_set_managed_advanced_is_rejected(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:- def _skip_background_task(*args, **kwargs):- return None-- monkeypatch.setattr(doclib_app, "_create_background_task", _skip_background_task)- monkeypatch.setattr("mineru.doclib.server.ensure_tier_runtime_dependencies", lambda tier: None)- monkeypatch.setattr(model_download.get_config().model, "base_dir", str(tmp_path / "models"))+def test_config_set_managed_advanced_accepts_ready_standard_models(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:+ """Advanced 使用 Standard 依赖和模型,通过检查后保存为显式托管上限。"""+ check_dependencies = Mock(return_value=None)+ verify_models = Mock(return_value=model_download.ModelReadyResult(ready=True, root=tmp_path / "models"))+ monkeypatch.setattr(doclib_app, "_create_background_task", Mock(return_value=None))+ monkeypatch.setattr("mineru.doclib.server.ensure_tier_runtime_dependencies", check_dependencies)+ monkeypatch.setattr("mineru.doclib.server.verify_model_repo", verify_models)+ monkeypatch.setattr(model_download.get_config().model, "small_backend", "torch")+ monkeypatch.setattr(model_download.get_config().model.vlm, "engine", "llama-cpp")+ monkeypatch.setattr(model_download.get_config().model.vlm, "server_url", "")cfg = PatchedConfig(doclib={"data_dir": str(tmp_path), "sqlite": {"path": str(tmp_path / "doclib.db")}})with TestClient(doclib_app.create_app(cfg)) as client:response = client.put("/api/v1/configs/parse_server.local.managed_tier", json={"value": "advanced"})+ config_response = client.get("/api/v1/configs/parse_server.local.managed_tier")- assert response.status_code == 400- payload = response.json()- assert payload["error"]["code"] == "invalid_config_value"- assert "basic, standard" in payload["error"]["message"]+ assert response.status_code == 200+ assert response.json()["value"] == "advanced"+ assert config_response.json()["value"] == "advanced"+ assert config_response.json()["source"] == "override"+ check_dependencies.assert_called_once_with("standard")+ assert [call.args[0].name for call in verify_models.call_args_list] == [+ "MinerU-4_models_torch",+ "MinerU2.5-Pro-2605-1.2B-GGUF",+ ]def test_config_set_managed_mode_rejects_missing_models_for_current_tier(