Spaces:
Running
Running
Prepare leaderboard dataframes
Browse files
server.py
CHANGED
@@ -164,6 +164,7 @@ class LeaderboardServer:
|
|
164 |
self.submission_id_to_model_title = {}
|
165 |
self.submission_id_to_data = {} # Only data (results and metadata) using by leaderboard
|
166 |
self.tournament_results = None
|
|
|
167 |
|
168 |
self.results_dataset_local_snapshot_lock = ReadWriteLock()
|
169 |
self.results_dataset_local_snapshot = None
|
@@ -184,10 +185,17 @@ class LeaderboardServer:
|
|
184 |
)
|
185 |
|
186 |
self.fetch_existing_models()
|
187 |
-
tournament_results = self.load_tournament_results()
|
188 |
|
|
|
189 |
with self.var_lock.rw:
|
190 |
self.tournament_results = tournament_results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
|
192 |
def load_tournament_results(self):
|
193 |
with self.results_dataset_local_snapshot_lock.ro:
|
@@ -384,6 +392,14 @@ class LeaderboardServer:
|
|
384 |
return dataframe
|
385 |
|
386 |
def get_leaderboard(self, pre_submit=None, category=None):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
387 |
with self.var_lock.ro:
|
388 |
tournament_results = pre_submit.tournament_results if pre_submit else self.tournament_results
|
389 |
category = category if category else self.TASKS_CATEGORY_OVERALL
|
|
|
164 |
self.submission_id_to_model_title = {}
|
165 |
self.submission_id_to_data = {} # Only data (results and metadata) using by leaderboard
|
166 |
self.tournament_results = None
|
167 |
+
self.leaderboard_dataframes = {} # For each category
|
168 |
|
169 |
self.results_dataset_local_snapshot_lock = ReadWriteLock()
|
170 |
self.results_dataset_local_snapshot = None
|
|
|
185 |
)
|
186 |
|
187 |
self.fetch_existing_models()
|
|
|
188 |
|
189 |
+
tournament_results = self.load_tournament_results()
|
190 |
with self.var_lock.rw:
|
191 |
self.tournament_results = tournament_results
|
192 |
+
|
193 |
+
leaderboard_dataframes = {
|
194 |
+
category: self._get_leaderboard(category=category)
|
195 |
+
for category in [self.TASKS_CATEGORY_OVERALL] + sorted(self.TASKS_CATEGORIES)
|
196 |
+
}
|
197 |
+
with self.var_lock.rw:
|
198 |
+
self.leaderboard_dataframes = leaderboard_dataframes
|
199 |
|
200 |
def load_tournament_results(self):
|
201 |
with self.results_dataset_local_snapshot_lock.ro:
|
|
|
392 |
return dataframe
|
393 |
|
394 |
def get_leaderboard(self, pre_submit=None, category=None):
|
395 |
+
if pre_submit == None:
|
396 |
+
category = category if category else self.TASKS_CATEGORY_OVERALL
|
397 |
+
with self.var_lock.ro:
|
398 |
+
return copy.deepcopy(self.leaderboard_dataframes[category])
|
399 |
+
else:
|
400 |
+
return self._get_leaderboard(pre_submit=pre_submit, category=category)
|
401 |
+
|
402 |
+
def _get_leaderboard(self, pre_submit=None, category=None):
|
403 |
with self.var_lock.ro:
|
404 |
tournament_results = pre_submit.tournament_results if pre_submit else self.tournament_results
|
405 |
category = category if category else self.TASKS_CATEGORY_OVERALL
|