Skip to content

fix(figure_parser): accept lang as named parameter on VisionFigureParser (#17280) - #19511

Merged
JinHai-CN merged 1 commit into
infiniflow:mainfrom
Taranum01:fix/17280-figure-parser-lang
Sep 11, 2026
Merged

JinHai-CN merged 1 commit into
infiniflow:mainfrom
Taranum01:fix/17280-figure-parser-lang

Conversation

@Taranum01

Copy link
Copy Markdown
Contributor

"Fixes #17280.\n\nRe-opened as a clean PR per JinHai-CN's request \u2014 the previous #18392 had 929k insertions and 111k deletions because it carried the full main-sync history forward from when the branch was first cut. This version is the same 7-line fix (now +9 / -2) rebased onto current upstream/main, with no unrelated changes.\n\n## Problem\n\nVisionFigureParser.__init__ previously took *args, **kwargs and read the dataset language via kwargs.get(\"lang\"). The three wrappers above pass lang=lang as an explicit keyword argument, so kwargs.get(\"lang\") did return the value \u2014 but the contract was implicit and easy to miss when adding new call sites. Any caller that forgets lang= and only forwards **kwargs would silently default to English.\n\n## Fix\n\ndeepdoc/parser/figure_parser.py \u2014 make lang an explicit named parameter on VisionFigureParser.__init__. The type system now catches the omission, and the value is normalized via the existing _normalize_vision_language helper (mirroring the wrappers' own handling) for consistency. **kwargs.get(\"lang\") is kept as a fallback so older callers that don't pass lang keep working.\n\npython\ndef __init__(self, vision_model, figures_data, *args, lang=\"English\", **kwargs):\n ...\n self.language = _normalize_vision_language(lang) or kwargs.get(\"lang\") or \"English\"\n\n\nNo behavior change for any existing call site.\n\n## Tests\n\ntest/unit_test/deepdoc/parser/test_figure_parser.py \u2014 the existing test_vision_figure_parser_passes_dataset_language_to_prompt[language] parametrized test already covers the named-parameter forward path; it pins vision_llm_figure_describe_prompt is called with the normalized language. test_figure_wrappers_pass_dataset_language_to_model_and_parser covers the three wrappers' end-to-end path.\n\nDiff: +9 / -2 across 1 file. mergeable: MERGEABLE.\n"

…ser (infiniflow#17280)

`VisionFigureParser.__init__` previously took `\*args, \*\*kwargs`
and read the dataset language via `kwargs.get("lang")`. The three
wrappers above pass `lang=lang` as an explicit keyword argument, so
`kwargs.get("lang")` did return the value — but the contract was
implicit and easy to miss when adding new call sites (any caller
that forgets `lang=` and only forwards `\*\*kwargs` would
silently default to English).

Make `lang` an explicit named parameter so the type system catches
the omission and the value is normalized via `_normalize_vision_language`
for consistency with the wrappers' own handling. `\*\*kwargs.get("lang")`
is kept as a fallback so older callers that don't pass `lang` keep
working.

No behavior change for any current call site.
@coderabbitai

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 67ea11cb-66d9-4baf-b339-8e894e5a4414

📥 Commits

Reviewing files that changed from the base of the PR and between 3dab5db and e37f996.

📒 Files selected for processing (1)
  • deepdoc/parser/figure_parser.py

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

VisionFigureParser.__init__ now accepts an explicit lang parameter. It normalizes this value before falling back to legacy keyword handling and then English.

Changes

Vision language handling

Layer / File(s) Summary
Explicit language resolution
deepdoc/parser/figure_parser.py
VisionFigureParser.__init__ accepts lang="English" and resolves the normalized explicit value before legacy keyword and English fallbacks.

Estimated code review effort: 2 (Simple) | ~10 minutes

Severity of issue fixed: Medium

Suggested reviewers: iwasaki1112

Merge Risk: ⚪ Minimal · up to e37f9

Vision figure parsing now receives an explicit normalized language while preserving legacy callers and the English default. No current correctness or operational risk remains, so this change is mergeable.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The change formalizes lang in VisionFigureParser, but it does not implement the linked issue's required wrapper and caller changes. The three wrappers still need to accept and forward lang, and the XL… Update the three vision wrapper functions to accept lang, pass lang=lang to VisionFigureParser and LLMBundle where required, update all affected callers, and forward lang through Excel.call for the XLSX path. Add or verify tests for eac…
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding a named lang parameter to VisionFigureParser.
Description check ✅ Passed The description explains the problem, fix, compatibility behavior, and tests. It does not use the template's exact Summary heading, but it provides the required information.
Out of Scope Changes check ✅ Passed The changed constructor signature, language normalization, and compatibility fallback are related to the linked issue's language-propagation scope. No unrelated changes are shown.
Full details: Linked Issues check

Explanation

The change formalizes lang in VisionFigureParser, but it does not implement the linked issue's required wrapper and caller changes. The three wrappers still need to accept and forward lang, and the XLSX path still needs to forward lang through Excel.call [#17280].

Resolution

Update the three vision wrapper functions to accept lang, pass lang=lang to VisionFigureParser and LLMBundle where required, update all affected callers, and forward lang through Excel.call for the XLSX path. Add or verify tests for each affected path [#17280].

  • Fix all pre-merge checks with AI

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.

❤️ Share

A rabbit checks the language flow,
With carrots neat and prompts aglow.
Named words hop into place,
Old callers keep their saving grace.
English waits when none appear.

Comment @coderabbitai help to get the list of available commands.

@JinHai-CN JinHai-CN added the ci Continue Integration label Sep 11, 2026
@JinHai-CN JinHai-CN self-assigned this Sep 11, 2026
@codecov

codecov Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 37.32%. Comparing base (4c9768b) to head (e37f996).
⚠️ Report is 80 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #19511      +/-   ##
==========================================
+ Coverage   29.85%   37.32%   +7.47%     
==========================================
  Files          54       54              
  Lines       15343    15374      +31     
  Branches      118      125       +7     
==========================================
+ Hits         4580     5739    +1159     
+ Misses      10751     9608    -1143     
- Partials       12       27      +15     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JinHai-CN
JinHai-CN merged commit c2e7704 into infiniflow:main Sep 11, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Figure description language not propagated to PDF/DOCX(book,manual)/XLSX vision wrappers

2 participants