badaoui HF Staff commited on
Commit
f3f4c77
·
1 Parent(s): 69d6e2e

improve encore

Browse files
Files changed (1) hide show
  1. app.py +66 -105
app.py CHANGED
@@ -379,20 +379,15 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
379
  gr.update(visible=show_all), # all_models_container
380
  gr.update(visible=show_amd_only), # amd_failures_container
381
  gr.update(visible=show_nvidia_only), # nvidia_failures_container
382
- gr.update(visible=show_all_failures), # all_failures_container
 
 
 
 
 
 
 
383
  )
384
-
385
- # Connect both checkboxes to the filter function
386
- show_amd_failures.change(
387
- fn=filter_failing_models,
388
- inputs=[show_amd_failures, show_nvidia_failures],
389
- outputs=[all_models_container, amd_failures_container, nvidia_failures_container, both_failures_container]
390
- )
391
- show_nvidia_failures.change(
392
- fn=filter_failing_models,
393
- inputs=[show_amd_failures, show_nvidia_failures],
394
- outputs=[all_models_container, amd_failures_container, nvidia_failures_container, both_failures_container]
395
- )
396
 
397
  # Regressions panel toggle functionality
398
  def toggle_regressions_panel(current_visible):
@@ -556,6 +551,11 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
556
 
557
 
558
 
 
 
 
 
 
559
  def get_historical_summary_plots():
560
  """Get historical summary plots from preloaded data."""
561
  plots = create_time_series_summary_gradio(Ci_results.historical_df)
@@ -564,77 +564,61 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
564
  gr.update(value=plots['amd_tests'], visible=True),
565
  gr.update(value=plots['nvidia_tests'], visible=True),
566
  )
 
 
 
 
 
 
 
 
567
 
568
  def handle_history_toggle(history_mode, last_selected_model, in_model_view):
569
- # Helper to create visibility updates efficiently
570
- hidden = gr.update(visible=False)
571
- shown = gr.update(visible=True)
572
- noop = gr.update()
573
-
574
  if history_mode:
575
- if in_model_view and last_selected_model: # Show historical model detail
 
576
  amd_ts, nvidia_ts = show_time_series_model(last_selected_model)
577
- return (hidden, shown, hidden, hidden, hidden, hidden, hidden, hidden,
578
- amd_ts, nvidia_ts, shown, noop, noop, noop, True)
579
- # Show historical summary
580
  fr_plot, amd_plot, nvidia_plot = get_historical_summary_plots()
581
- return (hidden, shown, hidden, hidden, hidden, fr_plot, amd_plot, nvidia_plot,
582
- noop, noop, hidden, noop, noop, noop, False)
583
  else:
584
- # Switch to current mode
585
  if last_selected_model and Ci_results.df is not None and not Ci_results.df.empty and last_selected_model in Ci_results.df.index:
586
  fig, amd_txt, nvidia_txt = plot_model_stats(Ci_results.df, last_selected_model, Ci_results.all_historical_data)
587
- return (shown, hidden, hidden, hidden, shown, hidden, hidden, hidden,
588
- noop, noop, hidden, fig, amd_txt, nvidia_txt, True)
589
- else:
590
- fig = create_summary_page(Ci_results.df, Ci_results.available_models)
591
- return (shown, hidden, shown, gr.update(value=fig, visible=True), hidden,
592
- hidden, hidden, hidden, noop, noop, hidden, noop, noop, noop, False)
593
 
 
 
 
 
 
 
 
 
 
 
 
 
594
  history_view_button.change(
595
  fn=handle_history_toggle,
596
  inputs=[history_view_button, selected_model_state, in_model_view_state],
597
  outputs=[
598
- current_view,
599
- historical_view,
600
- summary_view,
601
- summary_display,
602
- detail_view,
603
- time_series_failure_rates,
604
- time_series_amd_tests,
605
- time_series_nvidia_tests,
606
- time_series_amd_model_plot,
607
- time_series_nvidia_model_plot,
608
- time_series_detail_view,
609
- plot_output,
610
- amd_failed_tests_output,
611
- nvidia_failed_tests_output,
612
- in_model_view_state,
613
  ],
614
  )
615
 
