test_flash_santacoder.py 995 Bytes
Newer Older
1
2
import pytest

3
4
5
6
7

@pytest.fixture(scope="module")
def flash_santacoder_handle(launcher):
    with launcher("bigcode/santacoder") as handle:
        yield handle
8
9
10


@pytest.fixture(scope="module")
11
12
13
async def flash_santacoder(flash_santacoder_handle):
    await flash_santacoder_handle.health(240)
    return flash_santacoder_handle.client
14
15
16


@pytest.mark.asyncio
17
async def test_flash_santacoder(flash_santacoder, response_snapshot):
18
19
20
    response = await flash_santacoder.generate("def print_hello", max_new_tokens=10)

    assert response.details.generated_tokens == 10
21
    assert response == response_snapshot
22
23
24


@pytest.mark.asyncio
25
26
27
async def test_flash_santacoder_load(
    flash_santacoder, generate_load, response_snapshot
):
28
29
30
31
32
    responses = await generate_load(
        flash_santacoder, "def print_hello", max_new_tokens=10, n=4
    )

    assert len(responses) == 4
33
    assert all([r.generated_text == responses[0].generated_text for r in responses])
34

35
    assert responses == response_snapshot