Download remove_unmaterialized_lfs_pointers.py from jiangjy0508/so101-e23-3zone-comparison-complete: direct link, hf CLI and curl.
- Browser
- Download file 1.68 kB
-
https://huggingface.co/jiangjy0508/so101-e23-3zone-comparison-complete/resolve/main/remove_unmaterialized_lfs_pointers.py
- Command line
-
hf download hf://jiangjy0508/so101-e23-3zone-comparison-complete/remove_unmaterialized_lfs_pointers.py
-
curl -L -o remove_unmaterialized_lfs_pointers.py https://huggingface.co/jiangjy0508/so101-e23-3zone-comparison-complete/resolve/main/remove_unmaterialized_lfs_pointers.py
1.68 kB
| #!/usr/bin/env python3 | |
| from __future__ import annotations | |
| import re | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parent | |
| ALLOWED_ROOT = ROOT / "source/lerobot/tests/artifacts" | |
| POINTER_PATTERN = re.compile( | |
| rb"^version https://git-lfs\.github\.com/spec/v1\n" | |
| rb"oid sha256:([0-9a-f]{64})\n" | |
| rb"size ([0-9]+)\n?$" | |
| ) | |
| def main() -> None: | |
| pointers = [] | |
| for path in sorted(ROOT.rglob("*")): | |
| if not path.is_file() or path.is_symlink() or path.stat().st_size > 1024: | |
| continue | |
| data = path.read_bytes() | |
| match = POINTER_PATTERN.fullmatch(data) | |
| if match: | |
| pointers.append((path, match.group(1).decode(), int(match.group(2)))) | |
| if not pointers: | |
| print("No unmaterialized Git LFS pointers found.") | |
| return | |
| for path, _, _ in pointers: | |
| if ALLOWED_ROOT not in path.parents: | |
| raise RuntimeError(f"refusing to remove LFS pointer outside test artifacts: {path}") | |
| report = ROOT / "source/LFS_POINTERS_OMITTED.txt" | |
| lines = [ | |
| "Unmaterialized Git LFS test fixtures omitted for Hugging Face upload.", | |
| "They are unrelated to the SO101 training outputs and their pointers remain in the Git bundle history.", | |
| "", | |
| "path\tsha256_oid\tdeclared_size_bytes", | |
| ] | |
| for path, oid, size in pointers: | |
| lines.append(f"{path.relative_to(ROOT)}\t{oid}\t{size}") | |
| report.write_text("\n".join(lines) + "\n") | |
| for path, _, _ in pointers: | |
| path.unlink() | |
| print(f"Removed {len(pointers)} unmaterialized Git LFS test-fixture pointers.") | |
| print(f"Recorded omissions in {report}") | |
| if __name__ == "__main__": | |
| main() | |