Upgrade MinerU engine from magic-pdf 0.9 to MinerU 2.x - #12
Merged
Conversation
The MinerU engine adapter targeted the legacy magic-pdf 0.9 API
(PymuDocDataset / doc_analyze / pipe_*_mode), which is gone upstream.
Rewrite it around the supported mineru.cli.common.do_parse entry point.
- Adapter rewritten to call do_parse + read_fn; output read back from the
per-backend subdir (pipeline -> parse_method, vlm -> vlm).
- MinerUEngine gains backend ("pipeline" default | "vlm") and parse_method
options; public name/process()/EngineResult shape unchanged.
- Dependency extra: magic-pdf[full]>=0.9 -> mineru[core]>=2.0.
- Tests rewritten for the new API; docs/changelog/proposal added.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gi5bv7McPS2YsVD1q6fqPr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
MinerUEngineadapter was built on the legacymagic-pdf 0.9package and its now-removed import surface (PymuDocDataset,doc_analyze,pipe_txt_mode/pipe_ocr_mode). Upstream opendatalab/MinerU was renamed/rewritten as MinerU 2.x (PyPI packagemineru, import rootmineru). This PR retargets the adapter to the supported MinerU 2.x programmatic API.Changes
src/docfold/engines/mineru_engine.py): usesmineru.cli.common.do_parse+read_fn. Runsdo_parseinto a tempoutput_dirin a thread executor, then reads back the generated{name}.md/{name}_content_list.jsonfrom the per-backend subdirectory (pipeline→parse_method,vlm→vlm,hybrid→hybrid_<method>).backend(default"pipeline", or"vlm") andparse_method(default"auto"). Existingconfig_path/gpukept for backward compatibility.mineru,process()signature, andEngineResultshape are preserved.process()still honorslang,start_page/end_page(forwarded asstart_page_id/end_page_id), andOutputFormat.MARKDOWN/JSON.pyproject.toml):magic-pdf[full]>=0.9→mineru[core]>=2.0.tests/engines/test_adapters.py):TestMinerUEnginerewritten for the new API (mocksdo_parse/read_fn, asserts subdir layout, page-range/lang forwarding, vlm backend).docs/tasks/MINERU_2X_UPGRADE.md,CHANGELOG.md,README.md.Testing
pytest tests/engines/test_adapters.py -k MinerU -v— 13 passedpytest tests/ -m "not slow"— 321 passed, 3 skippedruff check— cleanminerupackage installed (downloads ~1-3 GB model weights). The proposal lists this as a manualslowverification step before release.🤖 Generated with Claude Code
Generated by Claude Code