lmgame_bench / generate_normalized_cache.py
Yuxuan-Zhang-Dexter
update leaderboard with new agentic leaderboard layout
6d4c755
#!/usr/bin/env python3
"""
Script to generate normalized data cache for faster visualization loading.
Usage:
python generate_normalized_cache.py [input_file] [output_file]
Example:
python generate_normalized_cache.py data/rank_data.json normalized_data.json
"""
import sys
import json
from data_visualization import generate_and_save_normalized_data, load_normalized_data
def main():
# Default files
input_file = "data/rank_data.json" # Update this path as needed
output_file = "normalized_data.json"
# Handle command line arguments
if len(sys.argv) > 1:
input_file = sys.argv[1]
if len(sys.argv) > 2:
output_file = sys.argv[2]
try:
# Load rank data
print(f"Loading rank data from {input_file}...")
with open(input_file, 'r') as f:
rank_data = json.load(f)
# Generate and save normalized data
print("Generating normalized data...")
saved_path = generate_and_save_normalized_data(rank_data, output_file)
# Verify the saved data
print("Verifying saved data...")
cached_data = load_normalized_data(output_file)
if cached_data:
print(f"โœ… Successfully generated normalized data cache!")
print(f"๐Ÿ“ Saved to: {saved_path}")
print(f"๐ŸŽฎ Games included: {list(cached_data['games'].keys())}")
print(f"๐Ÿ‘ฅ Players included: {len(cached_data['players'])}")
print(f"๐Ÿ“… Generated at: {cached_data['timestamp']}")
else:
print("โŒ Failed to verify cached data")
except FileNotFoundError:
print(f"โŒ Error: Could not find input file '{input_file}'")
print("Please check the file path and try again.")
except Exception as e:
print(f"โŒ Error: {str(e)}")
if __name__ == "__main__":
main()