albertvillanova HF staff commited on
Commit
7e19f96
1 Parent(s): bd858f5

Make display_results robust

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -130,8 +130,11 @@ 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)
136
  return display_tab("results", df, task), display_tab("configs", df, task)
137
 
@@ -299,7 +302,7 @@ with gr.Blocks(fill_height=True) as demo:
299
  outputs=[dataframe_1, dataframe_2],
300
  ).then(
301
  fn=display_results,
302
- inputs=[dataframe_1, dataframe_2, task],
303
  outputs=[results, configs],
304
  ).then(
305
  fn=update_tasks_component,
@@ -307,7 +310,7 @@ with gr.Blocks(fill_height=True) as demo:
307
  )
308
  task.change(
309
  fn=display_results,
310
- inputs=[dataframe_1, dataframe_2, task],
311
  outputs=[results, configs],
312
  )
313
 
 
130
  return [load_results_dataframe(model_id) for model_id in model_ids]
131
 
132
 
133
+ def display_results(task, *dfs):
134
+ dfs = [df.set_index("index") for df in dfs if "index" in df.columns]
135
+ if not dfs:
136
+ return None, None
137
+ df = pd.concat(dfs)
138
  df = df.T.rename_axis(columns=None)
139
  return display_tab("results", df, task), display_tab("configs", df, task)
140
 
 
302
  outputs=[dataframe_1, dataframe_2],
303
  ).then(
304
  fn=display_results,
305
+ inputs=[task, dataframe_1, dataframe_2],
306
  outputs=[results, configs],
307
  ).then(
308
  fn=update_tasks_component,
 
310
  )
311
  task.change(
312
  fn=display_results,
313
+ inputs=[task, dataframe_1, dataframe_2],
314
  outputs=[results, configs],
315
  )
316