Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ Startup Flow:
|
|
| 5 |
1. Space rebuild (triggered by PR merge) → Docker container starts
|
| 6 |
2. Call evaluate.run_evaluation() to scan new submissions in submissions/
|
| 7 |
3. Calculate EM/F1 scores for new submissions, update leaderboard_data.json
|
| 8 |
-
4. Commit updated data back to repository (persistence)
|
| 9 |
5. Start Flask Web server
|
| 10 |
"""
|
| 11 |
|
|
@@ -49,7 +49,8 @@ def startup_evaluation():
|
|
| 49 |
- Re-evaluate all submissions (deduplicate using configuration combinations)
|
| 50 |
- Compare with groundtruth.jsonl to calculate scores
|
| 51 |
- Update leaderboard_data.json
|
| 52 |
-
- Commit results back to repository
|
|
|
|
| 53 |
|
| 54 |
Note:
|
| 55 |
- Every startup re-evaluates all files, making the logic simpler
|
|
@@ -61,11 +62,24 @@ def startup_evaluation():
|
|
| 61 |
logger.info("=" * 60)
|
| 62 |
|
| 63 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
total, _ = run_evaluation()
|
| 65 |
|
| 66 |
if total > 0:
|
| 67 |
-
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
else:
|
| 70 |
logger.info("No submissions found.")
|
| 71 |
|
|
|
|
| 5 |
1. Space rebuild (triggered by PR merge) → Docker container starts
|
| 6 |
2. Call evaluate.run_evaluation() to scan new submissions in submissions/
|
| 7 |
3. Calculate EM/F1 scores for new submissions, update leaderboard_data.json
|
| 8 |
+
4. Commit updated data back to repository (persistence) ONLY if data changed
|
| 9 |
5. Start Flask Web server
|
| 10 |
"""
|
| 11 |
|
|
|
|
| 49 |
- Re-evaluate all submissions (deduplicate using configuration combinations)
|
| 50 |
- Compare with groundtruth.jsonl to calculate scores
|
| 51 |
- Update leaderboard_data.json
|
| 52 |
+
- Commit results back to repository ONLY if data actually changed
|
| 53 |
+
(this prevents an infinite rebuild loop)
|
| 54 |
|
| 55 |
Note:
|
| 56 |
- Every startup re-evaluates all files, making the logic simpler
|
|
|
|
| 62 |
logger.info("=" * 60)
|
| 63 |
|
| 64 |
try:
|
| 65 |
+
# Read old leaderboard data before evaluation
|
| 66 |
+
old_data = None
|
| 67 |
+
if os.path.exists(LEADERBOARD_FILE):
|
| 68 |
+
with open(LEADERBOARD_FILE, 'r', encoding='utf-8') as f:
|
| 69 |
+
old_data = f.read()
|
| 70 |
+
|
| 71 |
total, _ = run_evaluation()
|
| 72 |
|
| 73 |
if total > 0:
|
| 74 |
+
# Read new leaderboard data after evaluation
|
| 75 |
+
with open(LEADERBOARD_FILE, 'r', encoding='utf-8') as f:
|
| 76 |
+
new_data = f.read()
|
| 77 |
+
|
| 78 |
+
if new_data != old_data:
|
| 79 |
+
logger.info("Leaderboard data changed. Committing to repo...")
|
| 80 |
+
commit_leaderboard_to_repo()
|
| 81 |
+
else:
|
| 82 |
+
logger.info("Leaderboard data unchanged. Skipping commit to avoid rebuild loop.")
|
| 83 |
else:
|
| 84 |
logger.info("No submissions found.")
|
| 85 |
|