Download scripts/publish.py from candypunk/NanoJev-Web: direct link, hf CLI and curl.
- Browser
- Download file 1.55 kB
-
https://huggingface.co/candypunk/NanoJev-Web/resolve/main/scripts/publish.py
- Command line
-
hf download hf://candypunk/NanoJev-Web/scripts/publish.py
-
curl -L -o publish.py https://huggingface.co/candypunk/NanoJev-Web/resolve/main/scripts/publish.py
1.55 kB
| """Prepare an allowlisted Hugging Face upload; no network writes without --publish.""" | |
| import argparse,json,re | |
| from pathlib import Path | |
| from release import ROOT,verify | |
| def main(): | |
| p=argparse.ArgumentParser(description=__doc__) | |
| p.add_argument('--repo-id',help='Your Hugging Face namespace/NanoJev-Web') | |
| p.add_argument('--publish',action='store_true',help='Create a PUBLIC repository and upload the verified files') | |
| p.add_argument('--update-existing',action='store_true',help='Explicitly allow adding/replacing these files in an existing repository') | |
| a=p.parse_args();m=verify();paths=sorted([*m['files'],'MANIFEST.json']) | |
| if a.repo_id and not re.fullmatch(r'[A-Za-z0-9][A-Za-z0-9_.-]*/[A-Za-z0-9][A-Za-z0-9_.-]*',a.repo_id):p.error('Expected namespace/repository') | |
| print(json.dumps({'mode':'publish' if a.publish else 'dry-run','repo_id':a.repo_id,'public':True,'files':len(paths),'bytes':sum((ROOT/x).stat().st_size for x in paths),'local_runtime_and_runs_excluded':True})) | |
| if not a.publish:return | |
| if not a.repo_id:p.error('--repo-id is required for publishing') | |
| from huggingface_hub import HfApi,CommitOperationAdd | |
| api=HfApi();api.create_repo(repo_id=a.repo_id,repo_type='model',private=False,exist_ok=a.update_existing) | |
| commit=api.create_commit(repo_id=a.repo_id,repo_type='model',commit_message='Release NanoJev-Web browser action model',operations=[CommitOperationAdd(path_in_repo=name,path_or_fileobj=str(ROOT/name)) for name in paths]) | |
| print(commit.commit_url) | |
| if __name__=='__main__':main() | |