Merge remote-tracking branch 'origin/feat/expose-sampling-params-core' into pr-5711-head
This commit is contained in:
commit
0cf2097a81
1 changed files with 9 additions and 7 deletions
|
|
@ -63,16 +63,18 @@ def test_cpu_thread_cap_is_opt_in(raw):
|
|||
|
||||
|
||||
# Anything that is not a positive integer raises a clear ValueError.
|
||||
@pytest.mark.parametrize("raw", ["zero", "0", "-3", "1.5", "abc", "8a", "0x4", "1e3", "4 0"])
|
||||
@pytest.mark.parametrize(
|
||||
"raw", ["zero", "0", "-3", "1.5", "abc", "8a", "0x4", "1e3", "4 0"]
|
||||
)
|
||||
def test_cpu_thread_cap_requires_positive_integer(raw):
|
||||
with pytest.raises(ValueError, match="must be a positive integer"):
|
||||
with pytest.raises(ValueError, match = "must be a positive integer"):
|
||||
configure_cpu_threads({"UNSLOTH_CPU_THREADS": raw})
|
||||
|
||||
|
||||
# env=None path uses real os.environ (production call from run.py / main.py).
|
||||
def test_cpu_thread_cap_uses_os_environ_when_env_is_none(monkeypatch):
|
||||
for variable in (*_THREAD_POOL_ENV_VARS, "UNSLOTH_CPU_THREADS"):
|
||||
monkeypatch.delenv(variable, raising=False)
|
||||
monkeypatch.delenv(variable, raising = False)
|
||||
monkeypatch.setenv("UNSLOTH_CPU_THREADS", "3")
|
||||
|
||||
configure_cpu_threads()
|
||||
|
|
@ -84,7 +86,7 @@ def test_cpu_thread_cap_uses_os_environ_when_env_is_none(monkeypatch):
|
|||
# Calling twice must not flip any seeded value.
|
||||
def test_cpu_thread_cap_idempotent(monkeypatch):
|
||||
for variable in (*_THREAD_POOL_ENV_VARS, "UNSLOTH_CPU_THREADS"):
|
||||
monkeypatch.delenv(variable, raising=False)
|
||||
monkeypatch.delenv(variable, raising = False)
|
||||
monkeypatch.setenv("UNSLOTH_CPU_THREADS", "5")
|
||||
|
||||
configure_cpu_threads()
|
||||
|
|
@ -138,9 +140,9 @@ def test_invalid_cpu_thread_cap_exits_without_traceback(entry_point):
|
|||
|
||||
result = subprocess.run(
|
||||
[sys.executable, str(entry_point)],
|
||||
env=env,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
env = env,
|
||||
capture_output = True,
|
||||
text = True,
|
||||
)
|
||||
|
||||
assert result.returncode == 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue