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: update backend normalization function and add test for flash backend parsing
myhlolie4cf38c06f91
diff --git a/mineru/kit/commands/parse.py b/mineru/kit/commands/parse.pyindex 8dade1eb..4e5bc068 100644--- a/mineru/kit/commands/parse.py+++ b/mineru/kit/commands/parse.py@@ -6,7 +6,7 @@ from typing import Literalfrom ...parser import MinerUApiParserfrom ...parser import parse as local_parse-from ...utils.backend_options import normalize_public_backend+from ...utils.backend_options import normalize_backendfrom ..common import (build_remote_api_url,effective_local_tier_and_backend,@@ -68,7 +68,7 @@ def parse_cmd(parse_one = partial(parser.parse, page_range=pages or "")else:try:- normalized_backend = normalize_public_backend(backend) if backend is not None else None+ normalized_backend = normalize_backend(backend) if backend is not None else Noneexcept ValueError as exc:exit_with_message("invalid_request", str(exc), "backend")resolved_tier, resolved_backend = effective_local_tier_and_backend(tier, normalized_backend)diff --git a/tests/unittest/test_kit_commands.py b/tests/unittest/test_kit_commands.pyindex c0a384a1..11282b3f 100644--- a/tests/unittest/test_kit_commands.py+++ b/tests/unittest/test_kit_commands.py@@ -409,6 +409,45 @@ def test_parse_forwards_backend_alias_and_effort(monkeypatch: Any, tmp_path: Patassert seen["effort"] == "high"+def test_parse_forwards_flash_backend(monkeypatch: Any, tmp_path: Path) -> None:+ source = tmp_path / "demo.pdf"+ output = tmp_path / "out.md"+ source.write_bytes(b"%PDF-1.7\n")+ seen: dict[str, Any] = {}++ class _Result:+ def markdown(self) -> str:+ """返回用于验证 flash backend 透传的测试内容。"""+ return "# demo\n"++ def to_json(self) -> str:+ """保留 zip 输出所需接口。"""+ return '{"pages":[]}'++ def images(self) -> dict[str, bytes]:+ """本用例不关注图片 sidecar。"""+ return {}++ def save(self, writer: Any) -> None:+ """模拟 zip 输出所需的完整保存接口。"""+ writer.write_string("markdown.md", self.markdown())+ writer.write_string("middle_json.json", self.to_json())++ def _fake_local_parse(*args: Any, **kwargs: Any) -> _Result:+ """记录 mineru-kit parse 透传给 parser 的 flash backend 参数。"""+ seen.update(kwargs)+ return _Result()++ monkeypatch.setattr(parse, "local_parse", _fake_local_parse)++ result = runner.invoke(app, ["parse", str(source), "-o", str(output), "--backend", "flash"])++ assert result.exit_code == 0+ assert seen["tier"] == "flash"+ assert seen["backend"] == "flash"+ assert output.read_text(encoding="utf-8") == "# demo\n"++def test_cli_old_vlm_branch_does_not_forward_effort(monkeypatch: Any, tmp_path: Path) -> None:from mineru.cli_old import common