badaoui HF Staff commited on
Commit
840d3e5
·
verified ·
1 Parent(s): de3de97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +137 -167
app.py CHANGED
@@ -15,42 +15,50 @@ from time_series_gradio import (
15
  get_model_time_series_dfs,
16
  )
17
 
 
 
 
 
 
 
 
 
 
 
18
 
19
- # Configure matplotlib to prevent memory warnings and set dark background
20
- matplotlib.rcParams['figure.facecolor'] = '#000000'
21
- matplotlib.rcParams['axes.facecolor'] = '#000000'
22
- matplotlib.rcParams['savefig.facecolor'] = '#000000'
23
- plt.ioff() # Turn off interactive mode to prevent figure accumulation
 
 
 
 
24
 
25
 
26
- # Load data once at startup
27
  Ci_results = CIResults()
28
  Ci_results.load_data()
29
- # Preload historical data at startup
30
  if Ci_results.available_dates:
31
- start_date_val = Ci_results.available_dates[-1] # Last date (oldest)
32
- end_date_val = Ci_results.available_dates[0] # First date (newest)
33
  Ci_results.load_historical_data(start_date_val, end_date_val)
34
  logger.info(f"Preloaded historical data: {len(Ci_results.historical_df)} records")
35
- # Start the auto-reload scheduler
36
  Ci_results.schedule_data_reload()
37
 
38
 
39
- # Function to check if a model has failures
40
  def model_has_failures(model_name):
41
  """Check if a model has any failures (AMD or NVIDIA)."""
42
  if Ci_results.df is None or Ci_results.df.empty:
43
  return False
44
 
45
- # Normalize model name to match DataFrame index
46
  model_name_lower = model_name.lower()
47
 
48
- # Check if model exists in DataFrame
49
  if model_name_lower not in Ci_results.df.index:
50
  return False
51
  row = Ci_results.df.loc[model_name_lower]
52
 
53
- # Check for failures in both AMD and NVIDIA
54
  amd_multi_failures = row.get('failed_multi_no_amd', 0)
55
  amd_single_failures = row.get('failed_single_no_amd', 0)
56
  nvidia_multi_failures = row.get('failed_multi_no_nvidia', 0)
@@ -63,7 +71,6 @@ def model_has_failures(model_name):
63
  ])
64
 
65
 
66
- # Function to get current description text
67
  def get_description_text():
68
  """Get description text with integrated last update time."""
69
  msg = [
@@ -79,7 +86,6 @@ def get_description_text():
79
  msg.append("*(loading...)*")
80
  return "<br>".join(msg)
81
 
82
- # Load CSS from external file
83
  def load_css():
84
  try:
85
  with open("styles.css", "r") as f:
@@ -88,7 +94,7 @@ def load_css():
88
  return css_content
89
  except FileNotFoundError:
90
  logger.warning("styles.css not found, using minimal default styles")
91
- return "body { background: #000; color: #fff; }"
92
 
93
  js_func = """
94
  function refresh() {
@@ -101,20 +107,16 @@ function refresh() {
101
  }
102
  """
103
 
104
- # Create the Gradio interface with sidebar and dark theme
105
  with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func) as demo:
106
 
107
 
108
  with gr.Row():
109
- # Sidebar for model selection
110
  with gr.Column(scale=1, elem_classes=["sidebar"]):
111
  gr.Markdown("# 🤖 TCID", elem_classes=["sidebar-title"])
112
 
113
- # Description with integrated last update time
114
  description_text = get_description_text()
115
  description_display = gr.Markdown(description_text, elem_classes=["sidebar-description"])
116
 
117
- # Summary button (for current view)
118
  summary_button = gr.Button(
119
  "summary\n📊",
120
  variant="primary",
@@ -130,65 +132,58 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
130
  )
131
 
132
 
133
- # Model selection header (clickable toggle)
134
  model_toggle_button = gr.Button(
135
  f"► Select model ({len(Ci_results.available_models)})",
136
  variant="secondary",
137
  elem_classes=["model-header"]
138
  )
139
 
140
- # Model buttons container (collapsible) - start folded
141
  with gr.Column(elem_classes=["model-list", "model-list-hidden"]) as model_list_container:
142
- # Create individual buttons for each model
143
  model_buttons = []
144
  model_choices = [model.lower() for model in Ci_results.available_models] if Ci_results.available_models else ["auto", "bert", "clip", "llama"]
145
 
146
  print(f"Creating {len(model_choices)} model buttons: {model_choices}")
147
 
148
  for model_name in model_choices:
149
- # Check if model has failures to determine styling
150
  has_failures = model_has_failures(model_name)
151
  button_classes = ["model-button"]
 
 
