albertvillanova HF staff commited on
Commit
9c39267
1 Parent(s): 1f43e72

Put Results and Configs tabs at top level and sync

Browse files
Files changed (2) hide show
  1. app.py +28 -17
  2. src/results.py +16 -11
app.py CHANGED
@@ -27,22 +27,28 @@ with gr.Blocks(fill_height=True) as demo:
27
  dataframe_2 = gr.Dataframe(visible=False)
28
 
29
  with gr.Row():
30
- # with gr.Tab("All"):
31
- # pass
32
  with gr.Tab("Results"):
33
- load_results_btn = gr.Button("Load Results", interactive=False)
34
- clear_results_btn = gr.Button("Clear Results")
35
- task = gr.Radio(
36
  ["All"] + list(TASKS.values()),
37
  label="Tasks",
38
  info="Evaluation tasks to be displayed",
39
  value="All",
40
  visible=False,
41
  )
42
- with gr.Tab("Results"):
43
- results = gr.HTML()
44
- with gr.Tab("Configs"):
45
- configs = gr.HTML()
 
 
 
 
 
 
 
 
46
  with gr.Tab("Details"):
47
  details_task = gr.Radio(
48
  list(TASKS.values()),
@@ -70,27 +76,32 @@ with gr.Blocks(fill_height=True) as demo:
70
  details_dataframe = gr.DataFrame(visible=False)
71
 
72
  gr.on(
73
- triggers=[model_id_1.change, model_id_2.change],
74
  fn=update_load_results_component,
75
- outputs=load_results_btn,
76
  )
77
- load_results_btn.click(
 
78
  fn=load_results_dataframes,
79
  inputs=[model_id_1, model_id_2],
80
  outputs=[dataframe_1, dataframe_2],
81
  ).then(
82
  fn=update_tasks_component,
83
- outputs=task,
84
  )
 
 
 
85
  gr.on(
86
- triggers=[dataframe_1.change, dataframe_2.change, task.change],
87
  fn=display_results,
88
- inputs=[task, dataframe_1, dataframe_2],
89
  outputs=[results, configs],
90
  )
91
- clear_results_btn.click(
 
92
  fn=clear_results,
93
- outputs=[model_id_1, model_id_2, dataframe_1, dataframe_2, task],
94
  )
95
 
96
  details_task.change(
 
27
  dataframe_2 = gr.Dataframe(visible=False)
28
 
29
  with gr.Row():
 
 
30
  with gr.Tab("Results"):
31
+ load_results_btn = gr.Button("Load", interactive=False)
32
+ clear_results_btn = gr.Button("Clear")
33
+ results_task = gr.Radio(
34
  ["All"] + list(TASKS.values()),
35
  label="Tasks",
36
  info="Evaluation tasks to be displayed",
37
  value="All",
38
  visible=False,
39
  )
40
+ results = gr.HTML()
41
+ with gr.Tab("Configs"):
42
+ load_configs_btn = gr.Button("Load", interactive=False)
43
+ clear_configs_btn = gr.Button("Clear")
44
+ configs_task = gr.Radio(
45
+ ["All"] + list(TASKS.values()),
46
+ label="Tasks",
47
+ info="Evaluation tasks to be displayed",
48
+ value="All",
49
+ visible=False,
50
+ )
51
+ configs = gr.HTML()
52
  with gr.Tab("Details"):
53
  details_task = gr.Radio(
54
  list(TASKS.values()),
 
76
  details_dataframe = gr.DataFrame(visible=False)
77
 
78
  gr.on(
79
+ triggers=[model_id_1.input, model_id_2.input],
80
  fn=update_load_results_component,
81
+ outputs=[load_results_btn, load_configs_btn],
82
  )
83
+ gr.on(
84
+ triggers=[load_results_btn.click, load_configs_btn.click],
85
  fn=load_results_dataframes,
86
  inputs=[model_id_1, model_id_2],
87
  outputs=[dataframe_1, dataframe_2],
88
  ).then(
89
  fn=update_tasks_component,
90
+ outputs=[results_task, configs_task],
91
  )
92
+ # Synchronize the results_task and configs_task radio buttons
93
+ results_task.input(fn=lambda task: task, inputs=results_task, outputs=configs_task)
94
+ configs_task.input(fn=lambda task: task, inputs=configs_task, outputs=results_task)
95
  gr.on(
96
+ triggers=[dataframe_1.change, dataframe_2.change, results_task.change],
97
  fn=display_results,
98
+ inputs=[results_task, dataframe_1, dataframe_2],
99
  outputs=[results, configs],
100
  )
101
+ gr.on(
102
+ triggers=[clear_results_btn.click, clear_configs_btn.click],
103
  fn=clear_results,
104
+ outputs=[model_id_1, model_id_2, dataframe_1, dataframe_2, load_results_btn, load_configs_btn, results_task, configs_task],
105
  )
106
 
107
  details_task.change(
src/results.py CHANGED
@@ -24,7 +24,7 @@ def filter_latest_result_path_per_model(paths):
24
 
25
 
26
  def update_load_results_component():
27
- return gr.Button("Load Results", interactive=True)
28
 
29
 
30
  def load_results_dataframe(model_id, result_path_per_model=None):
@@ -74,24 +74,29 @@ def display_tab(tab, df, task):
74
 
75
 
76
  def update_tasks_component():
77
- return gr.Radio(
 
78
  ["All"] + list(TASKS.values()),
79
  label="Tasks",
80
  info="Evaluation tasks to be displayed",
81
  value="All",
82
  visible=True,
83
- )
 
84
 
85
 
86
  def clear_results():
87
- # model_id_1, model_id_2, dataframe_1, dataframe_2, task
88
  return (
89
  None, None, None, None,
90
- gr.Radio(
91
- ["All"] + list(TASKS.values()),
92
- label="Tasks",
93
- info="Evaluation tasks to be displayed",
94
- value="All",
95
- interactive=False,
96
- ),
 
 
 
97
  )
 
24
 
25
 
26
  def update_load_results_component():
27
+ return (gr.Button("Load", interactive=True), ) * 2
28
 
29
 
30
  def load_results_dataframe(model_id, result_path_per_model=None):
 
74
 
75
 
76
  def update_tasks_component():
77
+ return (
78
+ gr.Radio(
79
  ["All"] + list(TASKS.values()),
80
  label="Tasks",
81
  info="Evaluation tasks to be displayed",
82
  value="All",
83
  visible=True,
84
+ ),
85
+ ) * 2
86
 
87
 
88
  def clear_results():
89
+ # model_id_1, model_id_2, dataframe_1, dataframe_2, load_results_btn, load_configs_btn, results_task, configs_task
90
  return (
91
  None, None, None, None,
92
+ *(gr.Button("Load", interactive=False), ) * 2,
93
+ *(
94
+ gr.Radio(
95
+ ["All"] + list(TASKS.values()),
96
+ label="Tasks",
97
+ info="Evaluation tasks to be displayed",
98
+ value="All",
99
+ visible=False,
100
+ ),
101
+ ) * 2,
102
  )