Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions tests/plugins_tests/test_ecpa_plugin_evidence.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import pytest

import vllm.plugins as plugins
from vllm.entrypoints.cli.main import _bind_serve_process_identity
from vllm.plugins import evidence

Payload = dict[str, Any]
Expand Down Expand Up @@ -75,6 +76,21 @@ def expected_event_id(payload: Payload) -> str:
return hashlib.sha256(material).hexdigest()


def test_serve_cli_binds_parent_before_general_plugin_loading():
_bind_serve_process_identity(["vllm", "serve", "model"])
process = evidence.capture_scope()["process"]
assert (process["role"], process["ordinal"], process["assignment_source"]) == (
"api-server",
0,
"host",
)


def test_non_serve_cli_does_not_claim_api_server_role():
_bind_serve_process_identity(["vllm", "bench"])
assert evidence.capture_scope()["process"]["assignment_source"] == "environment"


def test_event_id_and_deduplication_bind_assignment_source(monkeypatch):
events: list[Payload] = []
enable(events)
Expand Down
13 changes: 13 additions & 0 deletions vllm/entrypoints/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
logger = init_logger(__name__)


def _bind_serve_process_identity(argv: list[str]) -> None:
"""Bind the single-process serve parent before parser plugins execute."""
if argv[1:2] != ["serve"]:
return
from vllm.plugins.evidence import bind_process_identity

bind_process_identity("api-server", 0)


def maybe_run_omni() -> bool:
# If `--omni` arg is passed to the CLI, delegate to vLLM Omni's entrypoint handling
if "--omni" not in sys.argv:
Expand All @@ -40,6 +49,10 @@ def main():
if maybe_run_omni():
return

# Parser construction loads general plugins. Bind before those imports so
# the parent event is host-assigned rather than `unknown`/environment.
_bind_serve_process_identity(sys.argv)

import vllm.entrypoints.cli.benchmark.main
import vllm.entrypoints.cli.collect_env
import vllm.entrypoints.cli.download_kernels
Expand Down
Loading
Loading