beam-boot / scripts /publish_source.py
StarAtNyte1's picture
Publish Beam Boot / Super Beam source
2b0538e verified
Raw History Blame Contribute Delete
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']
@app.function(image=modal.Image.debian_slim(python_version='3.12'),
secrets=[modal.Secret.from_name('steerability-submission-write')])
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
@app.local_entrypoint()
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)