"""Verify the exact public Gemma adapter/head releases without re-downloading weights.""" import hashlib import json from pathlib import Path from huggingface_hub import HfApi ROOT=Path(__file__).resolve().parent def main(): api=HfApi(token=False) for task in ['open-emotions','open-morals','open-sensations']: out=ROOT/'outputs/gemma'/task;stage=out/'publish' info=api.model_info(f'mts-the-architect/{task}-gemma4-e2b-bf16-lora',files_metadata=True) assert not info.private files={f.rfilename:f for f in info.siblings} expected={p.name for p in stage.iterdir() if p.is_file()} assert expected<=set(files),expected-set(files) assert not any(name.endswith(('.sqlite3','.db')) or 'api-private' in name for name in files) verified={} for name in sorted(expected): raw=(stage/name).read_bytes();remote=files[name] if remote.lfs: digest=hashlib.sha256(raw).hexdigest() assert remote.lfs.sha256==digest,name verified[name]=dict(method='Hub LFS SHA256',sha256=digest) else: digest=hashlib.sha1(b'blob '+str(len(raw)).encode()+b'\0'+raw).hexdigest() assert remote.blob_id==digest,name verified[name]=dict(method='Git blob SHA1',blob_sha1=digest) assert {'adapter_model.safetensors','classifier_head.safetensors','synthetic-candidate.zip', 'real-only-control.zip','human-baseline.zip'}<=verified.keys() report=dict(repository=info.id,public=True,commit=info.sha,verified_files=verified, all_release_bytes_verified=True,adapter_head_and_continuation_archives_verified=True) (out/'publication_verification.json').write_text(json.dumps(report,indent=2)+'\n') print(task,'verified',len(verified),'files at',info.sha,flush=True) if __name__=='__main__':main()