152
  if has_failures:
153
  button_classes.append("model-button-failed")
 
154
 
155
  btn = gr.Button(
156
- model_name,
157
  variant="secondary",
158
  size="sm",
159
  elem_classes=button_classes
160
  )
161
  model_buttons.append(btn)
162
 
163
- # CI job links at bottom of sidebar
164
  ci_links_display = gr.Markdown("🔗 **CI Jobs:** *Loading...*", elem_classes=["sidebar-links"])
165
 
166
- # Main content area
167
  with gr.Column(scale=4, elem_classes=["main-content"]):
168
- # Current view components
169
  with gr.Column(visible=True, elem_classes=["current-view"]) as current_view:
170
- # Summary display (default view)
171
  summary_display = gr.Plot(
172
- value=create_summary_page(Ci_results.df, Ci_results.available_models),
173
  label="",
174
  format="png",
175
  elem_classes=["plot-container"],
176
  visible=True
177
  )
178
 
179
- # Detailed view components (hidden by default)
180
  with gr.Column(visible=False, elem_classes=["detail-view"]) as detail_view:
181
- # Create the plot output
182
  plot_output = gr.Plot(
183
  label="",
184
  format="png",
185
  elem_classes=["plot-container"]
186
  )
187
 
188
- # Create two separate failed tests displays in a row layout
189
  with gr.Row():
190
  with gr.Column(scale=1):
191
  amd_failed_tests_output = gr.Textbox(
 
192
  value="",
193
  lines=8,
194
  max_lines=8,
@@ -198,6 +193,7 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
198
  )
199
  with gr.Column(scale=1):
200
  nvidia_failed_tests_output = gr.Textbox(
 
201
  value="",
202
  lines=8,
203
  max_lines=8,
@@ -206,17 +202,15 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
206
  elem_classes=["failed-tests"]
207
  )
208
 
209
- # Historical view components (hidden by default)
210
  with gr.Column(visible=False, elem_classes=["historical-view"]) as historical_view:
211
 
212
 
213
- # Time-series summary displays (multiple Gradio plots)
214
  time_series_failure_rates = gr.LinePlot(
215
  label="",
216
  x="date",
217
  y="failure_rate",
218
  color="platform",
219
- color_map={"AMD": "#FF6B6B", "NVIDIA": "#4ECDC4"},
220
  title="Overall Failure Rates Over Time",
221
  tooltip=["failure_rate", "date", "change"],
222
  height=300,
@@ -230,7 +224,7 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
230
  x="date",
231
  y="count",
232
  color="test_type",
233
- color_map={"Passed": "#4CAF50", "Failed": "#E53E3E", "Skipped": "#FFA500"},
234
  title="AMD Test Results Over Time",
235
  tooltip=["count", "date", "change"],
236
  height=300,
@@ -244,7 +238,7 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
244
  x="date",
245
  y="count",
246
  color="test_type",
247
- color_map={"Passed": "#4CAF50", "Failed": "#E53E3E", "Skipped": "#FFA500"},
248
  title="NVIDIA Test Results Over Time",
249
  tooltip=["count", "date", "change"],
250
  height=300,
@@ -253,15 +247,13 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
253
  elem_classes=["plot-container"]
254
  )
255
 
256
- # Time-series model view (hidden by default)
257
  with gr.Column(visible=False, elem_classes=["time-series-detail-view"]) as time_series_detail_view:
258
- # Time-series plots for specific model (with spacing)
259
  time_series_amd_model_plot = gr.LinePlot(
260
  label="",
261
  x="date",
262
  y="count",
263
  color="test_type",
264
- color_map={"Passed": "#4CAF50", "Failed": "#E53E3E", "Skipped": "#FFA500"},
265
  title="AMD Results Over Time",
266
  tooltip=["count", "date", "change"],
267
  height=300,
@@ -275,7 +267,7 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
275
  x="date",
276
  y="count",
277
  color="test_type",
278
- color_map={"Passed": "#4CAF50", "Failed": "#E53E3E", "Skipped": "#FFA500"},
279
  title="NVIDIA Results Over Time",
280
  tooltip=["count", "date", "change"],
281
  height=300,
@@ -284,14 +276,12 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
284
  elem_classes=["plot-container"]
285
  )
286
 
287
- # Model toggle functionality
288
  def toggle_model_list(current_visible):
289
  """Toggle the visibility of the model list."""
290
  new_visible = not current_visible
291
  arrow = "▼" if new_visible else "►"
292
  button_text = f"{arrow} Select model ({len(Ci_results.available_models)})"
293
 
294
- # Use CSS classes instead of Gradio visibility
295
  css_classes = ["model-list"]
296
  if new_visible:
