using existing uvicorn configuration for dp supervisor (#52473)
Signed-off-by: Gregory Pereira <grpereir@redhat.com>
This commit is contained in:
@@ -86,6 +86,9 @@ def _make_unit_args(**overrides) -> argparse.Namespace:
|
||||
"pipeline_parallel_size": 1,
|
||||
"uvicorn_log_level": "info",
|
||||
"shutdown_timeout": 5.0,
|
||||
"disable_uvicorn_access_log": False,
|
||||
"disable_access_log_for_endpoints": None,
|
||||
"log_config_file": None,
|
||||
}
|
||||
base.update(overrides)
|
||||
return argparse.Namespace(**base)
|
||||
@@ -121,6 +124,9 @@ def _make_args(**overrides) -> argparse.Namespace:
|
||||
pipeline_parallel_size=1,
|
||||
uvicorn_log_level="warning",
|
||||
shutdown_timeout=0.0,
|
||||
disable_uvicorn_access_log=False,
|
||||
disable_access_log_for_endpoints=None,
|
||||
log_config_file=None,
|
||||
)
|
||||
base.update(overrides)
|
||||
return argparse.Namespace(**base)
|
||||
@@ -357,6 +363,100 @@ async def test_shutdown_if_supervisor_server_error_on_startup(
|
||||
await supervisor.run()
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Access-log filtering unit tests
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_start_server_applies_access_log_filter(monkeypatch):
|
||||
"""get_uvicorn_log_config result is forwarded to uvicorn.Config."""
|
||||
sentinel_config = {"version": 1, "loggers": {}}
|
||||
captured_config: list[uvicorn.Config] = []
|
||||
|
||||
monkeypatch.setattr(dp_sup, "get_uvicorn_log_config", lambda _args: sentinel_config)
|
||||
|
||||
class FakeServer:
|
||||
def __init__(self, config):
|
||||
captured_config.append(config)
|
||||
self.started = True
|
||||
self.should_exit = False
|
||||
|
||||
async def serve(self):
|
||||
pass
|
||||
|
||||
monkeypatch.setattr(dp_sup, "NoSignalServer", FakeServer)
|
||||
|
||||
args = _make_unit_args(
|
||||
host="127.0.0.1",
|
||||
disable_access_log_for_endpoints="/health,/readyz",
|
||||
)
|
||||
supervisor = DPSupervisor(args)
|
||||
await supervisor._start_server()
|
||||
|
||||
assert len(captured_config) == 1
|
||||
config = captured_config[0]
|
||||
assert config.log_config is sentinel_config
|
||||
assert config.access_log is True
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_start_server_disables_access_log(monkeypatch):
|
||||
"""disable_uvicorn_access_log=True sets access_log=False."""
|
||||
captured_config: list[uvicorn.Config] = []
|
||||
|
||||
monkeypatch.setattr(dp_sup, "get_uvicorn_log_config", lambda _args: None)
|
||||
|
||||
class FakeServer:
|
||||
def __init__(self, config):
|
||||
captured_config.append(config)
|
||||
self.started = True
|
||||
self.should_exit = False
|
||||
|
||||
async def serve(self):
|
||||
pass
|
||||
|
||||
monkeypatch.setattr(dp_sup, "NoSignalServer", FakeServer)
|
||||
|
||||
args = _make_unit_args(
|
||||
host="127.0.0.1",
|
||||
disable_uvicorn_access_log=True,
|
||||
)
|
||||
supervisor = DPSupervisor(args)
|
||||
await supervisor._start_server()
|
||||
|
||||
assert len(captured_config) == 1
|
||||
assert captured_config[0].access_log is False
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_start_server_no_log_config_when_no_filter(monkeypatch):
|
||||
"""Without filtering options, default uvicorn log_config is used."""
|
||||
captured_config: list[uvicorn.Config] = []
|
||||
|
||||
monkeypatch.setattr(dp_sup, "get_uvicorn_log_config", lambda _args: None)
|
||||
|
||||
class FakeServer:
|
||||
def __init__(self, config):
|
||||
captured_config.append(config)
|
||||
self.started = True
|
||||
self.should_exit = False
|
||||
|
||||
async def serve(self):
|
||||
pass
|
||||
|
||||
monkeypatch.setattr(dp_sup, "NoSignalServer", FakeServer)
|
||||
|
||||
args = _make_unit_args(host="127.0.0.1")
|
||||
supervisor = DPSupervisor(args)
|
||||
await supervisor._start_server()
|
||||
|
||||
assert len(captured_config) == 1
|
||||
config = captured_config[0]
|
||||
assert config.log_config == uvicorn.Config(app=None).log_config
|
||||
assert config.access_log is True
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Lifecycle integration tests – MockVLLMServer
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@@ -24,6 +24,7 @@ from fastapi import FastAPI, Response
|
||||
|
||||
import vllm.envs as envs
|
||||
from vllm.entrypoints.launchers.launcher import NoSignalServer
|
||||
from vllm.entrypoints.launchers.utils.server_utils import get_uvicorn_log_config
|
||||
from vllm.logger import init_logger
|
||||
from vllm.utils.system_utils import (
|
||||
decorate_logs,
|
||||
@@ -326,16 +327,24 @@ class DPSupervisor:
|
||||
"""
|
||||
app = _build_dp_supervisor_app(self)
|
||||
host = self.args.host or "0.0.0.0"
|
||||
|
||||
uvicorn_kwargs: dict = {}
|
||||
log_config = get_uvicorn_log_config(self.args)
|
||||
if log_config is not None:
|
||||
uvicorn_kwargs["log_config"] = log_config
|
||||
|
||||
config = uvicorn.Config(
|
||||
app,
|
||||
host=host,
|
||||
port=self.supervisor_port,
|
||||
log_level=self.args.uvicorn_log_level,
|
||||
access_log=not self.args.disable_uvicorn_access_log,
|
||||
ssl_keyfile=self.args.ssl_keyfile,
|
||||
ssl_certfile=self.args.ssl_certfile,
|
||||
ssl_ca_certs=self.args.ssl_ca_certs,
|
||||
ssl_cert_reqs=self.args.ssl_cert_reqs,
|
||||
ssl_ciphers=self.args.ssl_ciphers,
|
||||
**uvicorn_kwargs,
|
||||
)
|
||||
supervisor_server = NoSignalServer(config)
|
||||
supervisor_server_task = asyncio.create_task(
|
||||
|
||||
Reference in New Issue
Block a user