[Misc][Build] Lazy load cv2 in nemotron_parse.py#33189
[Misc][Build] Lazy load cv2 in nemotron_parse.py#33189mgoin merged 2 commits intovllm-project:mainfrom
Conversation
Signed-off-by: kiersten-stokes <kierstenstokes@gmail.com>
There was a problem hiding this comment.
Code Review
This pull request aims to lazy-load the cv2 module in nemotron_parse.py to prevent import errors in environments where opencv-python is not installed but the model is used for text-only tasks. The change correctly moves the import cv2 statement from the top of the file into the methods that use it.
My review identifies an opportunity to make the lazy loading even more effective. Currently, cv2 is imported during the initialization of NemotronParseImageProcessor, which may still be too early. I've suggested a change to defer the import until an image is actually processed, fully aligning with the PR's goal.
|
Hi @kiersten-stokes, the pre-commit checks have failed. Please run: uv pip install pre-commit
pre-commit install
pre-commit run --all-filesThen, commit the changes and push to your branch. For future commits, Tip Is
|
Signed-off-by: kiersten-stokes <kierstenstokes@gmail.com>
mgoin
left a comment
There was a problem hiding this comment.
Follows the pattern in the result of the codebase, thanks!
Signed-off-by: kiersten-stokes <kierstenstokes@gmail.com>
Signed-off-by: kiersten-stokes <kierstenstokes@gmail.com> (cherry picked from commit 9e138cb)
Signed-off-by: kiersten-stokes <kierstenstokes@gmail.com> Signed-off-by: PiratePai <416932041@qq.com> Signed-off-by: Pai <416932041@qq.com>
Signed-off-by: kiersten-stokes <kierstenstokes@gmail.com>
Purpose
Lazy loads the cv2 module to avoid import errors in certain envs when not needed
Error trace
Test Plan
Build locally in problem env and test for above error
Test Result
Local build succeeded as expected without above error
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.