297
  css_classes.append("model-list-visible")
@@ -300,11 +290,8 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
300
 
301
  return gr.update(value=button_text), gr.update(elem_classes=css_classes), new_visible
302
 
303
- # Track model list visibility state
304
  model_list_visible = gr.State(False)
305
- # Track last selected model for mode switches
306
  selected_model_state = gr.State(None)
307
- # Track whether current view is model detail (True) or summary (False)
308
  in_model_view_state = gr.State(False)
309
 
310
  model_toggle_button.click(
@@ -314,7 +301,6 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
314
  )
315
 
316
 
317
- # Unified summary handler: respects History toggle
318
  def handle_summary_click(history_mode: bool):
319
  description = get_description_text()
320
  links = get_ci_links()
@@ -323,30 +309,30 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
323
  return (
324
  description,
325
  links,
326
- gr.update(visible=False), # current_view
327
- gr.update(visible=True), # historical_view
328
- gr.update(visible=False), # summary_display
329
- gr.update(visible=False), # detail_view
330
  fr_plot,
331
  amd_plot,
332
  nvidia_plot,
333
- gr.update(visible=False), # time_series_detail_view
334
- False, # in_model_view_state
335
  )
336
  else:
337
- fig = create_summary_page(Ci_results.df, Ci_results.available_models)
338
  return (
339
  description,
340
  links,
341
- gr.update(visible=True), # current_view
342
- gr.update(visible=False), # historical_view
343
- gr.update(value=fig, visible=True), # summary_display
344
- gr.update(visible=False), # detail_view
345
- gr.update(visible=False), # time_series_failure_rates
346
- gr.update(visible=False), # time_series_amd_tests
347
- gr.update(visible=False), # time_series_nvidia_tests
348
- gr.update(visible=False), # time_series_detail_view
349
- False, # in_model_view_state
350
  )
351
 
352
  summary_button.click(
@@ -367,15 +353,12 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
367
  ],
368
  )
369
 
370
- # Function to get CI job links
371
  def get_ci_links():
372
  """Get CI job links from the most recent data."""
373
  try:
374
- # Check if df exists and is not empty
375
  if Ci_results.df is None or Ci_results.df.empty:
376
  return "🔗 **CI Jobs:** *Loading...*"
377
 
378
- # Get links from any available model (they should be the same for all models in a run)
379
  amd_multi_link = None
380
  amd_single_link = None
381
  nvidia_multi_link = None
@@ -384,7 +367,6 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
384
  for model_name in Ci_results.df.index:
385
  row = Ci_results.df.loc[model_name]
386
 
387
- # Extract AMD links
388
  if pd.notna(row.get('job_link_amd')) and (not amd_multi_link or not amd_single_link):
389
  amd_link_raw = row.get('job_link_amd')
390
  if isinstance(amd_link_raw, dict):
@@ -393,7 +375,6 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
393
  if 'single' in amd_link_raw and not amd_single_link:
394
  amd_single_link = amd_link_raw['single']
395
 
396
- # Extract NVIDIA links
397
  if pd.notna(row.get('job_link_nvidia')) and (not nvidia_multi_link or not nvidia_single_link):
398
  nvidia_link_raw = row.get('job_link_nvidia')
399
  if isinstance(nvidia_link_raw, dict):
@@ -402,16 +383,13 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
402
  if 'single' in nvidia_link_raw and not nvidia_single_link:
403
  nvidia_single_link = nvidia_link_raw['single']
404
 
405
- # Break if we have all links
406
  if amd_multi_link and amd_single_link and nvidia_multi_link and nvidia_single_link:
407
  break
408
 
409
 
410
- # Add FAQ link at the bottom
411
  links_md = "❓ [**FAQ**](https://huggingface.co/spaces/transformers-community/transformers-ci-dashboard/blob/main/README.md)\n\n"
412
  links_md += "🔗 **CI Jobs:**\n\n"
413
 
414
- # AMD links
415
  if amd_multi_link or amd_single_link:
416
  links_md += "**AMD:**\n"
417
  if amd_multi_link:
@@ -420,7 +398,6 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
420
  links_md += f"• [Single GPU]({amd_single_link})\n"
421
  links_md += "\n"
422
 
423
- # NVIDIA links
424
  if nvidia_multi_link or nvidia_single_link:
425
  links_md += "**NVIDIA:**\n"
426
  if nvidia_multi_link:
@@ -437,7 +414,7 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
437
  return "🔗 **CI Jobs:** *Error loading links*\n\n❓ **[FAQ](README.md)**"
438
 
439
 
440
-
441
 
442
  def get_historical_summary_plots():
443
  """Get historical summary plots from preloaded data."""
