Skip to content

[Misc] Add deprecated environment variable utilities#33677

Merged
vllm-bot merged 2 commits intovllm-project:mainfrom
carlory:add-deprecated-env-var-utils
Feb 20, 2026
Merged

[Misc] Add deprecated environment variable utilities#33677
vllm-bot merged 2 commits intovllm-project:mainfrom
carlory:add-deprecated-env-var-utils

Conversation

@carlory
Copy link
Copy Markdown
Contributor

@carlory carlory commented Feb 3, 2026

Purpose

Add general-purpose utilities for handling deprecated environment variables with deprecation warnings. These functions can be reused across the codebase when deprecating environment variables in favor of CLI arguments or config options.

This addresses the suggestion from @hmellor in PR #33536 to add general versions of the removed _get_from_env_if_set and _set_from_env_if_set methods to utils.py for reuse in future deprecations.

New functions added to vllm/utils/system_utils.py:

  • get_deprecated_env_var(): Get value from deprecated env var with warning
  • set_from_deprecated_env_var(): Set object field from deprecated env var with optional type conversion (bool/int)

Usage example:

from vllm.utils.system_utils import set_from_deprecated_env_var

# In a config class validator:
set_from_deprecated_env_var(
    self,
    field_name="torch_profiler_dir",
    env_var_name="VLLM_TORCH_PROFILER_DIR",
    alternative="--profiler-config.torch_profiler_dir"
)

set_from_deprecated_env_var(
    self,
    field_name="delay_iterations",
    env_var_name="VLLM_PROFILER_DELAY_ITERS",
    to_int=True,
    deprecation_version="v0.15.0",
    alternative="--profiler-config.delay_iterations"
)

Test Plan

  1. Run linting: pre-commit run --files vllm/utils/system_utils.py
  2. Run type checking: pre-commit run --hook-stage manual mypy-3.12 --files vllm/utils/system_utils.py
  3. Verify module imports correctly:
    python -c "from vllm.utils.system_utils import get_deprecated_env_var, set_from_deprecated_env_var; print('OK')"

Test Result

All pre-commit hooks pass:

ruff check..........................................................................................Passed
ruff format.........................................................................................Passed
typos...............................................................................................Passed
Run mypy locally for lowest supported Python version................................................Passed
Check SPDX headers..................................................................................Passed

Import verification:

$ python -c "from vllm.utils.system_utils import get_deprecated_env_var, set_from_deprecated_env_var; print('OK')"
OK

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

The pull request introduces general-purpose utilities for handling deprecated environment variables, which is a valuable addition for managing feature deprecation in the codebase. The new functions get_deprecated_env_var and set_from_deprecated_env_var provide a centralized mechanism for issuing warnings and facilitating transitions. However, there are critical issues in the type handling and conversion logic within these functions that need to be addressed to ensure correct behavior.

Comment thread vllm/utils/system_utils.py Outdated
Comment thread vllm/utils/system_utils.py Outdated
Comment thread vllm/utils/system_utils.py Outdated
Comment thread vllm/utils/system_utils.py Outdated
@carlory carlory marked this pull request as draft February 3, 2026 09:50
@carlory carlory force-pushed the add-deprecated-env-var-utils branch from 375fef3 to b93b894 Compare February 3, 2026 10:04
@carlory carlory marked this pull request as ready for review February 3, 2026 10:12
Copy link
Copy Markdown
Member

@hmellor hmellor left a comment

Choose a reason for hiding this comment

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

Thanks for this PR! Could the utilities please be moved to the config utils? The only place we should be using these is when we are forwarding environment variables to the config fields that replace them

@carlory
Copy link
Copy Markdown
Contributor Author

carlory commented Feb 4, 2026

@hmellor updated.

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Feb 4, 2026

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @carlory.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase label Feb 4, 2026
@carlory carlory force-pushed the add-deprecated-env-var-utils branch from ca21c2b to 3d607f5 Compare February 9, 2026 03:44
@mergify mergify Bot removed the needs-rebase label Feb 9, 2026
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Feb 9, 2026

Hi @carlory, the pre-commit checks have failed. Please run:

uv pip install pre-commit
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Tip

Is mypy or markdownlint failing?
mypy and markdownlint are run differently in CI. If the failure is related to either of these checks, please use the following commands to run them locally:
# For mypy (substitute "3.10" with the failing version if needed)
pre-commit run --hook-stage manual mypy-3.10
# For markdownlint
pre-commit run --hook-stage manual markdownlint

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: carlory <baofa.fan@daocloud.io>
@carlory carlory force-pushed the add-deprecated-env-var-utils branch from 3d607f5 to b3e4b78 Compare February 9, 2026 05:51
Copy link
Copy Markdown
Member

@hmellor hmellor left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for adding back these utilities

@hmellor hmellor enabled auto-merge (squash) February 19, 2026 10:46
@github-actions github-actions Bot added the ready ONLY add when PR is ready to merge/full CI is needed label Feb 19, 2026
@vllm-bot vllm-bot merged commit 07cab21 into vllm-project:main Feb 20, 2026
44 of 48 checks passed
yugong333 pushed a commit to yugong333/vllm that referenced this pull request Feb 22, 2026
)

Signed-off-by: carlory <baofa.fan@daocloud.io>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
jmamou pushed a commit to jmamou/vllm that referenced this pull request Feb 23, 2026
)

Signed-off-by: carlory <baofa.fan@daocloud.io>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
@carlory carlory deleted the add-deprecated-env-var-utils branch February 24, 2026 02:17
Copilot AI pushed a commit to machov/vllm that referenced this pull request Mar 10, 2026
)

Signed-off-by: carlory <baofa.fan@daocloud.io>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
jiangkuaixue123 pushed a commit to jiangkuaixue123/vllm that referenced this pull request Apr 28, 2026
)

Signed-off-by: carlory <baofa.fan@daocloud.io>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants