"""Verify the local Qwen-Image-2.1-Turbo snapshot against upstream sizes and LFS SHA-256 (assets excluded).""" import hashlib, json, time from huggingface_hub import HfApi from common import BASE, BASE_REPO, BASE_REVISION, ROOT info = HfApi().model_info(BASE_REPO, revision=BASE_REVISION, files_metadata=True) rows = [] for f in info.siblings: if f.rfilename.startswith('assets/'): continue p = BASE / f.rfilename assert p.exists(), f.rfilename h = hashlib.sha256() with p.open('rb') as s: while b := s.read(8 << 20): h.update(b) digest = h.hexdigest() if f.size is not None: assert p.stat().st_size == f.size, f.rfilename if f.lfs: assert digest == f.lfs.sha256, (f.rfilename, digest) rows.append({'file': f.rfilename, 'bytes': p.stat().st_size, 'sha256': digest, 'upstream_lfs_sha256_matched': bool(f.lfs)}) receipt = {'model': info.id, 'revision': info.sha, 'files': rows, 'total_bytes': sum(r['bytes'] for r in rows), 'excluded': 'assets/* preview images (not needed for inference)', 'verified_at': time.time()} (ROOT / 'base_integrity.json').write_text(json.dumps(receipt, indent=2)) print('BASE_VERIFIED', len(rows), receipt['total_bytes'])