File size: 908 Bytes
e8055cf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | import os
import pytest
from experiments import launch
def test_cpu_override(monkeypatch):
monkeypatch.setenv("VSI_CPU_WORKERS", "7")
assert launch.available_cpu_count() == 7
def test_invalid_cpu_override(monkeypatch):
monkeypatch.setenv("VSI_CPU_WORKERS", "0")
with pytest.raises(ValueError):
launch.available_cpu_count()
def test_thread_budget_sets_all_numerical_controls(monkeypatch):
for name in (
"OMP_NUM_THREADS",
"MKL_NUM_THREADS",
"OPENBLAS_NUM_THREADS",
"NUMEXPR_NUM_THREADS",
"VSI_KD_WORKERS",
):
monkeypatch.delenv(name, raising=False)
launch.configure_numerical_threads(3)
assert os.environ["VSI_KD_WORKERS"] == "3"
assert os.environ["OMP_NUM_THREADS"] == "3"
def test_empty_batch_does_not_spawn_workers():
assert launch.launch({}, [], workers=0) == {"built": 0, "loaded": 0, "failed": 0}
|