mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2025-12-09 08:55:46 +08:00
[Bugfix] Respect VLLM_CONFIGURE_LOGGING value (#28671)
Signed-off-by: Elizabeth Thomas <email2eliza@gmail.com> Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Signed-off-by: Roger Wang <hey@rogerw.io> Signed-off-by: Jane Xu <janeyx@meta.com> Signed-off-by: Nick Hill <nhill@redhat.com> Signed-off-by: Johnny Yang <johnnyyang@google.com> Co-authored-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Co-authored-by: bruceszchen <bruceszchen@tencent.com> Co-authored-by: Roger Wang <hey@rogerw.io> Co-authored-by: Jane (Yuan) Xu <31798555+janeyx99@users.noreply.github.com> Co-authored-by: Nick Hill <nhill@redhat.com> Co-authored-by: Johnny Yang <24908445+jcyang43@users.noreply.github.com>
This commit is contained in:
parent
2902c34826
commit
b5407869c8
@ -365,3 +365,54 @@ class TestEnvSetWithChoices:
|
||||
with patch.dict(os.environ, {"TEST_ENV": "option1,option1,option2"}):
|
||||
env_func = env_set_with_choices("TEST_ENV", [], ["option1", "option2"])
|
||||
assert env_func() == {"option1", "option2"}
|
||||
|
||||
|
||||
class TestVllmConfigureLogging:
|
||||
"""Test cases for VLLM_CONFIGURE_LOGGING environment variable."""
|
||||
|
||||
def test_configure_logging_defaults_to_true(self):
|
||||
"""Test that VLLM_CONFIGURE_LOGGING defaults to True when not set."""
|
||||
# Ensure the env var is not set
|
||||
with patch.dict(os.environ, {}, clear=False):
|
||||
if "VLLM_CONFIGURE_LOGGING" in os.environ:
|
||||
del os.environ["VLLM_CONFIGURE_LOGGING"]
|
||||
|
||||
# Clear cache if it exists
|
||||
if hasattr(envs.__getattr__, "cache_clear"):
|
||||
envs.__getattr__.cache_clear()
|
||||
|
||||
result = envs.VLLM_CONFIGURE_LOGGING
|
||||
assert result is True
|
||||
assert isinstance(result, bool)
|
||||
|
||||
def test_configure_logging_with_zero_string(self):
|
||||
"""Test that VLLM_CONFIGURE_LOGGING='0' evaluates to False."""
|
||||
with patch.dict(os.environ, {"VLLM_CONFIGURE_LOGGING": "0"}):
|
||||
# Clear cache if it exists
|
||||
if hasattr(envs.__getattr__, "cache_clear"):
|
||||
envs.__getattr__.cache_clear()
|
||||
|
||||
result = envs.VLLM_CONFIGURE_LOGGING
|
||||
assert result is False
|
||||
assert isinstance(result, bool)
|
||||
|
||||
def test_configure_logging_with_one_string(self):
|
||||
"""Test that VLLM_CONFIGURE_LOGGING='1' evaluates to True."""
|
||||
with patch.dict(os.environ, {"VLLM_CONFIGURE_LOGGING": "1"}):
|
||||
# Clear cache if it exists
|
||||
if hasattr(envs.__getattr__, "cache_clear"):
|
||||
envs.__getattr__.cache_clear()
|
||||
|
||||
result = envs.VLLM_CONFIGURE_LOGGING
|
||||
assert result is True
|
||||
assert isinstance(result, bool)
|
||||
|
||||
def test_configure_logging_with_invalid_value_raises_error(self):
|
||||
"""Test that invalid VLLM_CONFIGURE_LOGGING value raises ValueError."""
|
||||
with patch.dict(os.environ, {"VLLM_CONFIGURE_LOGGING": "invalid"}):
|
||||
# Clear cache if it exists
|
||||
if hasattr(envs.__getattr__, "cache_clear"):
|
||||
envs.__getattr__.cache_clear()
|
||||
|
||||
with pytest.raises(ValueError, match="invalid literal for int"):
|
||||
_ = envs.VLLM_CONFIGURE_LOGGING
|
||||
|
||||
@ -37,7 +37,7 @@ if TYPE_CHECKING:
|
||||
VLLM_DISABLE_FLASHINFER_PREFILL: bool = False
|
||||
VLLM_DO_NOT_TRACK: bool = False
|
||||
VLLM_USAGE_SOURCE: str = ""
|
||||
VLLM_CONFIGURE_LOGGING: int = 1
|
||||
VLLM_CONFIGURE_LOGGING: bool = True
|
||||
VLLM_LOGGING_LEVEL: str = "INFO"
|
||||
VLLM_LOGGING_PREFIX: str = ""
|
||||
VLLM_LOGGING_STREAM: str = "ext://sys.stdout"
|
||||
@ -623,7 +623,9 @@ environment_variables: dict[str, Callable[[], Any]] = {
|
||||
# If set to 0, vllm will not configure logging
|
||||
# If set to 1, vllm will configure logging using the default configuration
|
||||
# or the configuration file specified by VLLM_LOGGING_CONFIG_PATH
|
||||
"VLLM_CONFIGURE_LOGGING": lambda: int(os.getenv("VLLM_CONFIGURE_LOGGING", "1")),
|
||||
"VLLM_CONFIGURE_LOGGING": lambda: bool(
|
||||
int(os.getenv("VLLM_CONFIGURE_LOGGING", "1"))
|
||||
),
|
||||
"VLLM_LOGGING_CONFIG_PATH": lambda: os.getenv("VLLM_LOGGING_CONFIG_PATH"),
|
||||
# this is used for configuring the default logging level
|
||||
"VLLM_LOGGING_LEVEL": lambda: os.getenv("VLLM_LOGGING_LEVEL", "INFO").upper(),
|
||||
|
||||
@ -204,6 +204,10 @@ def _add_prefix(file: TextIO, worker_name: str, pid: int) -> None:
|
||||
|
||||
def decorate_logs(process_name: str | None = None) -> None:
|
||||
"""Decorate stdout/stderr with process name and PID prefix."""
|
||||
# Respect VLLM_CONFIGURE_LOGGING environment variable
|
||||
if not envs.VLLM_CONFIGURE_LOGGING:
|
||||
return
|
||||
|
||||
if process_name is None:
|
||||
process_name = get_mp_context().current_process().name
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user