mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2026-01-11 18:04:28 +08:00
[Misc] Suppress log outputs when constructing the default vllm config. (#29291)
Signed-off-by: wang.yuqi <yuqi.wang@daocloud.io> Signed-off-by: wang.yuqi <noooop@126.com> Signed-off-by: Cyrus Leung <cyrus.tl.leung@gmail.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Cyrus Leung <cyrus.tl.leung@gmail.com> Co-authored-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
parent
7a80b01889
commit
de6889946b
@ -77,7 +77,7 @@ from vllm.config.observability import DetailedTraceModules
|
||||
from vllm.config.parallel import DistributedExecutorBackend, ExpertPlacementStrategy
|
||||
from vllm.config.scheduler import SchedulerPolicy
|
||||
from vllm.config.utils import get_field
|
||||
from vllm.logger import init_logger
|
||||
from vllm.logger import init_logger, suppress_logging
|
||||
from vllm.platforms import CpuArchEnum, current_platform
|
||||
from vllm.plugins import load_general_plugins
|
||||
from vllm.ray.lazy_utils import is_in_ray_actor, is_ray_initialized
|
||||
@ -247,11 +247,13 @@ def _compute_kwargs(cls: ConfigType) -> dict[str, dict[str, Any]]:
|
||||
default = field.default
|
||||
# Handle pydantic.Field defaults
|
||||
if isinstance(default, FieldInfo):
|
||||
default = (
|
||||
default.default
|
||||
if default.default_factory is None
|
||||
else default.default_factory()
|
||||
)
|
||||
if default.default_factory is None:
|
||||
default = default.default
|
||||
else:
|
||||
# VllmConfig's Fields have default_factory set to config classes.
|
||||
# These could emit logs on init, which would be confusing.
|
||||
with suppress_logging():
|
||||
default = default.default_factory()
|
||||
elif field.default_factory is not MISSING:
|
||||
default = field.default_factory()
|
||||
|
||||
|
||||
@ -7,7 +7,8 @@ import json
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
from collections.abc import Hashable
|
||||
from collections.abc import Generator, Hashable
|
||||
from contextlib import contextmanager
|
||||
from functools import lru_cache, partial
|
||||
from logging import Logger
|
||||
from logging.config import dictConfig
|
||||
@ -212,6 +213,14 @@ def init_logger(name: str) -> _VllmLogger:
|
||||
return cast(_VllmLogger, logger)
|
||||
|
||||
|
||||
@contextmanager
|
||||
def suppress_logging(level: int = logging.INFO) -> Generator[None, Any, None]:
|
||||
current_level = logging.root.manager.disable
|
||||
logging.disable(level)
|
||||
yield
|
||||
logging.disable(current_level)
|
||||
|
||||
|
||||
# The root logger is initialized when the module is imported.
|
||||
# This is thread-safe as the module is only imported once,
|
||||
# guaranteed by the Python GIL.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user