Repository navigation
fix(mineru): thread page_from/page_to into MinerU API request - #16957
Conversation
The MinerU parser was hardcoding start_page_id=0/end_page_id=99999 in the file_parse payload, so every page-range task ended up fetching the whole PDF and duplicating chunks downstream. Thread page_from/page_to through parse_pdf and _run_mineru, then translate the RAGFlow exclusive to_page into MinerU's inclusive end_page_id at the API boundary.
by_mineru already received the task dispatcher's page range but dropped it before calling parse_pdf. Forward the range and clamp the task-sentinel value so the parser's MAXIMUM_PAGE_NUMBER default still maps to the full-document fallback inside the API request.
Add three pytest regressions against _run_mineru_api: an explicit range shows up in the request, the default full-document range still falls back to 0/99999, and the to_page - 1 normalization matches MinerU's 0-based inclusive end_page_id contract.
📝 WalkthroughWalkthroughChangesMinerU page-range propagation
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant by_mineru
participant parse_pdf
participant MinerUParser
participant MinerU API
by_mineru->>parse_pdf: page_from and page_to
parse_pdf->>MinerUParser: forward page range
MinerUParser->>MinerU API: start_page_id and inclusive end_page_id
MinerU API-->>MinerUParser: parsed page-range result
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16957 +/- ##
==========================================
- Coverage 94.56% 93.16% -1.40%
==========================================
Files 10 10
Lines 717 717
Branches 118 118
==========================================
- Hits 678 668 -10
- Misses 25 29 +4
- Partials 14 20 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Problem
When a page range is set on a chunk task, the range is not passed to the MinerU API. Each request sends the full PDF instead of the selected pages, which causes MinerU to process the same content repeatedly and duplicate chunks downstream.
Repro steps
page_fromandpage_to.Expected
The MinerU request should include the selected page range. RAGFlow's
page_tois exclusive (Python slice stop); MinerU'send_page_idis 0-based inclusive.Fix
page_fromandpage_tothroughparse_pdf,_run_mineru, and_run_mineru_apiindeepdoc/parser/mineru_parser.py.page_tointoend_page_idat the API boundary.start_page_id: 0andend_page_id: 99999when no range is provided.from_pageandto_pagefromrag/app/naive.py, clampingto_pagetoMAXIMUM_PAGE_NUMBER.Fixes #16586
Tests
Three regression tests in
test/unit_test/deepdoc/parser/test_mineru_parser.py:to_pageconverts correctly to MinerU's inclusiveend_page_id.Result: 7/7 tests passed (4 existing + 3 new).
py_compileclean.Review the payload and run the parser test before merging.