616
-
617
- # Time-series model selection functionality
618
- def show_time_series_model(selected_model):
619
- """Show time-series view for a specific model."""
620
- plots = create_model_time_series_gradio(Ci_results.historical_df, selected_model)
621
- return (
622
- gr.update(value=plots['amd_plot'], visible=True),
623
- gr.update(value=plots['nvidia_plot'], visible=True),
624
- )
625
-
626
- # Unified model click handler: respects History toggle
627
- def handle_model_click(selected_model: str, history_mode: bool):
628
- noop, hidden, shown = gr.update(), gr.update(visible=False), gr.update(visible=True)
629
- if history_mode:
630
- amd_ts, nvidia_ts = show_time_series_model(selected_model)
631
- return (noop, noop, noop, hidden, shown, hidden, hidden, hidden, hidden, hidden,
632
- hidden, amd_ts, nvidia_ts, shown, selected_model, True)
633
- else:
634
- fig, amd_txt, nvidia_txt = plot_model_stats(Ci_results.df, selected_model, Ci_results.all_historical_data)
635
- return (fig, amd_txt, nvidia_txt, shown, hidden, hidden, hidden, shown, noop, noop,
636
- noop, noop, noop, hidden, selected_model, True)
637
-
638
  # Define common outputs for model click handlers
639
  model_click_outputs = [
640
  plot_output, amd_failed_tests_output, nvidia_failed_tests_output,
@@ -644,44 +628,21 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
644
  selected_model_state, in_model_view_state,
645
  ]
646
 
647
- # Wire up all model buttons
648
- for i, btn in enumerate(model_buttons):
649
- model_name = model_choices[i]
650
- btn.click(
651
- fn=lambda history_mode, m=model_name: handle_model_click(m, history_mode),
652
- inputs=[history_view_button],
653
- outputs=model_click_outputs,
654
- )
655
-
656
- # Wire up AMD failing model buttons
657
- amd_models_to_show = amd_failing_models + both_failing_models
658
- for i, btn in enumerate(amd_buttons):
659
- model_name = sorted(amd_models_to_show)[i]
660
- btn.click(
661
- fn=lambda history_mode, m=model_name: handle_model_click(m, history_mode),
662
- inputs=[history_view_button],
663
- outputs=model_click_outputs,
664
- )
665
-
666
- # Wire up NVIDIA failing model buttons
667
- nvidia_models_to_show = nvidia_failing_models + both_failing_models
668
- for i, btn in enumerate(nvidia_buttons):
669
- model_name = sorted(nvidia_models_to_show)[i]
670
- btn.click(
671
- fn=lambda history_mode, m=model_name: handle_model_click(m, history_mode),
672
- inputs=[history_view_button],
673
- outputs=model_click_outputs,
674
- )
675
 
676
- # Wire up both failures model buttons
677
- all_failing = list(set(amd_failing_models + nvidia_failing_models + both_failing_models))
678
- for i, btn in enumerate(both_buttons):
679
- model_name = sorted(all_failing)[i]
680
- btn.click(
681
- fn=lambda history_mode, m=model_name: handle_model_click(m, history_mode),
682
- inputs=[history_view_button],
683
- outputs=model_click_outputs,
684
- )
685
 
686
  # Summary button click handler
687
  def show_summary_and_update_links():
 
379
  gr.update(visible=show_all), # all_models_container
380
  gr.update(visible=show_amd_only), # amd_failures_container
381
  gr.update(visible=show_nvidia_only), # nvidia_failures_container
382
+ gr.update(visible=show_all_failures), # both_failures_container
383
+ )
384
+
385
+ for checkbox in [show_amd_failures, show_nvidia_failures]:
386
+ checkbox.change(
387
+ fn=filter_failing_models,
388
+ inputs=[show_amd_failures, show_nvidia_failures],
389
+ outputs=[all_models_container, amd_failures_container, nvidia_failures_container, both_failures_container]
390
  )
 
 
 
 
 
 
 
 
 
 
 
 
391
 
392
  # Regressions panel toggle functionality
393
  def toggle_regressions_panel(current_visible):
 
551
 
552
 
553
 
554
+ # Constants for Gradio updates
555
+ HIDDEN = gr.update(visible=False)
556
+ SHOWN = gr.update(visible=True)
557
+ NOOP = gr.update()
558
+
559
  def get_historical_summary_plots():
560
  """Get historical summary plots from preloaded data."""
561
  plots = create_time_series_summary_gradio(Ci_results.historical_df)
 
564
  gr.update(value=plots['amd_tests'], visible=True),
565
  gr.update(value=plots['nvidia_tests'], visible=True),
566
  )
567
+
568
+ def show_time_series_model(selected_model):
569
+ """Show time-series view for a specific model."""
570
+ plots = create_model_time_series_gradio(Ci_results.historical_df, selected_model)
571
+ return (
572
+ gr.update(value=plots['amd_plot'], visible=True),
573
+ gr.update(value=plots['nvidia_plot'], visible=True),
574
+ )
575
 
576
  def handle_history_toggle(history_mode, last_selected_model, in_model_view):
