"""Explicit, user-run upload of the verified release allowlist only.""" import argparse, json, tempfile, shutil from pathlib import Path from verify_release import verify ROOT=Path(__file__).resolve().parent def main(): parser=argparse.ArgumentParser();parser.add_argument('repo_id',help='Your HF namespace/repository');parser.add_argument('--public',action='store_true',help='Create a public repository; default is private');parser.add_argument('--dry-run',action='store_true');args=parser.parse_args() if len(args.repo_id.split('/'))!=2 or any(not p or p in ('.','..') for p in args.repo_id.split('/')):parser.error('Expected namespace/repository') manifest=verify();files=sorted([*manifest,'SHA256SUMS.json']) if args.dry_run: print(json.dumps(dict(repo_id=args.repo_id,private=not args.public,files=len(files),bytes=sum((ROOT/p).stat().st_size for p in files),upload_performed=False),indent=2));return from huggingface_hub import HfApi api=HfApi() # Reads an existing hf auth login or HF_TOKEN; never prints tokens. try: info=api.model_info(args.repo_id) except Exception as error: from huggingface_hub.errors import RepositoryNotFoundError if not isinstance(error,RepositoryNotFoundError):raise info=None if info is not None and not info.private and not args.public: raise SystemExit('Existing repository is public. Use --public explicitly or choose a private repository.') api.create_repo(repo_id=args.repo_id,repo_type='model',private=not args.public,exist_ok=True) # Ignore any newly generated API keys, hook state, .venv or caches beside the release. with tempfile.TemporaryDirectory(prefix='laya-hf-upload-') as temporary: staging=Path(temporary) for name in files: target=staging/name;target.parent.mkdir(parents=True,exist_ok=True);shutil.copy2(ROOT/name,target) result=api.upload_folder(repo_id=args.repo_id,repo_type='model',folder_path=str(staging),commit_message='Laya DevOps v29 early stage preview: weights, method, paired audit and integration') print('Uploaded verified release:',result.commit_url) if __name__=='__main__':main()