K-Prism_Benchmark / upload_space.py
luke0709
Fix
d3a5002
Raw History Blame Contribute Delete
1.49 kB
"""Upload this static app to an existing Static Space using the saved HF login."""
import argparse
from pathlib import Path
from huggingface_hub import HfApi
ROOT = Path(__file__).resolve().parent
FILES = [
'.gitignore',
'README.md',
'index.html',
'config.mjs',
'data.mjs',
'leaderboard.mjs',
'benchmark.json',
'tests/test_static_space.py',
'upload_space.py',
]
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--repo-id', default='KETI-NLP/K-Prism_Benchmark')
parser.add_argument('--message', default='Update static benchmark leaderboard')
args = parser.parse_args()
for name in FILES:
if not (ROOT / name).is_file():
parser.error('Missing deployment file: ' + name)
api = HfApi()
space = api.space_info(args.repo_id)
if space.sdk != 'static':
parser.error('Upload target must already be a Static Space: ' + args.repo_id)
# upload_folder writes to the existing repository without create_repo().
# Older hf upload versions send space_sdk="gradio" in that extra request.
commit = api.upload_folder(
repo_id=args.repo_id,
repo_type='space',
folder_path=ROOT,
allow_patterns=FILES,
parent_commit=space.sha,
commit_message=args.message,
)
print('Uploaded:', commit.commit_url)
print('Space: https://huggingface.co/spaces/' + args.repo_id)
if __name__ == '__main__':
main()