File size: 1,818 Bytes
20c251e | 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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | from __future__ import annotations
import subprocess
import sys
from pathlib import Path
from scripts.verify_external_checkpoint import build_manifest
def test_external_checkpoint_manifest_ready_when_required_files_exist(tmp_path: Path) -> None:
checkpoint = tmp_path / "checkpoint"
checkpoint.mkdir()
(checkpoint / "config.json").write_text("{}", encoding="utf-8")
(checkpoint / "model.safetensors").write_bytes(b"weights")
manifest = build_manifest(
checkpoint,
model_family="smolvla",
repo_id="lerobot/smolvla_base",
revision="abc",
required_files=["config.json", "model.safetensors"],
)
assert manifest["ready"] is True
assert manifest["missing_required_files"] == []
assert manifest["file_count"] == 2
assert manifest["total_bytes"] == len("{}") + len(b"weights")
model_row = next(row for row in manifest["files"] if row["path"] == "model.safetensors")
assert len(model_row["sha256"]) == 64
def test_external_checkpoint_cli_reports_missing_required_files(tmp_path: Path) -> None:
checkpoint = tmp_path / "checkpoint"
checkpoint.mkdir()
(checkpoint / "config.json").write_text("{}", encoding="utf-8")
out = tmp_path / "manifest.json"
result = subprocess.run(
[
sys.executable,
"scripts/verify_external_checkpoint.py",
"--checkpoint",
str(checkpoint),
"--out",
str(out),
"--model-family",
"smolvla",
"--required-file",
"config.json",
"--required-file",
"model.safetensors",
],
capture_output=True,
text=True,
)
assert result.returncode == 2
assert "model.safetensors" in result.stdout
assert out.exists()
|