@@ -450,80 +427,77 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
450
 
451
  def handle_history_toggle(history_mode, last_selected_model, in_model_view):
452
  if history_mode:
453
- # If currently in model view and valid model, show historical model detail
454
  if in_model_view and last_selected_model:
455
  amd_ts, nvidia_ts = show_time_series_model(last_selected_model)
456
  return (
457
- gr.update(visible=False), # current_view
458
- gr.update(visible=True), # historical_view
459
- gr.update(visible=False), # summary_display
460
- gr.update(visible=False), # detail_view
461
- gr.update(visible=False), # time_series_failure_rates
462
- gr.update(visible=False), # time_series_amd_tests
463
- gr.update(visible=False), # time_series_nvidia_tests
464
- amd_ts, # time_series_amd_model_plot
465
- nvidia_ts, # time_series_nvidia_model_plot
466
- gr.update(visible=True), # time_series_detail_view
467
- gr.update(), # plot_output
468
- gr.update(), # amd_failed_tests_output
469
- gr.update(), # nvidia_failed_tests_output
470
- True, # in_model_view_state (still in model view)
471
  )
472
- # Otherwise show historical summary
473
  fr_plot, amd_plot, nvidia_plot = get_historical_summary_plots()
474
  return (
475
- gr.update(visible=False), # current_view
476
- gr.update(visible=True), # historical_view
477
- gr.update(visible=False), # summary_display
478
- gr.update(visible=False), # detail_view
479
- fr_plot, # time_series_failure_rates (value + keep visibility)
480
- amd_plot, # time_series_amd_tests
481
- nvidia_plot, # time_series_nvidia_tests
482
- gr.update(), # time_series_amd_model_plot
483
- gr.update(), # time_series_nvidia_model_plot
484
- gr.update(visible=False), # time_series_detail_view
485
- gr.update(), # plot_output
486
- gr.update(), # amd_failed_tests_output
487
- gr.update(), # nvidia_failed_tests_output
488
- False, # in_model_view_state
489
  )
490
  else:
491
- # Switch to current mode: show model if selected; otherwise summary
492
  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:
493
- fig, amd_txt, nvidia_txt = plot_model_stats(Ci_results.df, last_selected_model)
494
  return (
495
- gr.update(visible=True), # current_view
496
- gr.update(visible=False), # historical_view
497
- gr.update(visible=False), # summary_display
498
- gr.update(visible=True), # detail_view
499
- gr.update(visible=False), # time_series_failure_rates
500
- gr.update(visible=False), # time_series_amd_tests
501
- gr.update(visible=False), # time_series_nvidia_tests
502
- gr.update(), # time_series_amd_model_plot
503
- gr.update(), # time_series_nvidia_model_plot
504
- gr.update(visible=False), # time_series_detail_view
505
- fig, # plot_output
506
- amd_txt, # amd_failed_tests_output
507
- nvidia_txt, # nvidia_failed_tests_output
508
- True, # in_model_view_state
509
  )
510
  else:
511
- fig = create_summary_page(Ci_results.df, Ci_results.available_models)
512
  return (
513
- gr.update(visible=True), # current_view
514
- gr.update(visible=False), # historical_view
515
- gr.update(value=fig, visible=True), # summary_display
516
- gr.update(visible=False), # detail_view
517
- gr.update(visible=False), # time_series_failure_rates
518
- gr.update(visible=False), # time_series_amd_tests
519
- gr.update(visible=False), # time_series_nvidia_tests
520
- gr.update(), # time_series_amd_model_plot
521
- gr.update(), # time_series_nvidia_model_plot
522
- gr.update(visible=False), # time_series_detail_view
523
- gr.update(), # plot_output
524
- gr.update(), # amd_failed_tests_output
525
- gr.update(), # nvidia_failed_tests_output
526
- False, # in_model_view_state
527
  )
528
 
529
  history_view_button.change(
@@ -548,7 +522,6 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
548
  )
549
 
550
 
551
- # Time-series model selection functionality
552
  def show_time_series_model(selected_model):
553
  """Show time-series view for a specific model."""
554
  dfs = get_model_time_series_dfs(Ci_results.historical_df, selected_model)
@@ -557,42 +530,41 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
557
  gr.update(value=dfs['nvidia_df'], visible=True, title=f"{selected_model.upper()} - NVIDIA Results Over Time"),
558
  )
559
 
560
- # Unified model click handler: respects History toggle
561
  def handle_model_click(selected_model: str, history_mode: bool):
562
  if history_mode:
563
  amd_ts, nvidia_ts = show_time_series_model(selected_model)
