conftest.py 992 Bytes
Newer Older
1
2
import pytest
import pytest_asyncio
zhuwenwen's avatar
zhuwenwen committed
3
# from huggingface_hub import snapshot_download
4
5
6
7
8
9
10
11
12
13
14

from tests.utils import RemoteOpenAIServer

from .utils import ARGS, CONFIGS, ServerConfig


# for each server config, download the model and return the config
@pytest.fixture(scope="session", params=CONFIGS.keys())
def server_config(request):
    config = CONFIGS[request.param]
    # download model and tokenizer using transformers
zhuwenwen's avatar
zhuwenwen committed
15
    # snapshot_download(config["model"])
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
    yield CONFIGS[request.param]


# run this for each server config
@pytest.fixture(scope="session")
def server(request, server_config: ServerConfig):
    model = server_config["model"]
    args_for_model = server_config["arguments"]
    with RemoteOpenAIServer(model, ARGS + args_for_model,
                            max_wait_seconds=480) as server:
        yield server


@pytest_asyncio.fixture
async def client(server: RemoteOpenAIServer):
    async with server.get_async_client() as async_client:
        yield async_client