idolezal commited on
Commit
edb55ca
1 Parent(s): 48f1910

Try to highlight wins

Browse files
Files changed (1) hide show
  1. server.py +12 -12
server.py CHANGED
@@ -216,16 +216,16 @@ class LeaderboardServer:
216
  self.submission_id_to_file[submission_id] = submission_file
217
  self.submission_id_to_model_title[submission_id] = metadata["team_name"] + "/" + metadata["model_name"]
218
 
219
- def _model_tournament_table_format(self, c):
220
- if isinstance(c, int):
221
- return bool(c)
222
- else:
223
- return c
224
-
225
- def _model_tournament_table_style_pipe(self, styler):
226
- styler.format(self._model_tournament_table_format)
227
- #styler.highlight_max(color='lightgreen', axis=None)
228
- return styler
229
 
230
  def get_model_tournament_table(self, submission_id, category):
231
  if category == self.TASKS_CATEGORY_OVERALL:
@@ -245,7 +245,7 @@ class LeaderboardServer:
245
  for task in self.tournament_results[submission_id][competitor_id]:
246
  task_category = self.TASKS_METADATA[task]["category"]
247
  if task_category == category:
248
- match_results[task] = int(self.tournament_results[submission_id][competitor_id][task])
249
 
250
  model_link = data["metadata"]["link_to_model"]
251
  model_title = data["metadata"]["team_name"] + "/" + data["metadata"]["model_name"]
@@ -281,7 +281,7 @@ class LeaderboardServer:
281
  dataframe = dataframe.rename(
282
  columns=attributes_map_word_to_header
283
  )
284
- dataframe = dataframe.loc[1:].style.pipe(self._model_tournament_table_style_pipe)
285
  return dataframe
286
 
287
  def get_leaderboard(self, pre_submit=None, category=None):
 
216
  self.submission_id_to_file[submission_id] = submission_file
217
  self.submission_id_to_model_title[submission_id] = metadata["team_name"] + "/" + metadata["model_name"]
218
 
219
+ @staticmethod
220
+ def _model_tournament_table_highlight_true(x):
221
+ df_css = x.copy()
222
+ for c in df_css:
223
+ for i in range(len(df_css.index)):
224
+ if x[c].iloc[i] == True:
225
+ df_css[c].iloc[i] = 'background-color: lightgreen'
226
+ else:
227
+ df_css[c].iloc[i] = ''
228
+ return df_css
229
 
230
  def get_model_tournament_table(self, submission_id, category):
231
  if category == self.TASKS_CATEGORY_OVERALL:
 
245
  for task in self.tournament_results[submission_id][competitor_id]:
246
  task_category = self.TASKS_METADATA[task]["category"]
247
  if task_category == category:
248
+ match_results[task] = bool(self.tournament_results[submission_id][competitor_id][task])
249
 
250
  model_link = data["metadata"]["link_to_model"]
251
  model_title = data["metadata"]["team_name"] + "/" + data["metadata"]["model_name"]
 
281
  dataframe = dataframe.rename(
282
  columns=attributes_map_word_to_header
283
  )
284
+ dataframe = dataframe.style.apply(self._model_tournament_table_highlight_true, axis=None)
285
  return dataframe
286
 
287
  def get_leaderboard(self, pre_submit=None, category=None):