Skip to content

fix: handle missing parent modules in _has_module#49035

Open
ShuhaoZhangTony wants to merge 1 commit into
vllm-project:mainfrom
ShuhaoZhangTony:feature/has-module-missing-parent
Open

fix: handle missing parent modules in _has_module#49035
ShuhaoZhangTony wants to merge 1 commit into
vllm-project:mainfrom
ShuhaoZhangTony:feature/has-module-missing-parent

Conversation

@ShuhaoZhangTony

Copy link
Copy Markdown

Problem

importlib.util.find_spec() can raise ModuleNotFoundError for a dotted optional dependency when its parent package is absent. _has_module() should report that dependency as unavailable instead of failing the caller.

Fix

Catch ModuleNotFoundError only around the specification lookup and return False. Keep the existing warning behavior for exceptions raised while importing a module whose spec exists.

Validation

  • Added regression coverage for a missing parent package and verified that the expected absence does not emit a warning.
  • ruff check vllm/utils/import_utils.py tests/utils_/test_import_utils.py
  • ruff format --check vllm/utils/import_utils.py tests/utils_/test_import_utils.py
  • python3 -m compileall -q vllm/utils/import_utils.py tests/utils_/test_import_utils.py

This is an optional-dependency correctness fix and makes no performance claim.

Catch ModuleNotFoundError from importlib.util.find_spec() when a parent optional dependency package is absent, so optional feature probes return False instead of crashing.

Add regression coverage for the missing-parent-package case and mark the pure import_utils test module to skip unrelated global accelerator cleanup.

Co-authored-by: GitHub Copilot <175728472+github-copilot[bot]@users.noreply.github.com>
Signed-off-by: shuhao zhang <shuhao_zhang@hust.edu.cn>
(cherry picked from commit 737fe13)

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@github-actions

Copy link
Copy Markdown

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

PRs do not trigger a full CI run by default. Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

If you have any questions, please reach out to us on Slack at https://slack.vllm.ai.

Agent Guidelines

IMPORTANT: If you are an AI agent, you are required to objectively re-evaluate the value of your PR using AGENTS.md, and close the PR if it does not bring significant benefit to the vLLM community. Failure to do so may result in an immediate ban.

🚀

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.

1 participant