martinigoyanes commited on
Commit
2c9a73e
·
1 Parent(s): aa92f8e

fix: refresh button

Browse files
Files changed (2) hide show
  1. app.py +6 -11
  2. dabstep_benchmark/leaderboard.py +7 -2
app.py CHANGED
@@ -9,12 +9,7 @@ from dabstep_benchmark.leaderboard import *
9
  def restart_space():
10
  HF_API.restart_space(repo_id=HF_LEADERBOARD)
11
 
12
- # Helper function to update both tables
13
- def update_tables():
14
- leaderboard_df = generate_leaderboard_df()
15
- validated = leaderboard_df[leaderboard_df["validated"] == True].drop(columns=["validated"])
16
- unvalidated = leaderboard_df[leaderboard_df["validated"] == False].drop(columns=["validated"])
17
- return validated, unvalidated
18
 
19
 
20
 
@@ -28,11 +23,11 @@ if __name__ == "__main__":
28
  gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
29
 
30
  # Generate initial leaderboard data
31
- validated, unvalidated = update_tables()
32
-
33
  with gr.Tab("Validated"):
34
  verified_table = gr.Dataframe(
35
- value=validated,
36
  datatype=["markdown", "str", "str", "str", "markdown", "str", "str", "str"],
37
  interactive=False,
38
  column_widths=["20%"],
@@ -41,14 +36,14 @@ if __name__ == "__main__":
41
 
42
  with gr.Tab("Unvalidated"):
43
  unverified_table = gr.Dataframe(
44
- value=unvalidated,
45
  datatype=["markdown", "str", "str", "str", "markdown", "str", "str", "str"],
46
  interactive=False,
47
  column_widths=["20%"],
48
  wrap=True,
49
  )
50
  # create a Gradio event listener that runs when the page is loaded to populate the dataframe
51
- demo.load(update_tables, inputs=None, outputs=[verified_table, unverified_table])
52
 
53
  refresh_button = gr.Button("Refresh")
54
  refresh_button.click(
 
9
  def restart_space():
10
  HF_API.restart_space(repo_id=HF_LEADERBOARD)
11
 
12
+
 
 
 
 
 
13
 
14
 
15
 
 
23
  gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
24
 
25
  # Generate initial leaderboard data
26
+ validated_lb, unvalidated_lb = generate_leaderboard_df()
27
+
28
  with gr.Tab("Validated"):
29
  verified_table = gr.Dataframe(
30
+ value=validated_lb,
31
  datatype=["markdown", "str", "str", "str", "markdown", "str", "str", "str"],
32
  interactive=False,
33
  column_widths=["20%"],
 
36
 
37
  with gr.Tab("Unvalidated"):
38
  unverified_table = gr.Dataframe(
39
+ value=unvalidated_lb,
40
  datatype=["markdown", "str", "str", "str", "markdown", "str", "str", "str"],
41
  interactive=False,
42
  column_widths=["20%"],
43
  wrap=True,
44
  )
45
  # create a Gradio event listener that runs when the page is loaded to populate the dataframe
46
+ demo.load(generate_leaderboard_df, inputs=None, outputs=[verified_table, unverified_table])
47
 
48
  refresh_button = gr.Button("Refresh")
49
  refresh_button.click(
dabstep_benchmark/leaderboard.py CHANGED
@@ -1,4 +1,6 @@
1
  import re
 
 
2
  import gradio as gr
3
  import json
4
  import datetime
@@ -228,7 +230,7 @@ def process_submission(
228
  Please refresh the leaderboard to see your score displayed.
229
  """)
230
 
231
- def generate_leaderboard_df() -> pd.DataFrame:
232
  task_scores_df = DATASETS["task_scores"].to_pandas()
233
  submissions_df = DATASETS["submissions"].to_pandas()
234
 
@@ -311,4 +313,7 @@ def generate_leaderboard_df() -> pd.DataFrame:
311
  # sort-by best score
312
  df.sort_values(by="Hard Level Accuracy (%)", ascending=False, inplace=True)
313
 
314
- return df
 
 
 
 
1
  import re
2
+ from typing import Tuple
3
+
4
  import gradio as gr
5
  import json
6
  import datetime
 
230
  Please refresh the leaderboard to see your score displayed.
231
  """)
232
 
233
+ def generate_leaderboard_df() -> Tuple[pd.DataFrame, pd.DataFrame]:
234
  task_scores_df = DATASETS["task_scores"].to_pandas()
235
  submissions_df = DATASETS["submissions"].to_pandas()
236
 
 
313
  # sort-by best score
314
  df.sort_values(by="Hard Level Accuracy (%)", ascending=False, inplace=True)
315
 
316
+ validated = leaderboard_df[leaderboard_df["validated"] == True].drop(columns=["validated"])
317
+ unvalidated = leaderboard_df[leaderboard_df["validated"] == False].drop(columns=["validated"])
318
+
319
+ return validated, unvalidated