idolezal commited on
Commit
6bae7e8
1 Parent(s): 7e24376

More info to table of the tasks

Browse files
Files changed (2) hide show
  1. app.py +13 -10
  2. server.py +17 -4
app.py CHANGED
@@ -168,6 +168,14 @@ def fetch_model_tournament_results_table(submission_id, category):
168
  visible=True,
169
  )
170
 
 
 
 
 
 
 
 
 
171
  def change_leaderboard_category(category, selected_submission_id):
172
  if category == leaderboard_server.TASKS_CATEGORY_OVERALL:
173
  task_abbreviation_legend = gr.update(
@@ -183,14 +191,8 @@ def change_leaderboard_category(category, selected_submission_id):
183
  visible=False,
184
  )
185
  else:
186
- task_abbreviation_legend_body = []
187
-
188
- abbreviation2name = leaderboard_server.CATEGORY_TO_TASK_ABBREVIATION_TO_NAME[category]
189
- for abbr, name in abbreviation2name.items():
190
- task_abbreviation_legend_body.append([abbr, name])
191
-
192
  task_abbreviation_legend = gr.update(
193
- value=task_abbreviation_legend_body,
194
  visible=True,
195
  )
196
 
@@ -303,12 +305,13 @@ with gr.Blocks(theme=gr.themes.Soft(text_size=text_md), css=custom_css) as main:
303
  results_table_legend = gr.DataFrame(
304
  value=None,
305
  headers=[
306
- "task abbr.", # "task abbreviation"
307
- "task name",
 
308
  ],
309
  column_widths=["150px"],
310
  datatype="str",
311
- label=None,
312
  visible=False,
313
  interactive=False,
314
  elem_classes="leaderboard-table-legend",
 
168
  visible=True,
169
  )
170
 
171
+ def create_task_abbreviation_legend_table(category):
172
+ task_abbreviation_legend_body = []
173
+ abbreviation2name = leaderboard_server.CATEGORY_TO_TASK_ABBREVIATION_TO_DETAILS[category]
174
+ for abbr, name, url in abbreviation2name.values():
175
+ task_abbreviation_legend_body.append([abbr, name, url])
176
+
177
+ return task_abbreviation_legend_body
178
+
179
  def change_leaderboard_category(category, selected_submission_id):
180
  if category == leaderboard_server.TASKS_CATEGORY_OVERALL:
181
  task_abbreviation_legend = gr.update(
 
191
  visible=False,
192
  )
193
  else:
 
 
 
 
 
 
194
  task_abbreviation_legend = gr.update(
195
+ value=create_task_abbreviation_legend_table(category),
196
  visible=True,
197
  )
198
 
 
305
  results_table_legend = gr.DataFrame(
306
  value=None,
307
  headers=[
308
+ "Abbr.", # "task abbreviation"
309
+ "Name",
310
+ "URL",
311
  ],
312
  column_widths=["150px"],
313
  datatype="str",
314
+ label="Descriptions of the tasks",
315
  visible=False,
316
  interactive=False,
317
  elem_classes="leaderboard-table-legend",
server.py CHANGED
@@ -155,7 +155,7 @@ class LeaderboardServer:
155
  self.TASKS_METADATA = json.load(open(TASKS_METADATA_PATH))
156
  self.TASKS_CATEGORIES = {self.TASKS_METADATA[task]["category"] for task in self.TASKS_METADATA}
157
  self.TASKS_CATEGORY_OVERALL = "Overall"
158
- self.CATEGORY_TO_TASK_ABBREVIATION_TO_NAME = self._prepare_category_to_task_abbr_to_name()
159
 
160
  self.var_lock = ReadWriteLock()
161
  self.submission_ids = set()
@@ -190,18 +190,31 @@ class LeaderboardServer:
190
  results = json.load(ranks_file)
191
  return results
192
 
193
- def _prepare_category_to_task_abbr_to_name(self):
194
  tasks_per_category = {}
195
  for task in self.TASKS_METADATA:
196
  task_category = self.TASKS_METADATA[task]["category"]
197
  tasks_per_category.setdefault(task_category, list()).append(task)
198
 
199
- category2abbreviation2name = {}
200
  for category, tasks in tasks_per_category.items():
201
- abbreviation2name = {self.TASKS_METADATA[t]["abbreviation"]: self.TASKS_METADATA[t]["name"] for t in tasks}
 
 
 
 
 
 
 
202
  sorted_abbreviation2name = dict.fromkeys(sorted(abbreviation2name.keys()))
203
  sorted_abbreviation2name.update(abbreviation2name)
204
  category2abbreviation2name[category] = sorted_abbreviation2name
 
 
 
 
 
 
205
 
206
  return category2abbreviation2name
207
 
 
155
  self.TASKS_METADATA = json.load(open(TASKS_METADATA_PATH))
156
  self.TASKS_CATEGORIES = {self.TASKS_METADATA[task]["category"] for task in self.TASKS_METADATA}
157
  self.TASKS_CATEGORY_OVERALL = "Overall"
158
+ self.CATEGORY_TO_TASK_ABBREVIATION_TO_DETAILS = self._prepare_category_to_task_abbr_to_details()
159
 
160
  self.var_lock = ReadWriteLock()
161
  self.submission_ids = set()
 
190
  results = json.load(ranks_file)
191
  return results
192
 
193
+ def _prepare_category_to_task_abbr_to_details(self):
194
  tasks_per_category = {}
195
  for task in self.TASKS_METADATA:
196
  task_category = self.TASKS_METADATA[task]["category"]
197
  tasks_per_category.setdefault(task_category, list()).append(task)
198
 
199
+ category2abbreviation2name = {self.TASKS_CATEGORY_OVERALL: {}}
200
  for category, tasks in tasks_per_category.items():
201
+ abbreviation2name = {
202
+ self.TASKS_METADATA[t]["abbreviation"]: (
203
+ self.TASKS_METADATA[t]["abbreviation"],
204
+ self.TASKS_METADATA[t]["name"],
205
+ self.TASKS_METADATA[t]["source_url"],
206
+ )
207
+ for t in tasks
208
+ }
209
  sorted_abbreviation2name = dict.fromkeys(sorted(abbreviation2name.keys()))
210
  sorted_abbreviation2name.update(abbreviation2name)
211
  category2abbreviation2name[category] = sorted_abbreviation2name
212
+ category2abbreviation2name[self.TASKS_CATEGORY_OVERALL].update(sorted_abbreviation2name)
213
+
214
+ abbreviation2name = category2abbreviation2name[self.TASKS_CATEGORY_OVERALL]
215
+ sorted_abbreviation2name = dict.fromkeys(sorted(abbreviation2name.keys()))
216
+ sorted_abbreviation2name.update(abbreviation2name)
217
+ category2abbreviation2name[self.TASKS_CATEGORY_OVERALL] = sorted_abbreviation2name
218
 
219
  return category2abbreviation2name
220