Spaces:
Sleeping
Sleeping
Jitin Krishnan commited on
Commit ·
cb6f8b4
1
Parent(s): dc70710
Update space
Browse files
setup.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Setup script to ensure all necessary files and directories are created
|
| 4 |
+
before running the application.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
import os
|
| 8 |
+
import json
|
| 9 |
+
import sys
|
| 10 |
+
|
| 11 |
+
def setup():
|
| 12 |
+
"""Create necessary directories and files if they don't exist."""
|
| 13 |
+
print("Setting up leaderboard application...")
|
| 14 |
+
|
| 15 |
+
# Create submissions directory
|
| 16 |
+
if not os.path.exists("submissions"):
|
| 17 |
+
print("Creating submissions directory...")
|
| 18 |
+
os.makedirs("submissions", exist_ok=True)
|
| 19 |
+
|
| 20 |
+
# Create models.json if it doesn't exist or is empty
|
| 21 |
+
if not os.path.exists("models.json") or os.path.getsize("models.json") == 0:
|
| 22 |
+
print("Creating models.json configuration file...")
|
| 23 |
+
config = {
|
| 24 |
+
"title": "Model Performance Leaderboard",
|
| 25 |
+
"description": "This leaderboard tracks and compares model performance across multiple metrics. Submit your model results to see how they stack up!",
|
| 26 |
+
"metrics": ["accuracy", "f1_score", "precision", "recall"],
|
| 27 |
+
"main_metric": "accuracy"
|
| 28 |
+
}
|
| 29 |
+
with open("models.json", "w") as f:
|
| 30 |
+
json.dump(config, f, indent=2)
|
| 31 |
+
else:
|
| 32 |
+
# Validate JSON format
|
| 33 |
+
try:
|
| 34 |
+
with open("models.json", "r") as f:
|
| 35 |
+
json.load(f)
|
| 36 |
+
print("models.json exists and is valid.")
|
| 37 |
+
except json.JSONDecodeError:
|
| 38 |
+
print("models.json exists but has invalid JSON. Creating new file...")
|
| 39 |
+
config = {
|
| 40 |
+
"title": "Model Performance Leaderboard",
|
| 41 |
+
"description": "This leaderboard tracks and compares model performance across multiple metrics. Submit your model results to see how they stack up!",
|
| 42 |
+
"metrics": ["accuracy", "f1_score", "precision", "recall"],
|
| 43 |
+
"main_metric": "accuracy"
|
| 44 |
+
}
|
| 45 |
+
with open("models.json", "w") as f:
|
| 46 |
+
json.dump(config, f, indent=2)
|
| 47 |
+
|
| 48 |
+
print("Setup complete.")
|
| 49 |
+
|
| 50 |
+
if __name__ == "__main__":
|
| 51 |
+
setup()
|
start.sh
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Run setup script first
|
| 3 |
+
python setup.py
|
| 4 |
+
|
| 5 |
+
# Then start the main application
|
| 6 |
+
python app.py
|