564
  return (
565
- gr.update(), # plot_output
566
- gr.update(), # amd_failed_tests_output
567
- gr.update(), # nvidia_failed_tests_output
568
- gr.update(visible=False), # current_view
569
- gr.update(visible=True), # historical_view
570
- gr.update(visible=False), # summary_display
571
- gr.update(visible=False), # detail_view
572
- gr.update(visible=False), # time_series_failure_rates
573
- gr.update(visible=False), # time_series_amd_tests
574
- gr.update(visible=False), # time_series_nvidia_tests
575
- amd_ts, # time_series_amd_model_plot
576
- nvidia_ts, # time_series_nvidia_model_plot
577
- gr.update(visible=True), # time_series_detail_view
578
- selected_model, True) # selected_model_state, in_model_view_state
579
  else:
580
- fig, amd_txt, nvidia_txt = plot_model_stats(Ci_results.df, selected_model)
581
  return (
582
  fig,
583
  amd_txt,
584
  nvidia_txt,
585
- gr.update(visible=True), # current_view
586
- gr.update(visible=False), # historical_view
587
- gr.update(visible=False), # summary_display
588
- gr.update(visible=True), # detail_view
589
- gr.update(), # time_series_failure_rates
590
- gr.update(), # time_series_amd_tests
591
- gr.update(), # time_series_nvidia_tests
592
- gr.update(), # time_series_amd_model_plot
593
- gr.update(), # time_series_nvidia_model_plot
594
- gr.update(visible=False), # time_series_detail_view
595
- selected_model, True) # selected_model_state, in_model_view_state
596
 
597
  for i, btn in enumerate(model_buttons):
598
  model_name = model_choices[i]
@@ -618,13 +590,11 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
618
  ],
619
  )
620
 
621
- # Auto-update CI links when the interface loads
622
  demo.load(
623
  fn=get_ci_links,
624
  outputs=[ci_links_display]
625
  )
626
 
627
 
628
- # Gradio entrypoint
629
  if __name__ == "__main__":
630
- demo.launch()
 
15
  get_model_time_series_dfs,
16
  )
17
 
18
+ COLORS = {
19
+ 'passed': '#4CAF50',
20
+ 'failed': '#E53E3E',
21
+ 'skipped': '#FFD54F',
22
+ 'error': '#8B0000',
23
+ 'amd': '#ED1C24',
24
+ 'nvidia': '#76B900',
25
+ 'background': '#0B0F19',
26
+ 'text': '#FFFFFF'
27
+ }
28
 
29
+ matplotlib.rcParams['figure.facecolor'] = COLORS['background']
30
+ matplotlib.rcParams['axes.facecolor'] = COLORS['background']
31
+ matplotlib.rcParams['savefig.facecolor'] = COLORS['background']
32
+ matplotlib.rcParams['text.color'] = COLORS['text']
33
+ matplotlib.rcParams['axes.labelcolor'] = COLORS['text']
34
+ matplotlib.rcParams['xtick.color'] = COLORS['text']
35
+ matplotlib.rcParams['ytick.color'] = COLORS['text']
36
+ matplotlib.rcParams['axes.edgecolor'] = COLORS['text']
37
+ plt.ioff()
38
 
39
 
 
40
  Ci_results = CIResults()
41
  Ci_results.load_data()
42
+
43
  if Ci_results.available_dates:
44
+ start_date_val = Ci_results.available_dates[-1]
45
+ end_date_val = Ci_results.available_dates[0]
46
  Ci_results.load_historical_data(start_date_val, end_date_val)
47
  logger.info(f"Preloaded historical data: {len(Ci_results.historical_df)} records")
 
48
  Ci_results.schedule_data_reload()
49
 
50
 
 
51
  def model_has_failures(model_name):
52
  """Check if a model has any failures (AMD or NVIDIA)."""
53
  if Ci_results.df is None or Ci_results.df.empty:
54
  return False
55
 
 
56
  model_name_lower = model_name.lower()
57
 
 
58
  if model_name_lower not in Ci_results.df.index:
59
  return False
60
  row = Ci_results.df.loc[model_name_lower]
61
 
 
62
  amd_multi_failures = row.get('failed_multi_no_amd', 0)
63
  amd_single_failures = row.get('failed_single_no_amd', 0)
64
  nvidia_multi_failures = row.get('failed_multi_no_nvidia', 0)
 
71
  ])
72
 
73
 
 
74
  def get_description_text():
75
  """Get description text with integrated last update time."""
76
  msg = [
 
86
  msg.append("*(loading...)*")
87
  return "<br>".join(msg)
88
 
 
89
  def load_css():
90
  try:
91
  with open("styles.css", "r") as f:
 
94
  return css_content
95
  except FileNotFoundError:
96
  logger.warning("styles.css not found, using minimal default styles")
97
+ return f"body {{ background: {COLORS['background']}; color: {COLORS['text']}; }}"
98
 
99
  js_func = """
100
  function refresh() {
 
107
  }
108
  """
109
 
 
110
  with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func) as demo:
