mirror of
https://github.com/elder-plinius/OBLITERATUS.git
synced 2026-12-05 10:34:23 +01:00
37 lines
1.5 KiB
Python
37 lines
1.5 KiB
Python
"""Empty evaluation partitions cannot start checkpoint loading or configuration."""
|
|
|
|
from unittest.mock import Mock
|
|
|
|
import pytest
|
|
|
|
from obliteratus import checkpoint_evaluation
|
|
|
|
pytestmark = pytest.mark.cpu
|
|
|
|
|
|
@pytest.mark.parametrize("partition", ["optimizer_tune", "final_test"])
|
|
@pytest.mark.parametrize("max_prompts", [None, 1])
|
|
def test_empty_prompt_partition_refuses_before_loading(tmp_path, monkeypatch, partition, max_prompts):
|
|
lifecycle = Mock(spec=["loading", "resize", "ready", "release"])
|
|
pipeline = Mock(side_effect=AssertionError("empty partition must not construct a pipeline"))
|
|
configure, log = Mock(), Mock()
|
|
pairs = Mock(return_value=())
|
|
monkeypatch.setattr(checkpoint_evaluation, "_partition_pairs", pairs)
|
|
monkeypatch.setattr(checkpoint_evaluation, "from_environment", lambda: lifecycle)
|
|
monkeypatch.setattr(checkpoint_evaluation, "AbliterationPipeline", pipeline)
|
|
|
|
with pytest.raises(ValueError, match="^evaluation partition contains no prompt pairs$"):
|
|
checkpoint_evaluation.evaluate_checkpoint(
|
|
tmp_path / "checkpoint", partition=partition, max_prompts=max_prompts,
|
|
configure=configure, on_log=log,
|
|
)
|
|
|
|
pairs.assert_called_once_with(partition)
|
|
pipeline.assert_not_called()
|
|
configure.assert_not_called()
|
|
log.assert_not_called()
|
|
for method in (lifecycle.loading, lifecycle.resize, lifecycle.ready):
|
|
method.assert_not_called()
|
|
lifecycle.release.assert_called_once_with(reason=f"evaluation_{partition}_complete")
|
|
assert list(tmp_path.iterdir()) == []
|