albertvillanova HF staff commited on
Commit
99aea78
1 Parent(s): 45f2d12

Simplify loading 2 dataframes

Browse files
Files changed (1) hide show
  1. app.py +14 -14
app.py CHANGED
@@ -126,6 +126,10 @@ def load_results_dataframe(model_id):
126
  return df.set_index(pd.Index([model_name])).reset_index()
127
 
128
 
 
 
 
 
129
  def display_results(df_1, df_2, task):
130
  df = pd.concat([df.set_index("index") for df in [df_1, df_2] if "index" in df.columns])
131
  df = df.T.rename_axis(columns=None)
@@ -198,6 +202,10 @@ def load_details_dataframe(model_id, subtask):
198
  # return df.set_index(pd.Index([model_id])).reset_index()
199
 
200
 
 
 
 
 
201
  def display_details(df_1, df_2, sample_idx):
202
  s_1 = df_1.iloc[sample_idx]
203
  s_2 = df_2.iloc[sample_idx]
@@ -267,13 +275,9 @@ with gr.Blocks(fill_height=True) as demo:
267
  outputs=load_results_btn,
268
  )
269
  load_results_btn.click(
270
- fn=load_results_dataframe,
271
- inputs=model_id_1,
272
- outputs=dataframe_1,
273
- ).then(
274
- fn=load_results_dataframe,
275
- inputs=model_id_2,
276
- outputs=dataframe_2,
277
  ).then(
278
  fn=display_results,
279
  inputs=[dataframe_1, dataframe_2, task],
@@ -300,13 +304,9 @@ with gr.Blocks(fill_height=True) as demo:
300
  outputs=load_details_btn,
301
  )
302
  load_details_btn.click(
303
- fn=load_details_dataframe,
304
- inputs=[model_id_1, subtask],
305
- outputs=details_dataframe_1,
306
- ).then(
307
- fn=load_details_dataframe,
308
- inputs=[model_id_2, subtask],
309
- outputs=details_dataframe_2,
310
  ).then(
311
  fn=display_details,
312
  inputs=[details_dataframe_1, details_dataframe_2, sample_idx],
 
126
  return df.set_index(pd.Index([model_name])).reset_index()
127
 
128
 
129
+ def load_results_dataframes(*model_ids):
130
+ return [load_results_dataframe(model_id) for model_id in model_ids]
131
+
132
+
133
  def display_results(df_1, df_2, task):
134
  df = pd.concat([df.set_index("index") for df in [df_1, df_2] if "index" in df.columns])
135
  df = df.T.rename_axis(columns=None)
 
202
  # return df.set_index(pd.Index([model_id])).reset_index()
203
 
204
 
205
+ def load_details_dataframes(subtask, *model_ids):
206
+ return [load_details_dataframe(model_id, subtask) for model_id in model_ids]
207
+
208
+
209
  def display_details(df_1, df_2, sample_idx):
210
  s_1 = df_1.iloc[sample_idx]
211
  s_2 = df_2.iloc[sample_idx]
 
275
  outputs=load_results_btn,
276
  )
277
  load_results_btn.click(
278
+ fn=load_results_dataframes,
279
+ inputs=[model_id_1, model_id_2],
280
+ outputs=[dataframe_1, dataframe_2],
 
 
 
 
281
  ).then(
282
  fn=display_results,
283
  inputs=[dataframe_1, dataframe_2, task],
 
304
  outputs=load_details_btn,
305
  )
306
  load_details_btn.click(
307
+ fn=load_details_dataframes,
308
+ inputs=[subtask, model_id_1, model_id_2],
309
+ outputs=[details_dataframe_1, details_dataframe_2],
 
 
 
 
310
  ).then(
311
  fn=display_details,
312
  inputs=[details_dataframe_1, details_dataframe_2, sample_idx],