mini-unet-colorizer / upload_main.py
User-2468's picture
Update validated colorizer weights, spatial decoder and deployment artifacts
704fa80 verified
Raw History Blame
1.26 kB
"""Upload a prepared release folder atomically to main, preserving stable."""
import argparse
from pathlib import Path
from huggingface_hub import HfApi
from model import load_model
def main():
p=argparse.ArgumentParser(__doc__)
p.add_argument('--folder',default='release')
p.add_argument('--repo',default='User-2468/mini-unet-colorizer')
p.add_argument('--expected-main',default=None,help='Optional optimistic-concurrency commit SHA')
a=p.parse_args()
folder=Path(a.folder)
model=load_model(folder)
assert sum(p.numel() for p in model.parameters())<4_000_000
api=HfApi()
refs={x.name:x.target_commit for x in api.list_repo_refs(a.repo).branches}
stable=refs.get('stable')
result=api.upload_folder(repo_id=a.repo,revision='main',folder_path=folder,
parent_commit=a.expected_main or refs['main'],
commit_message='Update validated colorizer weights, spatial decoder and deployment artifacts',
ignore_patterns=['__pycache__/**','*.pyc'])
after={x.name:x.target_commit for x in api.list_repo_refs(a.repo).branches}
if stable!=after.get('stable'):raise RuntimeError('Stable changed concurrently; inspect repository history')
print(result.commit_url)
if __name__=='__main__':main()