idolezal commited on
Commit
1c2b941
β€’
1 Parent(s): 7384a2a

gr.DataFrame instead of Markdown table

Browse files
Files changed (1) hide show
  1. app.py +23 -21
app.py CHANGED
@@ -145,31 +145,27 @@ def fetch_model_detail(submission_id):
145
 
146
  def change_leaderboard_category(category):
147
  if category == leaderboard_server.TASKS_CATEGORY_OVERALL:
148
- task_abbreviation_legend = ""
 
 
 
 
149
  else:
150
- # TODO: gr.DataFrame
151
  task_abbreviation_legend_head = [
152
- "### Legend",
153
- "",
154
- "| task abbreviation | task name |",
155
- "| --- | --- |",
156
  ]
157
  task_abbreviation_legend_body = []
158
- task_abbreviation_legend_tail = [
159
- "",
160
- ]
161
  abbreviation2name = leaderboard_server.CATEGORY_TO_TASK_ABBREVIATION_TO_NAME[category]
162
  for abbr, name in abbreviation2name.items():
163
- abbr_escaped = xmlEscape(abbr, MARKDOWN_SPECIAL_CHARACTERS)
164
- name_escaped = xmlEscape(name, MARKDOWN_SPECIAL_CHARACTERS)
165
- task_abbreviation_legend_body.append(f"| {abbr_escaped} | {name_escaped} |")
166
 
167
- task_abbreviation_legend = (
168
- task_abbreviation_legend_head
169
- + task_abbreviation_legend_body
170
- + task_abbreviation_legend_tail
171
  )
172
- task_abbreviation_legend = "\n".join(task_abbreviation_legend)
173
 
174
  return (
175
  gr.update(
@@ -177,9 +173,7 @@ def change_leaderboard_category(category):
177
  visible=True,
178
  datatype="markdown",
179
  ),
180
- gr.update(
181
- value=task_abbreviation_legend,
182
- ),
183
  )
184
 
185
  def show_modal():
@@ -291,7 +285,15 @@ with gr.Blocks(theme=gr.themes.Soft(text_size=text_md), css=custom_css) as main:
291
  )
292
 
293
  with gr.Row():
294
- results_table_legend = gr.Markdown()
 
 
 
 
 
 
 
 
295
 
296
  category_of_tasks.change(
297
  fn=change_leaderboard_category,
 
145
 
146
  def change_leaderboard_category(category):
147
  if category == leaderboard_server.TASKS_CATEGORY_OVERALL:
148
+ task_abbreviation_legend = gr.update(
149
+ value=None,
150
+ headers=None,
151
+ visible=False,
152
+ )
153
  else:
 
154
  task_abbreviation_legend_head = [
155
+ "task abbreviation",
156
+ "task name",
 
 
157
  ]
158
  task_abbreviation_legend_body = []
159
+
 
 
160
  abbreviation2name = leaderboard_server.CATEGORY_TO_TASK_ABBREVIATION_TO_NAME[category]
161
  for abbr, name in abbreviation2name.items():
162
+ task_abbreviation_legend_body.append([abbr, name])
 
 
163
 
164
+ task_abbreviation_legend = gr.update(
165
+ value=task_abbreviation_legend_body,
166
+ headers=task_abbreviation_legend_head,
167
+ visible=True,
168
  )
 
169
 
170
  return (
171
  gr.update(
 
173
  visible=True,
174
  datatype="markdown",
175
  ),
176
+ task_abbreviation_legend,
 
 
177
  )
178
 
179
  def show_modal():
 
285
  )
286
 
287
  with gr.Row():
288
+ results_table_legend = gr.DataFrame(
289
+ value=None,
290
+ headers=None,
291
+ datatype="str",
292
+ label=None,
293
+ visible=False,
294
+ interactive=False,
295
+ elem_classes="leaderboard-table-legend",
296
+ )
297
 
298
  category_of_tasks.change(
299
  fn=change_leaderboard_category,