| 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} | |