Skip to content

[Core][Easy] Use envs.__getattr__ for all Unify to environment variable access#26810

Merged
mgoin merged 1 commit intovllm-project:mainfrom
Jialin:env-fix
Oct 15, 2025
Merged

[Core][Easy] Use envs.__getattr__ for all Unify to environment variable access#26810
mgoin merged 1 commit intovllm-project:mainfrom
Jialin:env-fix

Conversation

@Jialin
Copy link
Copy Markdown
Collaborator

@Jialin Jialin commented Oct 14, 2025

Purpose

Avoid directly using TYPE_CHECKING environment variables in the code (by updating all code with from vllm.envs import FOO_BAR). And use envs.FOO_BAR instead, which go through the envs.__getattr__ which has 2 benefits:

  1. no extra overhead, as environment variable caching is added in [Perf] Cache vllm.env.__getattr__ result to avoid recomputation #26146
  2. using __getattr__ ensured we adopted environment variable updates during service startup time.

This should be landed after #26146

Test Plan

N/A

Test Result

N/A


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

Signed-off-by: Jialin Ouyang <Jialin.Ouyang@gmail.com>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the way environment variables from vllm.envs are accessed throughout the codebase. The changes replace direct imports of environment variables (e.g., from vllm.envs import FOO_BAR) with module-level imports (import vllm.envs as envs) and qualified access (envs.FOO_BAR). This is a good practice as it ensures that environment variable values are fetched dynamically via __getattr__, allowing for updates to be reflected during service startup. The changes are applied consistently and correctly across the modified files. The code is clean and the refactoring improves maintainability.

@Jialin Jialin changed the title [Core] Use envs.__getattr__ for all Unify to environment variable access [Core][Easy] Use envs.__getattr__ for all Unify to environment variable access Oct 14, 2025
@Jialin
Copy link
Copy Markdown
Collaborator Author

Jialin commented Oct 14, 2025

CC @mgoin @yeqcharlotte @houseroad

@Jialin
Copy link
Copy Markdown
Collaborator Author

Jialin commented Oct 14, 2025

Resolve #26854

Copy link
Copy Markdown
Member

@mgoin mgoin left a comment

Choose a reason for hiding this comment

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

Thanks!

@mgoin mgoin enabled auto-merge (squash) October 14, 2025 23:40
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Oct 14, 2025
@mgoin mgoin merged commit 07ca70a into vllm-project:main Oct 15, 2025
51 of 52 checks passed
bbartels pushed a commit to bbartels/vllm that referenced this pull request Oct 16, 2025
…le access (vllm-project#26810)

Signed-off-by: Jialin Ouyang <Jialin.Ouyang@gmail.com>
Signed-off-by: bbartels <benjamin@bartels.dev>
lywa1998 pushed a commit to lywa1998/vllm that referenced this pull request Oct 20, 2025
…le access (vllm-project#26810)

Signed-off-by: Jialin Ouyang <Jialin.Ouyang@gmail.com>
alhridoy pushed a commit to alhridoy/vllm that referenced this pull request Oct 24, 2025
…le access (vllm-project#26810)

Signed-off-by: Jialin Ouyang <Jialin.Ouyang@gmail.com>
0xrushi pushed a commit to 0xrushi/vllm that referenced this pull request Oct 26, 2025
…le access (vllm-project#26810)

Signed-off-by: Jialin Ouyang <Jialin.Ouyang@gmail.com>
Signed-off-by: 0xrushi <6279035+0xrushi@users.noreply.github.com>
0xrushi pushed a commit to 0xrushi/vllm that referenced this pull request Oct 26, 2025
…le access (vllm-project#26810)

Signed-off-by: Jialin Ouyang <Jialin.Ouyang@gmail.com>
Signed-off-by: 0xrushi <6279035+0xrushi@users.noreply.github.com>
rtourgeman pushed a commit to rtourgeman/vllm that referenced this pull request Nov 10, 2025
…le access (vllm-project#26810)

Signed-off-by: Jialin Ouyang <Jialin.Ouyang@gmail.com>
devpatelio pushed a commit to SumanthRH/vllm that referenced this pull request Nov 29, 2025
…le access (vllm-project#26810)

Signed-off-by: Jialin Ouyang <Jialin.Ouyang@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

multi-modality Related to multi-modality (#4194) ready ONLY add when PR is ready to merge/full CI is needed v1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants