"""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', 'front/config.mjs', 'front/data.mjs', 'front/leaderboard.mjs', 'front/data/benchmark.json', 'tests/test_static_space.py', 'upload_space.py', ] def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--repo-id', default='DoolyKim22/Benchmark_Leaderboard') 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()