"""Verify downloaded bytes, split counts, label mapping and exact cache layout.""" import argparse,hashlib,json from collections import Counter from pathlib import Path import pyarrow.parquet as pq from release_reader import load_processed,read_frames,resolve def sha(path): h=hashlib.sha256() with path.open('rb') as f: for b in iter(lambda:f.read(1024*1024),b''):h.update(b) return h.hexdigest() def main(root): files=0 listed=set() for line in (root/'checksums.sha256').read_text().splitlines(): digest,relative=line.split(' ',1) assert relative not in listed,relative listed.add(relative) assert sha(resolve(root,relative))==digest,relative files+=1 actual={str(p.relative_to(root)) for p in root.rglob('*') if p.is_file()} # HF download metadata and Python bytecode are local runtime artifacts. actual={p for p in actual if not p.startswith('.cache/') and '__pycache__' not in Path(p).parts} assert actual==listed|{'checksums.sha256'},'Unexpected or missing package files' expected={'train':4800,'test_ind':1200,'test_ood':400} video_splits={} for split,count in expected.items(): rows=load_processed(root,split);assert len(rows)==count byid={r['id']:r for r in rows};assert len(byid)==count for row in rows: frames=read_frames(root,row) assert frames.shape==(32,224,224,3) and str(frames.dtype)=='uint8' assert len(row['target_progress'])==32 total=0;seen=set();classes=Counter() for p in sorted((root/'data'/split).glob('*.parquet')): for batch in pq.ParquetFile(p).iter_batches(batch_size=8): for row in batch.to_pylist(): assert row['split']==split assert row['id'] not in seen seen.add(row['id']) digest=hashlib.sha256(row['video']['bytes']).hexdigest() assert digest==row['video_sha256']==sha(resolve(root,row['repro_video'])) assert video_splits.setdefault(digest,split)==split,'Cross-split duplicate video' assert row['processed_target_progress']==byid[row['id']]['target_progress'] assert row['lang_vector']==byid[row['id']]['lang_vector'] assert len(row['target_progress'])==len(row['progress_frame_indices']) assert row['progress_frame_indices']==list(range(row['video_frame_offset'],row['video_num_frames'])) classes[(row['task_id'],row['quality_label'])]+=1 total+=1 assert total==count assert seen==set(byid) assert len(classes)==(8 if split=='test_ood' else 24) assert set(classes.values())=={200 if split=='train' else 50} print(json.dumps({'status':'passed','files':files,'items':sum(expected.values())})) if __name__=='__main__': p=argparse.ArgumentParser();p.add_argument('--root',type=Path,required=True);a=p.parse_args();main(a.root.resolve())