AlexNijjar commited on
Commit
aa04fbd
1 Parent(s): 0eac6a7

fix duplicate entries and sort order

Browse files
Files changed (1) hide show
  1. app.py +15 -8
app.py CHANGED
@@ -63,24 +63,31 @@ def refresh_leaderboard():
63
  if not is_valid_run(run):
64
  continue
65
 
 
66
  for key, value in run.summary.items():
67
  if key.startswith("_"):
68
  continue
69
 
 
 
70
  try:
71
  uid = int(key)
72
 
73
- entries[uid] = LeaderboardEntry(
74
- uid=uid,
75
- rank=value["rank"],
76
- model=value["model"],
77
- score=value["score"],
78
- hotkey=value["hotkey"],
79
- previous_day_winner=value["multiday_winner"],
80
- )
 
81
  except Exception:
82
  continue
83
 
 
 
 
84
  leaderboard: list[tuple] = [
85
  (entry.rank + 1, entry.uid, entry.model, entry.score, entry.hotkey, entry.previous_day_winner)
86
  for entry in sorted(entries.values(), key=lambda entry: entry.rank)
 
63
  if not is_valid_run(run):
64
  continue
65
 
66
+ has_data = False
67
  for key, value in run.summary.items():
68
  if key.startswith("_"):
69
  continue
70
 
71
+ has_data = True
72
+
73
  try:
74
  uid = int(key)
75
 
76
+ if uid not in entries:
77
+ entries[uid] = LeaderboardEntry(
78
+ uid=uid,
79
+ rank=value["rank"],
80
+ model=value["model"],
81
+ score=value["score"],
82
+ hotkey=value["hotkey"],
83
+ previous_day_winner=value["multiday_winner"],
84
+ )
85
  except Exception:
86
  continue
87
 
88
+ if has_data:
89
+ break
90
+
91
  leaderboard: list[tuple] = [
92
  (entry.rank + 1, entry.uid, entry.model, entry.score, entry.hotkey, entry.previous_day_winner)
93
  for entry in sorted(entries.values(), key=lambda entry: entry.rank)