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
feat: add --stack option to mineru-kit models verify
jinzhenj99940ebc83d7
diff --git a/mineru/kit/commands/models.py b/mineru/kit/commands/models.pyindex d75de80d..85d3946d 100644--- a/mineru/kit/commands/models.py+++ b/mineru/kit/commands/models.py@@ -143,9 +143,30 @@ def show_cmd(def verify_cmd(repo: str | None = typer.Argument(None, help="Optional model repo name"),tier: str | None = typer.Option(None, "--tier", help="Optional model tier: basic or standard"),+ stack: str | None = typer.Option(+ None,+ "--stack",+ help="Model stack: auto (default, follows config.model.stack), light, or full. Ignored when REPO is given.",+ ),) -> None:"""Verify local model repos and required paths."""- repos = MODEL_REPOS if repo is None and tier is None else _select_target_repos(repo, tier)+ if repo is not None:+ repos = _select_target_repos(repo, tier)+ elif tier is not None:+ try:+ effective_stack = resolve_model_stack(stack)+ except ValueError as exc:+ exit_with_message("invalid_request", str(exc), "stack")+ try:+ repos = model_repos_for_tier(tier, stack=effective_stack)+ except ValueError as exc:+ exit_with_message("invalid_request", str(exc), "tier")+ else:+ try:+ effective_stack = resolve_model_stack(stack)+ except ValueError as exc:+ exit_with_message("invalid_request", str(exc), "stack")+ repos = tuple(r for r in MODEL_REPOS if r.stack == effective_stack)failures = 0for target_repo in repos:diff --git a/tests/unittest/test_kit_commands.py b/tests/unittest/test_kit_commands.pyindex 11e1efc5..38b94670 100644--- a/tests/unittest/test_kit_commands.py+++ b/tests/unittest/test_kit_commands.py@@ -2053,3 +2053,68 @@ def test_models_show_rejects_invalid_stack() -> None:assert result.exit_code == 1assert "Unsupported stack 'torch'" in " ".join(result.output.split())+++def test_models_verify_filters_by_effective_stack_full(tmp_path: Path, monkeypatch: Any) -> None:+ """config.model.stack=full 时,verify 默认只验证 full repos。"""+ base_dir = tmp_path / "models"+ monkeypatch.setattr(models.config.model, "base_dir", str(base_dir))+ monkeypatch.setattr(models.config.model, "stack", "full")++ # 仅把 full repos 设为 ready,light repos 不创建+ for repo in models.MODEL_REPOS:+ if repo.stack == "full":+ if repo.download_mode == "full":+ repo.local_dir().mkdir(parents=True, exist_ok=True)+ (repo.local_dir() / MODEL_COMPLETE_MARKER).touch()+ continue+ for model_path in repo.required_paths():+ target = repo.local_dir() / model_path.relative_path+ if Path(model_path.relative_path).suffix:+ target.parent.mkdir(parents=True, exist_ok=True)+ target.write_text("x", encoding="utf-8")+ else:+ target.mkdir(parents=True, exist_ok=True)+ (target / MODEL_COMPLETE_MARKER).touch()++ result = runner.invoke(app, ["models", "verify"])++ assert result.exit_code == 0+ assert "PDF-Extract-Kit-1.0: ok" in result.output+ assert "MinerU2.5-Pro-2605-1.2B: ok" in result.output+ assert "PP-DocLayoutV2_onnx" not in result.output+++def test_models_verify_with_light_stack(tmp_path: Path, monkeypatch: Any) -> None:+ """--stack light 时,verify 只验证 light repos。"""+ base_dir = tmp_path / "models"+ monkeypatch.setattr(models.config.model, "base_dir", str(base_dir))++ result = runner.invoke(app, ["models", "verify", "--stack", "light"])++ assert result.exit_code == 1 # light repos 未准备,应失败+ assert "PP-DocLayoutV2_onnx: missing key paths" in " ".join(result.output.split())+ assert "PDF-Extract-Kit-1.0" not in result.output+++def test_models_verify_repo_ignores_stack(tmp_path: Path, monkeypatch: Any) -> None:+ """传具体 repo 名时 --stack 被忽略。"""+ base_dir = tmp_path / "models"+ monkeypatch.setattr(models.config.model, "base_dir", str(base_dir))++ # PP-DocLayoutV2_onnx 是 download_mode=full,只需创建 marker 文件+ repo = next(r for r in models.MODEL_REPOS if r.name == "PP-DocLayoutV2_onnx")+ repo.local_dir().mkdir(parents=True, exist_ok=True)+ (repo.local_dir() / MODEL_COMPLETE_MARKER).touch()++ result = runner.invoke(app, ["models", "verify", "PP-DocLayoutV2_onnx", "--stack", "full"])++ assert result.exit_code == 0+ assert "PP-DocLayoutV2_onnx: ok" in result.output+++def test_models_verify_rejects_invalid_stack() -> None:+ result = runner.invoke(app, ["models", "verify", "--stack", "torch"])++ assert result.exit_code == 1+ assert "Unsupported stack 'torch'" in " ".join(result.output.split())