#!/usr/bin/env python3 """ Upload existing leaderboard.json to HuggingFace dataset. Usage: export HF_TOKEN=your_token python upload_leaderboard.py """ import json from pathlib import Path from leaderboard import LEADERBOARD_DATASET_ID, save_leaderboard, create_leaderboard_dataset def main(): # Load local leaderboard local_path = Path("benchmark_data/leaderboard.json") if not local_path.exists(): print(f"Error: {local_path} not found") return 1 print(f"Loading leaderboard from {local_path}...") with open(local_path, "r", encoding="utf-8") as f: leaderboard = json.load(f) print(f"Found {len(leaderboard)} entries") # Ensure dataset exists print(f"\nEnsuring dataset exists: {LEADERBOARD_DATASET_ID}") create_leaderboard_dataset() # Upload all entries print(f"\nUploading {len(leaderboard)} entries to {LEADERBOARD_DATASET_ID}...") success = save_leaderboard(leaderboard) if success: print(f"\n✅ Successfully uploaded leaderboard!") print(f" View at: https://huggingface.co/datasets/{LEADERBOARD_DATASET_ID}") return 0 else: print("\n❌ Failed to upload. Check HF_TOKEN and permissions.") return 1 if __name__ == "__main__": exit(main())