Spaces:
Running
Running
File size: 1,957 Bytes
0380c4f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
#!/usr/bin/env python3
"""
Setup script to ensure all necessary files and directories are created
before running the application.
"""
import os
import json
import sys
def setup():
"""Create necessary directories and files if they don't exist."""
print("Setting up leaderboard application...")
# Create submissions directory
if not os.path.exists("submissions"):
print("Creating submissions directory...")
os.makedirs("submissions", exist_ok=True)
# Create models.json if it doesn't exist or is empty
if not os.path.exists("models.json") or os.path.getsize("models.json") == 0:
print("Creating models.json configuration file...")
config = {
"title": "TRAIL Performance Leaderboard",
"description": "This leaderboard tracks and compares model performance across multiple metrics. Submit your model results to see how they stack up!",
"metrics": ["Cat. F1", "Loc. Acc", "Joint F1"],
"main_metric": "Cat. F1"
}
with open("models.json", "w") as f:
json.dump(config, f, indent=2)
else:
# Validate JSON format
try:
with open("models.json", "r") as f:
json.load(f)
print("models.json exists and is valid.")
except json.JSONDecodeError:
print("models.json exists but has invalid JSON. Creating new file...")
config = {
"title": "Model Performance Leaderboard",
"description": "This leaderboard tracks and compares model performance across multiple metrics. Submit your model results to see how they stack up!",
"metrics": ["Cat. F1", "Loc. Acc", "Joint F1"],
"main_metric": "Cat. F1"
}
with open("models.json", "w") as f:
json.dump(config, f, indent=2)
print("Setup complete.")
if __name__ == "__main__":
setup() |