Download publish_v2.py from Lucasgitguy-co/forma3d-tiny-2: direct link, hf CLI and curl.
- Browser
- Download file 1.53 kB
-
https://huggingface.co/Lucasgitguy-co/forma3d-tiny-2/resolve/main/publish_v2.py
- Command line
-
hf download hf://Lucasgitguy-co/forma3d-tiny-2/publish_v2.py
-
curl -L -o publish_v2.py https://huggingface.co/Lucasgitguy-co/forma3d-tiny-2/resolve/main/publish_v2.py
1.53 kB
| """Explicit optional upload; creates a private repository before making it public.""" | |
| import hashlib | |
| import json | |
| import sys | |
| from pathlib import Path | |
| from huggingface_hub import HfApi | |
| def main(): | |
| root = Path(sys.argv[1]) | |
| report = json.loads((root/'evaluation.json').read_text()) | |
| if not report.get('passed') or not all(report['checks'].values()): | |
| raise ValueError('Evaluation gate failed') | |
| lines = (root/'SHA256SUMS').read_text().splitlines() | |
| expected = {} | |
| for line in lines: | |
| digest, filename = line.split(' ',1) | |
| path = (root/filename).resolve() | |
| if not path.is_relative_to(root.resolve()): | |
| raise ValueError('Invalid checksum path') | |
| expected[filename] = digest | |
| if hashlib.sha256(path.read_bytes()).hexdigest() != digest: | |
| raise ValueError('Changed release file: '+filename) | |
| actual = {str(p.relative_to(root)) for p in root.rglob('*') if p.is_file() and p.name != 'SHA256SUMS'} | |
| if actual != set(expected): | |
| raise ValueError('Unlisted or missing release files') | |
| repo = 'Lucasgitguy-co/forma3d-tiny-2' | |
| api = HfApi() | |
| api.create_repo(repo,repo_type='model',private=True,exist_ok=False) | |
| api.upload_folder(repo_id=repo,repo_type='model',folder_path=str(root), | |
| commit_message='Release evaluated Forma3D Tiny 2 continuation') | |
| api.update_repo_settings(repo_id=repo,repo_type='model',private=False) | |
| print('Published https://huggingface.co/'+repo) | |
| if __name__ == '__main__': | |
| main() | |