vla / workspace /tests /test_external_checkpoint_verify.py
anhtld's picture
auto-sync 2026-07-02T13:37:00Z workspace (part 33)
da08b7d verified
Raw
History Blame Contribute Delete
1.82 kB
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()