577
+ """Handle toggling between current and historical view."""
 
 
 
 
578
  if history_mode:
579
+ # Historical mode: show model detail if in model view, otherwise summary
580
+ if in_model_view and last_selected_model:
581
  amd_ts, nvidia_ts = show_time_series_model(last_selected_model)
582
+ return (HIDDEN, SHOWN, HIDDEN, HIDDEN, HIDDEN, HIDDEN, HIDDEN, HIDDEN,
583
+ amd_ts, nvidia_ts, SHOWN, NOOP, NOOP, NOOP, True)
584
+
585
  fr_plot, amd_plot, nvidia_plot = get_historical_summary_plots()
586
+ return (HIDDEN, SHOWN, HIDDEN, HIDDEN, HIDDEN, fr_plot, amd_plot, nvidia_plot,
587
+ NOOP, NOOP, HIDDEN, NOOP, NOOP, NOOP, False)
588
  else:
589
+ # Current mode: show model detail if available, otherwise summary
590
  if last_selected_model and Ci_results.df is not None and not Ci_results.df.empty and last_selected_model in Ci_results.df.index:
591
  fig, amd_txt, nvidia_txt = plot_model_stats(Ci_results.df, last_selected_model, Ci_results.all_historical_data)
592
+ return (SHOWN, HIDDEN, HIDDEN, HIDDEN, SHOWN, HIDDEN, HIDDEN, HIDDEN,
593
+ NOOP, NOOP, HIDDEN, fig, amd_txt, nvidia_txt, True)
594
+
595
+ fig = create_summary_page(Ci_results.df, Ci_results.available_models)
596
+ return (SHOWN, HIDDEN, SHOWN, gr.update(value=fig, visible=True), HIDDEN,
597
+ HIDDEN, HIDDEN, HIDDEN, NOOP, NOOP, HIDDEN, NOOP, NOOP, NOOP, False)
598
 
599
+ def handle_model_click(selected_model: str, history_mode: bool):
600
+ """Handle clicking on a model button."""
601
+ if history_mode:
602
+ amd_ts, nvidia_ts = show_time_series_model(selected_model)
603
+ return (NOOP, NOOP, NOOP, HIDDEN, SHOWN, HIDDEN, HIDDEN, HIDDEN, HIDDEN, HIDDEN,
604
+ HIDDEN, amd_ts, nvidia_ts, SHOWN, selected_model, True)
605
+
606
+ fig, amd_txt, nvidia_txt = plot_model_stats(Ci_results.df, selected_model, Ci_results.all_historical_data)
607
+ return (fig, amd_txt, nvidia_txt, SHOWN, HIDDEN, HIDDEN, HIDDEN, SHOWN, NOOP, NOOP,
608
+ NOOP, NOOP, NOOP, HIDDEN, selected_model, True)
609
+
610
+ # Wire up history toggle
611
  history_view_button.change(
612
  fn=handle_history_toggle,
613
  inputs=[history_view_button, selected_model_state, in_model_view_state],
614
  outputs=[
615
+ current_view, historical_view, summary_view, summary_display, detail_view,
616
+ time_series_failure_rates, time_series_amd_tests, time_series_nvidia_tests,
617
+ time_series_amd_model_plot, time_series_nvidia_model_plot, time_series_detail_view,
618
+ plot_output, amd_failed_tests_output, nvidia_failed_tests_output, in_model_view_state,
 
 
 
 
 
 
 
 
 
 
 
619
  ],
620
  )
621
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
622
  # Define common outputs for model click handlers
623
  model_click_outputs = [
624
  plot_output, amd_failed_tests_output, nvidia_failed_tests_output,
 
628
  selected_model_state, in_model_view_state,
629
  ]
630
 
631
+ # Helper function to connect button clicks
632
+ def connect_model_buttons(buttons, models):
633
+ """Connect a list of buttons to their corresponding models."""
634
+ for btn, model_name in zip(buttons, models):
635
+ btn.click(
636
+ fn=lambda history_mode, m=model_name: handle_model_click(m, history_mode),
637
+ inputs=[history_view_button],
638
+ outputs=model_click_outputs,
639
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
640
 
641
+ # Wire up all button groups
642
+ connect_model_buttons(model_buttons, model_choices)
643
+ connect_model_buttons(amd_buttons, sorted(amd_failing_models + both_failing_models))
644
+ connect_model_buttons(nvidia_buttons, sorted(nvidia_failing_models + both_failing_models))
645
+ connect_model_buttons(both_buttons, sorted(list(set(amd_failing_models + nvidia_failing_models + both_failing_models))))
 
 
 
 
646
 
647
  # Summary button click handler
648
  def show_summary_and_update_links():