maxwellinked commited on
Commit
ea41c38
·
1 Parent(s): f05992e

Add verified single-record download guidance (#24)

Browse files

- Add verified single-record download guidance (d584b1ba880bd92dfc4390256f76eddd9a3c6fb9)
- Normalize README line endings (09b176b394038b828b4ab62108ad748d1bc8508c)

Files changed (3) hide show
  1. LICENSE +20 -0
  2. README.md +35 -0
  3. tools/download_verified.py +155 -0
LICENSE ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Time-Lapse Artifacts
2
+ Copyright (c) 2026 Tim Maxwell
3
+
4
+ Except where otherwise noted, this dataset is licensed under the Creative
5
+ Commons Attribution-NonCommercial 4.0 International license (CC BY-NC 4.0):
6
+
7
+ https://creativecommons.org/licenses/by-nc/4.0/
8
+
9
+ Legal code:
10
+
11
+ https://creativecommons.org/licenses/by-nc/4.0/legalcode
12
+
13
+ The license applies only to material for which the licensor holds the
14
+ necessary rights. It does not independently grant rights in incidental
15
+ third-party content that may appear on screens, in references, or in captured
16
+ audio. Users remain responsible for reviewing those rights and the terms of
17
+ their downstream use.
18
+
19
+ See README.md for the dataset's rights, privacy, audio, and attribution
20
+ guidance.
README.md CHANGED
@@ -609,6 +609,37 @@ intentional.
609
 
610
  Use `"pre_standard"` as the configuration name to stream the earlier tier.
611
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
612
  For reproducible work:
613
 
614
  1. Pin a repository commit or release tag.
@@ -651,10 +682,14 @@ See `CHANGELOG.md` for release-level changes.
651
 
652
  - `metadata.csv` — canonical machine-readable index
653
  - `Pre_Standard_Time_Lapses/metadata.csv` — active pre-standard public index
 
654
  - `SCHEMA.md` — filename and metadata contracts
655
  - `Archive_Specifications.md` — acquisition specifications and known gaps
656
  - `VALIDATION.md` — validation scope and current results
 
 
657
  - `tools/capture_hub_inventory.py` — pinned Hub/Xet identity inventory
 
658
  - `tools/enrich_prestandard.py` — pinned Pre-Standard technical enrichment
659
  - `tools/validate_metadata.py` — cross-tier metadata and repository checks
660
  - `Standard_Time_Lapses/Provenance/` — historical evidence and mappings
 
609
 
610
  Use `"pre_standard"` as the configuration name to stream the earlier tier.
611
 
612
+ ### Download and Verify One Record
613
+
614
+ Install `huggingface_hub`, then use the included helper with a stable
615
+ `record_id`:
616
+
617
+ ```bash
618
+ python -m pip install huggingface_hub
619
+ ```
620
+
621
+ The helper resolves the requested revision to an immutable commit, checks the
622
+ indexed byte size and Xet identity against the pinned Hub headers, and reports
623
+ the ordinary LFS-compatible SHA-256 separately.
624
+
625
+ Check a record without downloading its video:
626
+
627
+ ```bash
628
+ python tools/download_verified.py tla-a66bdad6c903b89f --check-only
629
+ ```
630
+
631
+ Download that record and verify its local byte size and SHA-256:
632
+
633
+ ```bash
634
+ python tools/download_verified.py tla-a66bdad6c903b89f \
635
+ --revision "<commit-or-tag>" \
636
+ --output-dir downloads
637
+ ```
638
+
639
+ `hub_xet_hash` is an Xet file ID, not the SHA-256 of the downloaded bytes. The
640
+ helper verifies both identities without conflating them. Video downloads may
641
+ be many gigabytes; use `--check-only` first.
642
+
643
  For reproducible work:
644
 
645
  1. Pin a repository commit or release tag.
 
682
 
683
  - `metadata.csv` — canonical machine-readable index
684
  - `Pre_Standard_Time_Lapses/metadata.csv` — active pre-standard public index
685
+ - `LICENSE` — CC BY-NC 4.0 notice and rights-scope qualification
686
  - `SCHEMA.md` — filename and metadata contracts
687
  - `Archive_Specifications.md` — acquisition specifications and known gaps
688
  - `VALIDATION.md` — validation scope and current results
689
+ - `RELEASE_MANIFEST.json` — historical v0.2.0 release-candidate manifest; it
690
+ does not describe current `main` or provide checksums for the video payloads
691
  - `tools/capture_hub_inventory.py` — pinned Hub/Xet identity inventory
692
+ - `tools/download_verified.py` — selected download and byte-integrity check
693
  - `tools/enrich_prestandard.py` — pinned Pre-Standard technical enrichment
694
  - `tools/validate_metadata.py` — cross-tier metadata and repository checks
695
  - `Standard_Time_Lapses/Provenance/` — historical evidence and mappings
tools/download_verified.py ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Download one indexed video from a pinned Hub revision and verify its bytes.
3
+
4
+ The script resolves a branch or tag to an immutable commit, checks the selected
5
+ metadata row against the Hub's resolve headers, and optionally downloads the
6
+ video. After download it verifies both the exact byte size and the ordinary
7
+ LFS-compatible SHA-256. The Xet file ID is checked separately because it is not
8
+ the SHA-256 of the downloaded file.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ import argparse
14
+ import csv
15
+ import hashlib
16
+ from pathlib import Path
17
+ from urllib.parse import quote
18
+
19
+ from huggingface_hub import HfApi, hf_hub_download
20
+
21
+ from capture_hub_inventory import read_identity
22
+
23
+
24
+ DEFAULT_REPO_ID = "maxwellinked/time-lapse-artifacts"
25
+ INDEX_PATHS = (
26
+ "metadata.csv",
27
+ "Pre_Standard_Time_Lapses/metadata.csv",
28
+ )
29
+
30
+
31
+ def load_record(repo_id: str, revision: str, record_id: str) -> dict[str, str]:
32
+ matches: list[dict[str, str]] = []
33
+ for index_path in INDEX_PATHS:
34
+ local_path = hf_hub_download(
35
+ repo_id=repo_id,
36
+ filename=index_path,
37
+ repo_type="dataset",
38
+ revision=revision,
39
+ )
40
+ with Path(local_path).open(encoding="utf-8", newline="") as handle:
41
+ for row in csv.DictReader(handle):
42
+ if row.get("record_id") == record_id:
43
+ matches.append(row)
44
+
45
+ if not matches:
46
+ raise SystemExit(f"record_id not found: {record_id}")
47
+ if len(matches) != 1:
48
+ raise SystemExit(f"record_id is not unique across active indexes: {record_id}")
49
+ return matches[0]
50
+
51
+
52
+ def sha256_file(path: Path) -> str:
53
+ digest = hashlib.sha256()
54
+ with path.open("rb") as handle:
55
+ for block in iter(lambda: handle.read(8 * 1024 * 1024), b""):
56
+ digest.update(block)
57
+ return digest.hexdigest()
58
+
59
+
60
+ def main() -> None:
61
+ parser = argparse.ArgumentParser(
62
+ description="Download one indexed video and verify its pinned Hub identity."
63
+ )
64
+ parser.add_argument("record_id", help="Stable tla- record ID to download")
65
+ parser.add_argument(
66
+ "--repo-id",
67
+ default=DEFAULT_REPO_ID,
68
+ help=f"Dataset repository (default: {DEFAULT_REPO_ID})",
69
+ )
70
+ parser.add_argument(
71
+ "--revision",
72
+ default="main",
73
+ help="Branch, tag, or commit to resolve and pin (default: main)",
74
+ )
75
+ parser.add_argument(
76
+ "--output-dir",
77
+ type=Path,
78
+ default=Path("downloads"),
79
+ help="Local download directory (default: downloads)",
80
+ )
81
+ parser.add_argument(
82
+ "--check-only",
83
+ action="store_true",
84
+ help="Verify metadata and Hub headers without downloading the video",
85
+ )
86
+ parser.add_argument("--timeout", type=int, default=30)
87
+ parser.add_argument("--retries", type=int, default=2)
88
+ args = parser.parse_args()
89
+
90
+ commit = HfApi().dataset_info(args.repo_id, revision=args.revision).sha
91
+ if not commit:
92
+ raise SystemExit(f"unable to resolve revision: {args.revision}")
93
+
94
+ row = load_record(args.repo_id, commit, args.record_id)
95
+ file_name = row.get("file_name", "")
96
+ expected_xet = row.get("hub_xet_hash", "").lower()
97
+ try:
98
+ expected_size = int(row.get("size_bytes", ""))
99
+ except ValueError as exc:
100
+ raise SystemExit(f"invalid size_bytes for {args.record_id}") from exc
101
+ if not file_name or not expected_xet:
102
+ raise SystemExit(f"incomplete identity metadata for {args.record_id}")
103
+
104
+ encoded_path = quote(file_name, safe="/")
105
+ resolve_url = (
106
+ f"https://huggingface.co/datasets/{args.repo_id}/"
107
+ f"resolve/{commit}/{encoded_path}"
108
+ )
109
+ identity = read_identity(resolve_url, args.timeout, args.retries)
110
+
111
+ if identity["repoCommit"] != commit:
112
+ raise SystemExit("resolve response came from a different repository revision")
113
+ if identity["xetHash"] != expected_xet:
114
+ raise SystemExit("Hub Xet identity differs from the indexed hub_xet_hash")
115
+ if identity["linkedSize"] != expected_size:
116
+ raise SystemExit("Hub byte size differs from the indexed size_bytes")
117
+
118
+ print(f"record_id: {args.record_id}")
119
+ print(f"revision: {commit}")
120
+ print(f"file: {file_name}")
121
+ print(f"size_bytes: {expected_size}")
122
+ print(f"hub_xet_hash: {expected_xet}")
123
+ print(f"sha256: {identity['linkedEtag']}")
124
+
125
+ if args.check_only:
126
+ print("verified metadata against pinned Hub headers; video not downloaded")
127
+ return
128
+
129
+ downloaded = Path(
130
+ hf_hub_download(
131
+ repo_id=args.repo_id,
132
+ filename=file_name,
133
+ repo_type="dataset",
134
+ revision=commit,
135
+ local_dir=args.output_dir,
136
+ )
137
+ )
138
+ actual_size = downloaded.stat().st_size
139
+ if actual_size != expected_size:
140
+ raise SystemExit(
141
+ f"downloaded size mismatch: expected {expected_size}, got {actual_size}"
142
+ )
143
+
144
+ actual_sha256 = sha256_file(downloaded)
145
+ if actual_sha256 != identity["linkedEtag"]:
146
+ raise SystemExit(
147
+ "downloaded SHA-256 differs from the pinned Hub LFS-compatible identity"
148
+ )
149
+
150
+ print(f"downloaded_to: {downloaded.resolve()}")
151
+ print("verified downloaded byte size and SHA-256")
152
+
153
+
154
+ if __name__ == "__main__":
155
+ main()