Skip to content

Fix optional dependency imports in CI tests - #10046

Merged
tastelikefeet merged 1 commit into
modelscope:mainfrom
taking-lying-flat:fix/ci-optional-imports
Sep 5, 2026
Merged

Fix optional dependency imports in CI tests#10046
tastelikefeet merged 1 commit into
modelscope:mainfrom
taking-lying-flat:fix/ci-optional-imports

Conversation

@taking-lying-flat

Copy link
Copy Markdown
Contributor

Summary

Fix two optional-dependency import failures without skipping tests or adding dependencies to the CI environment:

  • Move the imports in tests/llm/test_web_ui.py under its existing __main__ guard. This file is a manual WebUI launcher, not a unittest test case. Test discovery no longer imports swift.ui and requires Gradio, while direct execution still launches the UI with WebUIArguments.
  • Import Gemma3ProcessorKwargs only in the image branch of Gemma3VisionTemplate._encode. The text-only test previously failed with ModuleNotFoundError: No module named 'transformers.models.gemma3' in environments without that Transformers module, although the processor defaults are only used for images.
  • Strengthen the existing Gemma3 text-only regression test by making the processor module unavailable. Keep the original token_type_ids assertion and execute the real vision-template encoding method.

Image processing still uses the same processor defaults and still raises when its required dependency is missing. No tests are skipped, no import errors are swallowed, and no dependency requirements are changed.

This is an independent CI fix based on main; it does not include the DPO/IPO changes from #9925 or the checkpoint-reader changes from #10045.

Validation

  • Existing Gemma3 text-only regression test passes with the processor module explicitly unavailable.
  • Three additional local checks pass: WebUI discovery with Gradio/UI imports blocked, manual WebUI entry-point dispatch with stubbed UI modules, and Gemma3 image encoding with a mock image processor and the actual processor defaults (4 tests passed in total).
  • Explicitly checked that, with the entire Gemma3 package unavailable, text-only encoding succeeds with unchanged IDs/labels and image encoding still raises ModuleNotFoundError.
  • uvx pre-commit run --all-files passes.

Validation above is local and CPU-only; GPU/NPU CI results are pending.

@tastelikefeet
tastelikefeet merged commit 6c130f3 into modelscope:main Sep 5, 2026
3 checks passed
@taking-lying-flat
taking-lying-flat deleted the fix/ci-optional-imports branch September 5, 2026 01:29
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