| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
| 3 | |
| 4 | import pytest |
| 5 | import pytest_asyncio |
| 6 | |
| 7 | from tests.utils import RemoteOpenAIServer |
| 8 | from vllm.platforms import current_platform |
| 9 | from vllm.transformers_utils.repo_utils import hf_api |
| 10 | |
| 11 | from .utils import ARGS, CONFIGS, ServerConfig |
| 12 | |
| 13 | |
| 14 | # for each server config, download the model and return the config |
| 15 | @pytest.fixture(scope="package", params=CONFIGS.keys()) |
| 16 | def server_config(request): |
| 17 | config = CONFIGS[request.param] |
| 18 | |
| 19 | if current_platform.is_rocm() and not config.get("supports_rocm", True): |
| 20 | pytest.skip( |
| 21 | "The {} model can't be tested on the ROCm platform".format(config["model"]) |
| 22 | ) |
| 23 | |
| 24 | # download model and tokenizer using transformers |
| 25 | hf_api().snapshot_download(config["model"]) |
| 26 | yield CONFIGS[request.param] |
| 27 | |
| 28 | |
| 29 | # run this for each server config |
| 30 | @pytest.fixture(scope="package") |
| 31 | def server(request, server_config: ServerConfig): |
| 32 | model = server_config["model"] |
| 33 | args_for_model = server_config["arguments"] |
| 34 | with RemoteOpenAIServer( |
| 35 | model, ARGS + args_for_model, max_wait_seconds=480 |
| 36 | ) as server: |
| 37 | yield server |
| 38 | |
| 39 | |
| 40 | @pytest_asyncio.fixture |
| 41 | async def client(server: RemoteOpenAIServer): |
| 42 | async with server.get_async_client() as async_client: |
| 43 | yield async_client |