ggcristian commited on
Commit
cc18a4c
·
1 Parent(s): 27abc2a

TLDR: A single trailing comma was causing a race-condition bug.

Browse files

By having two event handlers on the same task_radio component, it meant that sometimes one event handler was executed before the other and so on => race condition.

Tried grouping both onto a single event handler but gradio was complaining. And the reason of the complaint was because we were returning a tuple.

The leaderboard component had a trailing comma at the end which converted it onto a tuple instead of a list.

Files changed (1) hide show
  1. app.py +17 -7
app.py CHANGED
@@ -64,13 +64,16 @@ def filter_leaderboard(task, benchmark, model_type, search_query, max_params):
64
 
65
  def update_benchmarks_by_task(task):
66
  if task == "Spec-to-RTL":
67
- return gr.update(value="All", choices=["All"] + s2r_benchs)
68
  elif task == "Code Completion":
69
- return gr.update(value="All", choices=["All"] + cc_benchs)
70
  elif task == "Line Completion":
71
- return gr.update(value="All", choices=["All"] + lc_benchs)
72
  else:
73
- return gr.update(value="All", choices=["All"] + benchmarks)
 
 
 
74
 
75
  def generate_scatter_plot(benchmark, metric):
76
  if benchmark == "All":
@@ -256,7 +259,7 @@ with gr.Blocks(css=custom_css, js=js_func, theme=gr.themes.Default(primary_hue=c
256
  wrap=True,
257
  datatype=["markdown", "html",],
258
  interactive=False,
259
- column_widths=["7%", "25%", "10%", "17%", "6%", "6%", "6%", "6%", "6%", "7%"]),
260
 
261
  with gr.Tab("Interactive Bubble Plot"):
262
  with gr.Row(equal_height=True):
@@ -306,8 +309,15 @@ with gr.Blocks(css=custom_css, js=js_func, theme=gr.themes.Default(primary_hue=c
306
  )
307
 
308
  # event handlers, ugly way but it works
309
- task_radio.change(fn=update_benchmarks_by_task, inputs=[task_radio], outputs=[benchmark_radio])
310
- task_radio.change(fn=filter_leaderboard, inputs=[task_radio, benchmark_radio, model_type_dropdown, search_box, params_slider], outputs=leaderboard)
 
 
 
 
 
 
 
311
  benchmark_radio.change(fn=filter_leaderboard, inputs=[task_radio, benchmark_radio, model_type_dropdown, search_box, params_slider], outputs=leaderboard)
312
  model_type_dropdown.change(fn=filter_leaderboard, inputs=[task_radio, benchmark_radio, model_type_dropdown, search_box, params_slider], outputs=leaderboard)
313
  search_box.change(fn=filter_leaderboard, inputs=[task_radio, benchmark_radio, model_type_dropdown, search_box, params_slider], outputs=leaderboard)
 
64
 
65
  def update_benchmarks_by_task(task):
66
  if task == "Spec-to-RTL":
67
+ new_benchmarks = ["All"] + s2r_benchs
68
  elif task == "Code Completion":
69
+ new_benchmarks = ["All"] + cc_benchs
70
  elif task == "Line Completion":
71
+ new_benchmarks = lc_benchs
72
  else:
73
+ new_benchmarks = ["All"] + benchmarks
74
+ benchmark_value = "All" if "All" in new_benchmarks else new_benchmarks[0]
75
+ filtered = filter_leaderboard(task, benchmark_value, model_type_dropdown.value, search_box.value, params_slider.value)
76
+ return gr.update(value=benchmark_value, choices=new_benchmarks), filtered
77
 
78
  def generate_scatter_plot(benchmark, metric):
79
  if benchmark == "All":
 
259
  wrap=True,
260
  datatype=["markdown", "html",],
261
  interactive=False,
262
+ column_widths=["7%", "25%", "10%", "17%", "6%", "6%", "6%", "6%", "6%", "7%"])
263
 
264
  with gr.Tab("Interactive Bubble Plot"):
265
  with gr.Row(equal_height=True):
 
309
  )
310
 
311
  # event handlers, ugly way but it works
312
+ print(f"type(benchmark_radio): {type(benchmark_radio)}")
313
+ print(f"type(leaderboard): {type(leaderboard)}")
314
+ task_radio.change(
315
+ fn=update_benchmarks_by_task,
316
+ inputs=[task_radio],
317
+ outputs=[benchmark_radio, leaderboard]
318
+ )
319
+ # task_radio.change(fn=update_benchmarks_by_task, inputs=[task_radio], outputs=[benchmark_radio])
320
+ # task_radio.change(fn=filter_leaderboard, inputs=[task_radio, benchmark_radio, model_type_dropdown, search_box, params_slider], outputs=leaderboard)
321
  benchmark_radio.change(fn=filter_leaderboard, inputs=[task_radio, benchmark_radio, model_type_dropdown, search_box, params_slider], outputs=leaderboard)
322
  model_type_dropdown.change(fn=filter_leaderboard, inputs=[task_radio, benchmark_radio, model_type_dropdown, search_box, params_slider], outputs=leaderboard)
323
  search_box.change(fn=filter_leaderboard, inputs=[task_radio, benchmark_radio, model_type_dropdown, search_box, params_slider], outputs=leaderboard)