111
 
112
 
113
  with gr.Row():
 
114
  with gr.Column(scale=1, elem_classes=["sidebar"]):
115
  gr.Markdown("# 🤖 TCID", elem_classes=["sidebar-title"])
116
 
 
117
  description_text = get_description_text()
118
  description_display = gr.Markdown(description_text, elem_classes=["sidebar-description"])
119
 
 
120
  summary_button = gr.Button(
121
  "summary\n📊",
122
  variant="primary",
 
132
  )
133
 
134
 
 
135
  model_toggle_button = gr.Button(
136
  f"► Select model ({len(Ci_results.available_models)})",
137
  variant="secondary",
138
  elem_classes=["model-header"]
139
  )
140
 
 
141
  with gr.Column(elem_classes=["model-list", "model-list-hidden"]) as model_list_container:
 
142
  model_buttons = []
143
  model_choices = [model.lower() for model in Ci_results.available_models] if Ci_results.available_models else ["auto", "bert", "clip", "llama"]
144
 
145
  print(f"Creating {len(model_choices)} model buttons: {model_choices}")
146
 
147
  for model_name in model_choices:
 
148
  has_failures = model_has_failures(model_name)
149
  button_classes = ["model-button"]
150
+ display_name = model_name
151
+
152
  if has_failures:
153
  button_classes.append("model-button-failed")
154
+ display_name = f"🚨 {model_name}"
155
 
156
  btn = gr.Button(
157
+ display_name,
158
  variant="secondary",
159
  size="sm",
160
  elem_classes=button_classes
161
  )
162
  model_buttons.append(btn)
163
 
 
164
  ci_links_display = gr.Markdown("🔗 **CI Jobs:** *Loading...*", elem_classes=["sidebar-links"])
165
 
 
166
  with gr.Column(scale=4, elem_classes=["main-content"]):
 
167
  with gr.Column(visible=True, elem_classes=["current-view"]) as current_view:
 
168
  summary_display = gr.Plot(
169
+ value=create_summary_page(Ci_results.df, Ci_results.available_models, COLORS=COLORS),
170
  label="",
171
  format="png",
172
  elem_classes=["plot-container"],
173
  visible=True
174
  )
175
 
 
176
  with gr.Column(visible=False, elem_classes=["detail-view"]) as detail_view:
 
177
  plot_output = gr.Plot(
178
  label="",
179
  format="png",
180
  elem_classes=["plot-container"]
181
  )
182
 
 
183
  with gr.Row():
184
  with gr.Column(scale=1):
185
  amd_failed_tests_output = gr.Textbox(
186
+ label="AMD Failed Tests",
187
  value="",
188
  lines=8,
189
  max_lines=8,
 
193
  )
194
  with gr.Column(scale=1):
195
  nvidia_failed_tests_output = gr.Textbox(
196
+ label="NVIDIA Failed Tests",
197
  value="",
198
  lines=8,
199
  max_lines=8,
 
202
  elem_classes=["failed-tests"]
203
  )
204
 
 
205
  with gr.Column(visible=False, elem_classes=["historical-view"]) as historical_view:
206
 
207
 
 
208
  time_series_failure_rates = gr.LinePlot(
209
  label="",
210
  x="date",
211
  y="failure_rate",
212
  color="platform",
213
+ color_map={"AMD": COLORS['amd'], "NVIDIA": COLORS['nvidia']},
214
  title="Overall Failure Rates Over Time",
215
  tooltip=["failure_rate", "date", "change"],
216
  height=300,
 
224
  x="date",
225
  y="count",
226
  color="test_type",
227
+ color_map={"Passed": COLORS['passed'], "Failed": COLORS['failed'], "Skipped": COLORS['skipped']},
228
  title="AMD Test Results Over Time",
229
  tooltip=["count", "date", "change"],
230
  height=300,
 
238
  x="date",
239
  y="count",
240
  color="test_type",
241
+ color_map={"Passed": COLORS['passed'], "Failed": COLORS['failed'], "Skipped": COLORS['skipped']},
242
  title="NVIDIA Test Results Over Time",
243
  tooltip=["count", "date", "change"],
244
  height=300,
 
247
  elem_classes=["plot-container"]
248
  )
249
 
 
250
  with gr.Column(visible=False, elem_classes=["time-series-detail-view"]) as time_series_detail_view:
 
