Skip to content

Commit 56074a1

Browse files
committed
Raise on invalid StatLogger plugin
Signed-off-by: tovam <[email protected]>
1 parent 9d41ec8 commit 56074a1

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

tests/plugins_tests/test_stats_logger_plugins.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,23 @@ def test_no_plugins_loaded_if_env_empty(monkeypatch: pytest.MonkeyPatch):
3434
assert factories == []
3535

3636

37+
def test_invalid_stat_logger_plugin_raises(monkeypatch: pytest.MonkeyPatch):
38+
def fake_plugin_loader(group: str):
39+
assert group == "vllm.stat_logger_plugins"
40+
return {"bad": object()}
41+
42+
with monkeypatch.context() as m:
43+
m.setattr(
44+
"vllm.v1.metrics.loggers.load_plugins_by_group",
45+
fake_plugin_loader,
46+
)
47+
with pytest.raises(
48+
TypeError,
49+
match="Stat logger plugin 'bad' must be a subclass of StatLoggerBase",
50+
):
51+
load_stat_logger_plugin_factories()
52+
53+
3754
@pytest.mark.asyncio
3855
async def test_stat_logger_plugin_integration_with_engine(
3956
monkeypatch: pytest.MonkeyPatch,

vllm/v1/metrics/loggers.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,10 @@ def load_stat_logger_plugin_factories() -> list[StatLoggerFactory]:
6464
if not isinstance(plugin_class, type) or not issubclass(
6565
plugin_class, StatLoggerBase
6666
):
67-
logger.warning(
68-
"Stat logger plugin %s is not a valid subclass "
69-
"of StatLoggerBase. Skipping.",
70-
name,
67+
raise TypeError(
68+
f"Stat logger plugin {name!r} must be a subclass of "
69+
f"StatLoggerBase (got {plugin_class!r})."
7170
)
72-
continue
7371

7472
factories.append(plugin_class)
7573

0 commit comments

Comments
 (0)