Skip to content

Upgrade MinerU engine from magic-pdf 0.9 to MinerU 2.x - #12

Merged
Mihailorama merged 1 commit into
mainfrom
claude/mineru-library-integration-tw77ax
Jun 27, 2026
Merged

Upgrade MinerU engine from magic-pdf 0.9 to MinerU 2.x#12
Mihailorama merged 1 commit into
mainfrom
claude/mineru-library-integration-tw77ax

Conversation

@Mihailorama

Copy link
Copy Markdown
Owner

Summary

The MinerUEngine adapter was built on the legacy magic-pdf 0.9 package 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 package mineru, import root mineru). This PR retargets the adapter to the supported MinerU 2.x programmatic API.

Changes

  • Adapter rewrite (src/docfold/engines/mineru_engine.py): uses mineru.cli.common.do_parse + read_fn. Runs do_parse into a temp output_dir in a thread executor, then reads back the generated {name}.md / {name}_content_list.json from the per-backend subdirectory (pipelineparse_method, vlmvlm, hybridhybrid_<method>).
  • New constructor options: backend (default "pipeline", or "vlm") and parse_method (default "auto"). Existing config_path/gpu kept for backward compatibility.
  • Public API unchanged: engine name mineru, process() signature, and EngineResult shape are preserved. process() still honors lang, start_page/end_page (forwarded as start_page_id/end_page_id), and OutputFormat.MARKDOWN/JSON.
  • Dependency (pyproject.toml): magic-pdf[full]>=0.9mineru[core]>=2.0.
  • Tests (tests/engines/test_adapters.py): TestMinerUEngine rewritten for the new API (mocks do_parse/read_fn, asserts subdir layout, page-range/lang forwarding, vlm backend).
  • Docs: proposal docs/tasks/MINERU_2X_UPGRADE.md, CHANGELOG.md, README.md.

Testing

  • pytest tests/engines/test_adapters.py -k MinerU -v — 13 passed
  • pytest tests/ -m "not slow" — 321 passed, 3 skipped
  • ruff check — clean

⚠️ Not yet run: real-PDF E2E with the mineru package installed (downloads ~1-3 GB model weights). The proposal lists this as a manual slow verification step before release.

🤖 Generated with Claude Code


Generated by Claude Code

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
@Mihailorama
Mihailorama marked this pull request as ready for review June 27, 2026 19:42
@Mihailorama
Mihailorama merged commit b4fb89a into main Jun 27, 2026
10 checks passed
@Mihailorama
Mihailorama deleted the claude/mineru-library-integration-tw77ax branch June 27, 2026 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants