char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
42f0225fe
char/aliceai-t5-moe
1import os 2import pytest 3from filelock import FileLock 4from utils import * 5 6 7@ pytest . fixture ( scope = "session" , autouse = True ) 8def configure_worker_port (request ): 9worker_id = getattr (request .config ,"workerinput" , {}).get ("workerid" ,"master" ) 10if worker_id != "master" : 11worker_num = int (worker_id [2 :]) 12os .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-test 16@ pytest . fixture ( autouse = True ) 17def stop_server_after_each_test (): 18# do nothing before each test 19yield 20# stop all servers after each test 21instances = set ( 22server_instances 23 )# copy the set to prevent 'Set changed size during iteration' 24for server in instances : 25server .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 tests 31 32# serialize model downloads across parallel workers. 33root_tmp_dir = tmp_path_factory .getbasetemp ().parent 34with FileLock (str (root_tmp_dir / "load_all.lock" )): 35ServerPreset .load_all ()