#!/usr/bin/env bash # SUM Parts - check the downloaded archives survived # # The WSL VM has now died twice under load, and the first time it left pip's # in-flight files as 0-byte stubs. A download interrupted the same way leaves a # truncated zip, so verify before trusting anything that was in flight. set -euo pipefail source "$HOME/miniconda3/etc/profile.d/conda.sh" conda activate sumparts python - <<'PY' import zipfile from pathlib import Path d = Path.home() / "sum-parts/data/_archives" expected = {"demo.zip": 0.12, "mesh.zip": 0.52, "pcl.zip": 4.66} # GB, from the HF listing if not d.exists(): print(f"{d} missing") raise SystemExit(1) bad = [] for f in sorted(d.glob("*.zip")): gb = f.stat().st_size / 1e9 want = expected.get(f.name) line = f"{f.name:<12} {gb:>6.2f} GB" if want: line += f" (expected ~{want:.2f} GB)" if gb < want * 0.97: line += " TRUNCATED" bad.append(f.name) print(line) continue try: z = zipfile.ZipFile(f) broken = z.testzip() if broken: line += f" CORRUPT at {broken}" bad.append(f.name) else: line += f" OK, {len(z.namelist())} entries" except Exception as e: line += f" UNREADABLE {type(e).__name__}: {e}" bad.append(f.name) print(line) for name in expected: if not (d / name).exists(): print(f"{name:<12} MISSING") print() print("all good" if not bad else f"re-download: {', '.join(bad)}") raise SystemExit(1 if bad else 0) PY