251
  time_series_amd_model_plot = gr.LinePlot(
252
  label="",
253
  x="date",
254
  y="count",
255
  color="test_type",
256
+ color_map={"Passed": COLORS['passed'], "Failed": COLORS['failed'], "Skipped": COLORS['skipped']},
257
  title="AMD Results Over Time",
258
  tooltip=["count", "date", "change"],
259
  height=300,
 
267
  x="date",
268
  y="count",
269
  color="test_type",
270
+ color_map={"Passed": COLORS['passed'], "Failed": COLORS['failed'], "Skipped": COLORS['skipped']},
271
  title="NVIDIA Results Over Time",
272
  tooltip=["count", "date", "change"],
273
  height=300,
 
276
  elem_classes=["plot-container"]
277
  )
278
 
 
279
  def toggle_model_list(current_visible):
280
  """Toggle the visibility of the model list."""
281
  new_visible = not current_visible
282
  arrow = "▼" if new_visible else "►"
283
  button_text = f"{arrow} Select model ({len(Ci_results.available_models)})"
284
 
 
285
  css_classes = ["model-list"]
286
  if new_visible:
287
  css_classes.append("model-list-visible")
 
290
 
291
  return gr.update(value=button_text), gr.update(elem_classes=css_classes), new_visible
292
 
 
293
  model_list_visible = gr.State(False)
 
294
  selected_model_state = gr.State(None)
 
295
  in_model_view_state = gr.State(False)
296
 
297
  model_toggle_button.click(
 
301
  )
302
 
303
 
 
304
  def handle_summary_click(history_mode: bool):
305
  description = get_description_text()
306
  links = get_ci_links()
 
309
  return (
310
  description,
311
  links,
312
+ gr.update(visible=False),
313
+ gr.update(visible=True),
314
+ gr.update(visible=False),
315
+ gr.update(visible=False),
316
  fr_plot,
317
  amd_plot,
318
  nvidia_plot,
319
+ gr.update(visible=False),
320
+ False,
321
  )
322
  else:
323
+ fig = create_summary_page(Ci_results.df, Ci_results.available_models, COLORS=COLORS)
324
  return (
325
  description,
326
  links,
327
+ gr.update(visible=True),
328
+ gr.update(visible=False),
329
+ gr.update(value=fig, visible=True),
330
+ gr.update(visible=False),
331
+ gr.update(visible=False),
332
+ gr.update(visible=False),
333
+ gr.update(visible=False),
334
+ gr.update(visible=False),
335
+ False,
336
  )
337
 
338
  summary_button.click(
 
353
  ],
354
  )
355
 
 
356
  def get_ci_links():
357
  """Get CI job links from the most recent data."""
358
  try:
 
359
  if Ci_results.df is None or Ci_results.df.empty:
360
  return "🔗 **CI Jobs:** *Loading...*"
361
 
 
362
  amd_multi_link = None
363
  amd_single_link = None
364
  nvidia_multi_link = None
 
367
  for model_name in Ci_results.df.index:
368
  row = Ci_results.df.loc[model_name]
369
 
 
370
  if pd.notna(row.get('job_link_amd')) and (not amd_multi_link or not amd_single_link):
371
  amd_link_raw = row.get('job_link_amd')
372
  if isinstance(amd_link_raw, dict):
 
375
  if 'single' in amd_link_raw and not amd_single_link:
376
  amd_single_link = amd_link_raw['single']
377
 
 
378
  if pd.notna(row.get('job_link_nvidia')) and (not nvidia_multi_link or not nvidia_single_link):
379
  nvidia_link_raw = row.get('job_link_nvidia')
380
  if isinstance(nvidia_link_raw, dict):
 
383
  if 'single' in nvidia_link_raw and not nvidia_single_link:
384
  nvidia_single_link = nvidia_link_raw['single']
385
 
 
386
  if amd_multi_link and amd_single_link and nvidia_multi_link and nvidia_single_link:
387
  break
388
 
389
 
 
390
  links_md = "❓ [**FAQ**](https://huggingface.co/spaces/transformers-community/transformers-ci-dashboard/blob/main/README.md)\n\n"
391
  links_md += "🔗 **CI Jobs:**\n\n"
392
 
 
393
  if amd_multi_link or amd_single_link:
394
  links_md += "**AMD:**\n"
395
  if amd_multi_link:
 
398
  links_md += f"• [Single GPU]({amd_single_link})\n"
399
  links_md += "\n"
400
 
 
401
  if nvidia_multi_link or nvidia_single_link:
402
  links_md += "**NVIDIA:**\n"
403
  if nvidia_multi_link:
 
414
  return "🔗 **CI Jobs:** *Error loading links*\n\n❓ **[FAQ](README.md)**"
415
 
416
 
417
+
418
 
419
  def get_historical_summary_plots():
