"""Verify a downloaded copy of this dataset is complete and internally consistent. uv run python scripts/verify_download.py [DATASET_ROOT] Written for the case where `huggingface-cli download` died partway -- e.g. on an HTTP 429 rate limit. A partial download leaves a tree that looks plausible: lerobot will happily open it and train on whatever episodes happen to be present. This checks counts and cross-references before you spend GPU hours. Needs only stdlib + pandas/pyarrow (pandas only for the --deep row-count pass). """ import argparse import glob import json import os import pathlib import sys def main() -> int: ap = argparse.ArgumentParser() ap.add_argument("root", nargs="?", default=str(pathlib.Path(__file__).resolve().parent.parent)) ap.add_argument("--deep", action="store_true", help="also open every parquet and check row counts against episodes.jsonl") a = ap.parse_args() root = pathlib.Path(a.root) fail = [] for rel in ("meta/info.json", "meta/episodes.jsonl", "meta/episodes_stats.jsonl", "meta/tasks.jsonl"): if not (root / rel).exists(): fail.append(f"missing {rel}") if fail: for f in fail: print("FAIL", f) return 1 info = json.load(open(root / "meta/info.json")) eps = {json.loads(l)["episode_index"]: json.loads(l) for l in open(root / "meta/episodes.jsonl")} stats = [json.loads(l)["episode_index"] for l in open(root / "meta/episodes_stats.jsonl")] cams = sorted(k.split("observation.images.")[1] for k in info["features"] if info["features"][k]["dtype"] == "video") parquets = sorted(glob.glob(str(root / "data/chunk-000/episode_*.parquet"))) videos = glob.glob(str(root / "videos/chunk-000/*/*.mp4")) incomplete = glob.glob(str(root / ".cache/huggingface/download/**/*.incomplete"), recursive=True) exp_e, exp_f, exp_v = info["total_episodes"], info["total_frames"], info["total_videos"] print(f"root {root}") print(f"cameras {cams}") print(f"episodes info={exp_e} parquet={len(parquets)} episodes.jsonl={len(eps)} stats={len(stats)}") print(f"videos info={exp_v} on disk={len(videos)}") print(f"frames info={exp_f} episodes.jsonl sum={sum(e['length'] for e in eps.values())}") print(f"in-flight {len(incomplete)} .incomplete file(s)") if len(parquets) != exp_e: fail.append(f"{len(parquets)} parquet files but info.total_episodes={exp_e}") if len(eps) != exp_e: fail.append(f"episodes.jsonl has {len(eps)} rows but info.total_episodes={exp_e}") if sorted(eps) != list(range(exp_e)): fail.append("episodes.jsonl indices are not contiguous 0..N-1") if stats != list(range(exp_e)): fail.append("episodes_stats.jsonl is not aligned 0..N-1") if len(videos) != exp_v: fail.append(f"{len(videos)} mp4 files but info.total_videos={exp_v}") if sum(e["length"] for e in eps.values()) != exp_f: fail.append("episodes.jsonl lengths do not sum to info.total_frames") if incomplete: fail.append(f"{len(incomplete)} .incomplete file(s) -- the download did not finish") # every episode must have every camera, and a plausible file size missing, tiny = [], [] for ei in range(exp_e): if not (root / f"data/chunk-000/episode_{ei:06d}.parquet").exists(): missing.append(f"parquet ep{ei}") for c in cams: p = root / f"videos/chunk-000/observation.images.{c}/episode_{ei:06d}.mp4" if not p.exists(): missing.append(f"{c} ep{ei}") elif p.stat().st_size < 4096: tiny.append(f"{c} ep{ei} ({p.stat().st_size} B)") if missing: fail.append(f"{len(missing)} missing file(s), first 10: {missing[:10]}") if tiny: fail.append(f"{len(tiny)} suspiciously small video(s): {tiny[:10]}") if a.deep: import pandas as pd bad = [] for ei in range(exp_e): n = len(pd.read_parquet(root / f"data/chunk-000/episode_{ei:06d}.parquet", columns=["frame_index"])) if n != eps[ei]["length"]: bad.append((ei, eps[ei]["length"], n)) print(f"deep {exp_e} parquets opened, {len(bad)} row-count mismatch(es)") if bad: fail.append(f"row-count mismatches, first 10: {bad[:10]}") print() if fail: for f in fail: print("FAIL", f) print("\nIncomplete or inconsistent. Re-run the download -- it resumes:") print(" export HF_HUB_DISABLE_XET=1") print(" uv run huggingface-cli download $REPO_ID --repo-type dataset \\") print(" --local-dir $HF_LEROBOT_HOME/$REPO_ID --max-workers 4") return 1 print("PASS -- download is complete and self-consistent.") return 0 if __name__ == "__main__": sys.exit(main())