Team Ai
Modelpublic

Felipe97/llama-cpp-compiled

sourceHugging Faceupdated 21d agoView on Hugging Face
0likes1.2kdownloads
conftest.py36 linesDownload Raw Back to tests
1import os2import pytest3from filelock import FileLock4from utils import *5 6 7@pytest.fixture(scope="session", autouse=True)8def configure_worker_port(request):9    worker_id = getattr(request.config, "workerinput", {}).get("workerid", "master")10    if worker_id != "master":11        worker_num = int(worker_id[2:])12        os.environ["PORT"] = str(8080 + worker_num * 10)13 14 15# ref: https://stackoverflow.com/questions/22627659/run-code-before-and-after-each-test-in-py-test16@pytest.fixture(autouse=True)17def stop_server_after_each_test():18    # do nothing before each test19    yield20    # stop all servers after each test21    instances = set(22        server_instances23    )  # copy the set to prevent 'Set changed size during iteration'24    for server in instances:25        server.stop()26 27 28@pytest.fixture(scope="session", autouse=True)29def load_server_presets(configure_worker_port, tmp_path_factory):30    # this will be run once per test session, before any tests31 32    # serialize model downloads across parallel workers.33    root_tmp_dir = tmp_path_factory.getbasetemp().parent34    with FileLock(str(root_tmp_dir / "load_all.lock")):35        ServerPreset.load_all()36