420
  """Get historical summary plots from preloaded data."""
 
427
 
428
  def handle_history_toggle(history_mode, last_selected_model, in_model_view):
429
  if history_mode:
 
430
  if in_model_view and last_selected_model:
431
  amd_ts, nvidia_ts = show_time_series_model(last_selected_model)
432
  return (
433
+ gr.update(visible=False),
434
+ gr.update(visible=True),
435
+ gr.update(visible=False),
436
+ gr.update(visible=False),
437
+ gr.update(visible=False),
438
+ gr.update(visible=False),
439
+ gr.update(visible=False),
440
+ amd_ts,
441
+ nvidia_ts,
442
+ gr.update(visible=True),
443
+ gr.update(),
444
+ gr.update(),
445
+ gr.update(),
446
+ True,
447
  )
 
448
  fr_plot, amd_plot, nvidia_plot = get_historical_summary_plots()
449
  return (
450
+ gr.update(visible=False),
451
+ gr.update(visible=True),
452
+ gr.update(visible=False),
453
+ gr.update(visible=False),
454
+ fr_plot,
455
+ amd_plot,
456
+ nvidia_plot,
457
+ gr.update(),
458
+ gr.update(),
459
+ gr.update(visible=False),
460
+ gr.update(),
461
+ gr.update(),
462
+ gr.update(),
463
+ False,
464
  )
465
  else:
 
466
  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:
467
+ fig, amd_txt, nvidia_txt = plot_model_stats(Ci_results.df, last_selected_model, COLORS=COLORS)
468
  return (
469
+ gr.update(visible=True),
470
+ gr.update(visible=False),
471
+ gr.update(visible=False),
472
+ gr.update(visible=True),
473
+ gr.update(visible=False),
474
+ gr.update(visible=False),
475
+ gr.update(visible=False),
476
+ gr.update(),
477
+ gr.update(),
478
+ gr.update(visible=False),
479
+ fig,
480
+ amd_txt,
481
+ nvidia_txt,
482
+ True,
483
  )
484
  else:
485
+ fig = create_summary_page(Ci_results.df, Ci_results.available_models, COLORS=COLORS)
486
  return (
487
+ gr.update(visible=True),
488
+ gr.update(visible=False),
489
+ gr.update(value=fig, visible=True),
490
+ gr.update(visible=False),
491
+ gr.update(visible=False),
492
+ gr.update(visible=False),
493
+ gr.update(visible=False),
494
+ gr.update(),
495
+ gr.update(),
496
+ gr.update(visible=False),
497
+ gr.update(),
498
+ gr.update(),
499
+ gr.update(),
500
+ False,
501
  )
502
 
503
  history_view_button.change(
 
522
  )
523
 
524
 
 
525
  def show_time_series_model(selected_model):
526
  """Show time-series view for a specific model."""
527
  dfs = get_model_time_series_dfs(Ci_results.historical_df, selected_model)
 
530
  gr.update(value=dfs['nvidia_df'], visible=True, title=f"{selected_model.upper()} - NVIDIA Results Over Time"),
531
  )
532
 
 
533
  def handle_model_click(selected_model: str, history_mode: bool):
534
  if history_mode:
535
  amd_ts, nvidia_ts = show_time_series_model(selected_model)
536
  return (
537
+ gr.update(),
538
+ gr.update(),
539
+ gr.update(),
540
+ gr.update(visible=False),
541
+ gr.update(visible=True),
542
+ gr.update(visible=False),
543
+ gr.update(visible=False),
544
+ gr.update(visible=False),
545
+ gr.update(visible=False),
546
+ gr.update(visible=False),
547
+ amd_ts,
548
+ nvidia_ts,
549
+ gr.update(visible=True),
550
+ selected_model, True)
551
  else:
552
+ fig, amd_txt, nvidia_txt = plot_model_stats(Ci_results.df, selected_model, COLORS=COLORS)
553
  return (
554
  fig,
555
  amd_txt,
556
  nvidia_txt,
557
+ gr.update(visible=True),
558
+ gr.update(visible=False),
559
+ gr.update(visible=False),
560
+ gr.update(visible=True),
561
+ gr.update(),
562
+ gr.update(),
563
+ gr.update(),
564
+ gr.update(),
565
+ gr.update(),
566
+ gr.update(visible=False),
567
+ selected_model, True)
568
 
569
  for i, btn in enumerate(model_buttons):
570
  model_name = model_choices[i]
 
590
  ],
591
  )
592
 
 
593
  demo.load(
594
  fn=get_ci_links,
595
  outputs=[ci_links_display]
596
  )
597
 
598
 
 
599
  if __name__ == "__main__":
600
+ demo.launch()