File size: 1,210 Bytes
f440f03 | 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 36 | """Tests distillation preparation helpers."""
from __future__ import annotations
import json
from pathlib import Path
from maris_core.training.distill import distill
def test_distill_writes_plan_and_readme(tmp_path: Path) -> None:
teacher_dir = tmp_path / "teacher"
student_dir = tmp_path / "student"
teacher_dir.mkdir()
student_dir.mkdir()
(teacher_dir / "config.json").write_text("{}", encoding="utf-8")
output_dir = tmp_path / "distilled"
distill(str(teacher_dir), str(student_dir), str(output_dir))
manifest = json.loads((output_dir / "distillation-plan.json").read_text(encoding="utf-8"))
assert manifest["status"] == "prepared"
assert manifest["teacher"]["is_local_path"] is True
assert manifest["teacher"]["config_exists"] is True
assert manifest["student"]["config_exists"] is False
assert (output_dir / "README.md").is_file()
def test_distill_rejects_empty_teacher_model(tmp_path: Path) -> None:
try:
distill(" ", "student", str(tmp_path / "distilled"))
except ValueError as exc:
assert "teacher_model" in str(exc)
else:
raise AssertionError("distill() should reject an empty teacher model reference")
|