[Bugfix] Preserve non-logitproc entry points in tests (#51097)
Signed-off-by: Tristan Rice <rice@fn.lc>
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
import importlib.metadata
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
|
||||
import tests.v1.logits_processors.utils as logitproc_test_utils
|
||||
from tests.utils import create_new_process_for_each_test, set_random_seed
|
||||
from tests.v1.logits_processors.utils import (
|
||||
DUMMY_LOGITPROC_ARG,
|
||||
@@ -42,6 +44,32 @@ sampling_params_list = [
|
||||
]
|
||||
|
||||
|
||||
def test_fake_entrypoint_preserves_other_groups(monkeypatch):
|
||||
other_group_entrypoints = object()
|
||||
monkeypatch.setattr(
|
||||
importlib.metadata,
|
||||
"entry_points",
|
||||
lambda **kwargs: other_group_entrypoints,
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
logitproc_test_utils, "requires_spawn_multiprocessing", lambda: False
|
||||
)
|
||||
|
||||
setup_fake_entrypoint(monkeypatch)
|
||||
|
||||
logitproc_entrypoints = importlib.metadata.entry_points(
|
||||
group=logitproc_test_utils.LOGITSPROCS_GROUP
|
||||
)
|
||||
assert logitproc_entrypoints.names == [
|
||||
logitproc_test_utils.DUMMY_LOGITPROC_ENTRYPOINT
|
||||
]
|
||||
assert (
|
||||
importlib.metadata.entry_points(group="another.entrypoint.group")
|
||||
is other_group_entrypoints
|
||||
)
|
||||
assert importlib.metadata.entry_points() is other_group_entrypoints
|
||||
|
||||
|
||||
def _run_test(kwargs: dict, logitproc_loaded: bool) -> None:
|
||||
"""Compare `LLM` instance initialized with specified `kwargs` against
|
||||
reference `LLM` instance.
|
||||
|
||||
@@ -234,11 +234,6 @@ def register_fake_entrypoint(monkeypatch) -> str:
|
||||
return str(tmpdir)
|
||||
|
||||
|
||||
def fake_entry_points(group: str) -> EntryPoints:
|
||||
"""Fake version of importlib.metadata.entry_points."""
|
||||
return EntryPoints(group)
|
||||
|
||||
|
||||
def setup_fake_entrypoint(monkeypatch) -> None:
|
||||
"""Expose the dummy logitproc entrypoint for the current platform."""
|
||||
if requires_spawn_multiprocessing():
|
||||
@@ -248,5 +243,13 @@ def setup_fake_entrypoint(monkeypatch) -> None:
|
||||
|
||||
import importlib.metadata
|
||||
|
||||
original_entry_points = importlib.metadata.entry_points
|
||||
|
||||
def fake_entry_points(**kwargs):
|
||||
group = kwargs.get("group")
|
||||
if group == LOGITSPROCS_GROUP:
|
||||
return EntryPoints(group)
|
||||
return original_entry_points(**kwargs)
|
||||
|
||||
monkeypatch.setattr(importlib.metadata, "entry_points", fake_entry_points)
|
||||
monkeypatch.setenv("VLLM_WORKER_MULTIPROC_METHOD", "fork")
|
||||
|
||||
Reference in New Issue
Block a user