Download scripts/publish_source.py from StarAtNyte1/beam-boot: direct link, hf CLI and curl.
- Browser
- Download file 1.82 kB
-
https://huggingface.co/StarAtNyte1/beam-boot/resolve/main/scripts/publish_source.py
- Command line
-
hf download hf://StarAtNyte1/beam-boot/scripts/publish_source.py
-
curl -L -o publish_source.py https://huggingface.co/StarAtNyte1/beam-boot/resolve/main/scripts/publish_source.py
1.82 kB
| """Publish the full Beam Boot / Super Beam source as a public Hugging Face model repo. | |
| Uploads code only: beamboot/, tests/, scripts/, roms/, examples/, envs/, README.md, pyproject.toml, | |
| SUBMISSION.md. Virtual environments, checkpoints (artifacts/), results/ and outputs/ are not uploaded. | |
| The HF write token comes from the Modal secret and is held in memory only; it is never printed. | |
| .venv/bin/modal run scripts/publish_source.py | |
| """ | |
| import os | |
| from pathlib import Path | |
| import modal | |
| app = modal.App('beamboot-publish-source') | |
| ROOT = Path(__file__).resolve().parent.parent | |
| INCLUDE = ['beamboot', 'tests', 'scripts', 'roms', 'examples', 'envs', | |
| 'README.md', 'pyproject.toml', 'SUBMISSION.md', 'figures'] | |
| def get_write_token(): | |
| token = os.environ.get('HUGGINGFACE_TOKEN') or os.environ.get('HF_TOKEN') | |
| if not token: | |
| raise RuntimeError('No HF write token in configured secret') | |
| return token | |
| def main(): | |
| from huggingface_hub import HfApi | |
| api = HfApi(token=get_write_token.remote()) | |
| repo_id = api.whoami()['name'] + '/beam-boot' | |
| api.create_repo(repo_id=repo_id, repo_type='model', private=False, exist_ok=True) | |
| allow = [] | |
| for item in INCLUDE: | |
| allow.append(item + '/**' if (ROOT / item).is_dir() else item) | |
| api.upload_folder(repo_id=repo_id, repo_type='model', folder_path=str(ROOT), | |
| allow_patterns=allow, | |
| ignore_patterns=['**/__pycache__/**', '**/*.pyc', '**/.pytest_cache/**'], | |
| commit_message='Publish Beam Boot / Super Beam source') | |
| print('Public source: https://huggingface.co/' + repo_id, flush=True) | |