[Test] Cleanup for helpers (#6523)
Signed-off-by: wangyu <410167048@qq.com> Signed-off-by: [Your Name] <your.email@example.com> Co-authored-by: amy-why-3459 <wuhaiyan17@huawei.com>
This commit is contained in:
1 parent
8360346a66
commit
4af0ddc1c2
140 files changed
+4121
-4194
No files matched your search
@@ -1,10 +1,13 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
"""Runtime fixtures (OmniRunner / OmniServer). Imports are deferred to fixture time.
|
||||
|
||||
Loading ``tests.helpers.runtime`` at plugin import time (before session fixtures)
|
||||
pulls in vLLM/vllm_omni too early and breaks initialization order vs the legacy
|
||||
monolithic conftest. Defer imports until fixtures run so ``default_env`` /
|
||||
``default_vllm_config`` run first. Implementation helpers live in
|
||||
``tests.helpers.runtime`` (``iter_omni_server`` / ``iter_omni_runner``).
|
||||
monolithic conftest. Defer imports until fixtures run so session fixtures in
|
||||
``tests.helpers.fixtures.config`` run first. Server/runner helpers live in
|
||||
``tests.helpers.runtime``; request clients live in ``tests.helpers.client``.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -25,15 +28,14 @@ omni_fixture_lock = threading.Lock()
|
||||
def omni_server_function(
|
||||
request: pytest.FixtureRequest,
|
||||
run_level: str,
|
||||
model_prefix: str,
|
||||
) -> Generator[OmniServer, Any, None]:
|
||||
from tests.helpers.runtime import iter_omni_server
|
||||
|
||||
yield from iter_omni_server(request, run_level, model_prefix, omni_fixture_lock)
|
||||
yield from iter_omni_server(request, run_level, omni_fixture_lock)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def omni_server(request: pytest.FixtureRequest, run_level: str, model_prefix: str) -> Generator[OmniServer, Any, None]:
|
||||
def omni_server(request: pytest.FixtureRequest, run_level: str) -> Generator[OmniServer, Any, None]:
|
||||
"""Start vLLM-Omni through the standard or stage-CLI launcher.
|
||||
|
||||
The fixture stays module-scoped because multi-stage initialization is costly.
|
||||
@@ -42,16 +44,16 @@ def omni_server(request: pytest.FixtureRequest, run_level: str, model_prefix: st
|
||||
"""
|
||||
from tests.helpers.runtime import iter_omni_server
|
||||
|
||||
yield from iter_omni_server(request, run_level, model_prefix, omni_fixture_lock)
|
||||
yield from iter_omni_server(request, run_level, omni_fixture_lock)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def openai_client(request: pytest.FixtureRequest, run_level: str):
|
||||
def online_client(request: pytest.FixtureRequest, run_level: str):
|
||||
"""Resolve ``omni_server`` lazily so parametrized server fixtures work like upstream."""
|
||||
from tests.helpers.runtime import OpenAIClientHandler
|
||||
from tests.helpers.client import OnlineOmniClient
|
||||
|
||||
server = request.getfixturevalue("omni_server")
|
||||
return OpenAIClientHandler(
|
||||
return OnlineOmniClient(
|
||||
host=server.host,
|
||||
port=server.port,
|
||||
api_key="EMPTY",
|
||||
@@ -61,12 +63,18 @@ def openai_client(request: pytest.FixtureRequest, run_level: str):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def openai_client_function(request: pytest.FixtureRequest, run_level: str):
|
||||
def openai_client(online_client):
|
||||
"""Historical alias for :func:`online_client`."""
|
||||
return online_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def online_client_function(request: pytest.FixtureRequest, run_level: str):
|
||||
"""Resolve ``omni_server_function`` lazily for function-scoped reliability tests."""
|
||||
from tests.helpers.runtime import OpenAIClientHandler
|
||||
from tests.helpers.client import OnlineOmniClient
|
||||
|
||||
server = request.getfixturevalue("omni_server_function")
|
||||
return OpenAIClientHandler(
|
||||
return OnlineOmniClient(
|
||||
host=server.host,
|
||||
port=server.port,
|
||||
api_key="EMPTY",
|
||||
@@ -75,10 +83,15 @@ def openai_client_function(request: pytest.FixtureRequest, run_level: str):
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def openai_client_function(online_client_function):
|
||||
"""Historical alias for :func:`online_client_function`."""
|
||||
return online_client_function
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def omni_runner_function(
|
||||
request: pytest.FixtureRequest,
|
||||
model_prefix: str,
|
||||
run_level: str,
|
||||
) -> Generator[OmniRunner, Any, None]:
|
||||
"""Function-scoped :class:`~tests.helpers.runtime.OmniRunner` (cf. :func:`omni_server_function`).
|
||||
@@ -88,30 +101,42 @@ def omni_runner_function(
|
||||
"""
|
||||
from tests.helpers.runtime import iter_omni_runner
|
||||
|
||||
yield from iter_omni_runner(request, model_prefix, run_level, omni_fixture_lock)
|
||||
yield from iter_omni_runner(request, run_level, omni_fixture_lock)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def omni_runner(request: pytest.FixtureRequest, model_prefix: str, run_level: str) -> Generator[OmniRunner, Any, None]:
|
||||
def omni_runner(request: pytest.FixtureRequest, run_level: str) -> Generator[OmniRunner, Any, None]:
|
||||
"""Module-scoped :class:`~tests.helpers.runtime.OmniRunner` (cf. :func:`omni_server`).
|
||||
|
||||
Reuses one runner for the whole module to amortize multi-stage init cost.
|
||||
"""
|
||||
from tests.helpers.runtime import iter_omni_runner
|
||||
|
||||
yield from iter_omni_runner(request, model_prefix, run_level, omni_fixture_lock)
|
||||
yield from iter_omni_runner(request, run_level, omni_fixture_lock)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def omni_runner_handler_function(omni_runner_function: OmniRunner):
|
||||
"""Resolve :class:`~tests.helpers.runtime.OmniRunnerHandler` for :func:`omni_runner_function`."""
|
||||
from tests.helpers.runtime import OmniRunnerHandler
|
||||
def offline_client_function(omni_runner_function: OmniRunner):
|
||||
"""Resolve :class:`~tests.helpers.client.OfflineOmniClient` for :func:`omni_runner_function`."""
|
||||
from tests.helpers.client import OfflineOmniClient
|
||||
|
||||
return OmniRunnerHandler(omni_runner_function)
|
||||
return OfflineOmniClient(omni_runner_function)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def omni_runner_handler(omni_runner: OmniRunner):
|
||||
from tests.helpers.runtime import OmniRunnerHandler
|
||||
def omni_runner_handler_function(offline_client_function):
|
||||
"""Historical alias for :func:`offline_client_function`."""
|
||||
return offline_client_function
|
||||
|
||||
return OmniRunnerHandler(omni_runner)
|
||||
|
||||
@pytest.fixture
|
||||
def offline_client(omni_runner: OmniRunner):
|
||||
from tests.helpers.client import OfflineOmniClient
|
||||
|
||||
return OfflineOmniClient(omni_runner)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def omni_runner_handler(offline_client):
|
||||
"""Historical alias for :func:`offline_client`."""
|
||||
return offline_client
|
||||
Reference in new issue
Block a user