ZeroCommand commited on
Commit
4ecd715
1 Parent(s): 125e9f3

update the dataframe after every load from leaderboard dataset

Browse files
Files changed (1) hide show
  1. app_leaderboard.py +10 -5
app_leaderboard.py CHANGED
@@ -74,10 +74,6 @@ def get_display_df(df):
74
  )
75
  return display_df
76
 
77
- def update_leaderboard_records():
78
- logger.info("Updating leaderboard records")
79
- leaderboard.records = get_records_from_dataset_repo(leaderboard.LEADERBOARD)
80
-
81
  def get_demo(leaderboard_tab):
82
  logger.info("Loading leaderboard records")
83
  leaderboard.records = get_records_from_dataset_repo(leaderboard.LEADERBOARD)
@@ -120,7 +116,15 @@ def get_demo(leaderboard_tab):
120
  with gr.Row():
121
  leaderboard_df = gr.DataFrame(display_df, datatype=types, interactive=False)
122
 
123
- leaderboard_tab.select(fn=update_leaderboard_records)
 
 
 
 
 
 
 
 
124
 
125
  @gr.on(
126
  triggers=[
@@ -133,6 +137,7 @@ def get_demo(leaderboard_tab):
133
  outputs=[leaderboard_df],
134
  )
135
  def filter_table(model_id, dataset_id, columns, task):
 
136
  records = leaderboard.records
137
  # filter the table based on task
138
  df = records[(records["task"] == task)]
 
74
  )
75
  return display_df
76
 
 
 
 
 
77
  def get_demo(leaderboard_tab):
78
  logger.info("Loading leaderboard records")
79
  leaderboard.records = get_records_from_dataset_repo(leaderboard.LEADERBOARD)
 
116
  with gr.Row():
117
  leaderboard_df = gr.DataFrame(display_df, datatype=types, interactive=False)
118
 
119
+ def update_leaderboard_records(model_id, dataset_id, columns, task):
120
+ logger.info("Updating leaderboard records")
121
+ leaderboard.records = get_records_from_dataset_repo(leaderboard.LEADERBOARD)
122
+ return filter_table(model_id, dataset_id, columns, task)
123
+
124
+ leaderboard_tab.select(
125
+ fn=update_leaderboard_records,
126
+ inputs=[model_select, dataset_select, columns_select, task_select],
127
+ outputs=[leaderboard_df])
128
 
129
  @gr.on(
130
  triggers=[
 
137
  outputs=[leaderboard_df],
138
  )
139
  def filter_table(model_id, dataset_id, columns, task):
140
+ print("filtering table")
141
  records = leaderboard.records
142
  # filter the table based on task
143
  df = records[(records["task"] == task)]