badaoui HF Staff commited on
Commit
8c29cbd
·
verified ·
1 Parent(s): e4e6ce0

use different colors

Browse files
Files changed (1) hide show
  1. app.py +171 -131
app.py CHANGED
@@ -15,50 +15,42 @@ from time_series_gradio import (
15
  get_model_time_series_dfs,
16
  )
17
 
18
- COLORS = {
19
- 'passed': '#4CAF50',
20
- 'failed': '#E53E3E',
21
- 'skipped': '#FFD54F',
22
- 'error': '#8B0000',
23
- 'amd': '#FF6B6B',
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,6 +63,7 @@ def model_has_failures(model_name):
71
  ])
72
 
73
 
 
74
  def get_description_text():
75
  """Get description text with integrated last update time."""
76
  msg = [
@@ -86,6 +79,7 @@ def get_description_text():
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,7 +88,7 @@ def load_css():
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,16 +101,20 @@ 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,85 +130,99 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
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
 
155
  btn = gr.Button(
156
- display_name,
157
  variant="secondary",
158
  size="sm",
159
  elem_classes=button_classes
160
  )
161
  model_buttons.append(btn)
162
 
 
163
  ci_links_display = gr.Markdown("🔗 **CI Jobs:** *Loading...*", elem_classes=["sidebar-links"])
164
 
 
165
  with gr.Column(scale=4, elem_classes=["main-content"]):
 
166
  with gr.Column(visible=True, elem_classes=["current-view"]) as current_view:
 
167
  summary_display = gr.Plot(
168
  value=create_summary_page(Ci_results.df, Ci_results.available_models),
169
  label="",
170
  format="png",
 
171
  visible=True
172
  )
173
 
 
174
  with gr.Column(visible=False, elem_classes=["detail-view"]) as detail_view:
 
175
  plot_output = gr.Plot(
176
  label="",
177
  format="png",
 
178
  )
179
 
 
180
  with gr.Row():
181
  with gr.Column(scale=1):
182
  amd_failed_tests_output = gr.Textbox(
183
- label="AMD Failed Tests",
184
  value="",
185
  lines=8,
186
  max_lines=8,
187
  interactive=False,
188
  container=False,
 
189
  )
190
  with gr.Column(scale=1):
191
  nvidia_failed_tests_output = gr.Textbox(
192
- label="NVIDIA Failed Tests",
193
  value="",
194
  lines=8,
195
  max_lines=8,
196
  interactive=False,
197
  container=False,
 
198
  )
199
 
 
200
  with gr.Column(visible=False, elem_classes=["historical-view"]) as historical_view:
201
 
202
 
 
203
  time_series_failure_rates = gr.LinePlot(
204
  label="",
205
  x="date",
206
  y="failure_rate",
207
  color="platform",
208
- color_map={"AMD": COLORS['amd'], "NVIDIA": COLORS['nvidia']},
209
  title="Overall Failure Rates Over Time",
210
  tooltip=["failure_rate", "date", "change"],
211
  height=300,
212
  x_label_angle=45,
213
  y_title="Failure Rate (%)",
 
214
  )
215
 
216
  time_series_amd_tests = gr.LinePlot(
@@ -218,12 +230,13 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
218
  x="date",
219
  y="count",
220
  color="test_type",
221
- color_map={"Passed": COLORS['passed'], "Failed": COLORS['failed'], "Skipped": COLORS['skipped']},
222
  title="AMD Test Results Over Time",
223
  tooltip=["count", "date", "change"],
224
  height=300,
225
  x_label_angle=45,
226
  y_title="Number of Tests",
 
227
  )
228
 
229
  time_series_nvidia_tests = gr.LinePlot(
@@ -231,26 +244,30 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
231
  x="date",
232
  y="count",
233
  color="test_type",
234
- color_map={"Passed": COLORS['passed'], "Failed": COLORS['failed'], "Skipped": COLORS['skipped']},
235
  title="NVIDIA Test Results Over Time",
236
  tooltip=["count", "date", "change"],
237
  height=300,
238
  x_label_angle=45,
239
  y_title="Number of Tests",
 
240
  )
241
 
 
242
  with gr.Column(visible=False, elem_classes=["time-series-detail-view"]) as time_series_detail_view:
 
243
  time_series_amd_model_plot = gr.LinePlot(
244
  label="",
245
  x="date",
246
  y="count",
247
  color="test_type",
248
- color_map={"Passed": COLORS['passed'], "Failed": COLORS['failed'], "Skipped": COLORS['skipped']},
249
  title="AMD Results Over Time",
250
  tooltip=["count", "date", "change"],
251
  height=300,
252
  x_label_angle=45,
253
  y_title="Number of Tests",
 
254
  )
255
 
256
  time_series_nvidia_model_plot = gr.LinePlot(
@@ -258,20 +275,23 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
258
  x="date",
259
  y="count",
260
  color="test_type",
261
- color_map={"Passed": COLORS['passed'], "Failed": COLORS['failed'], "Skipped": COLORS['skipped']},
262
  title="NVIDIA Results Over Time",
263
  tooltip=["count", "date", "change"],
264
  height=300,
265
  x_label_angle=45,
266
  y_title="Number of Tests",
 
267
  )
268
 
 
269
  def toggle_model_list(current_visible):
270
  """Toggle the visibility of the model list."""
271
  new_visible = not current_visible
272
  arrow = "▼" if new_visible else "►"
273
  button_text = f"{arrow} Select model ({len(Ci_results.available_models)})"
274
 
 
275
  css_classes = ["model-list"]
276
  if new_visible:
277
  css_classes.append("model-list-visible")
@@ -280,8 +300,11 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
280
 
281
  return gr.update(value=button_text), gr.update(elem_classes=css_classes), new_visible
282
 
 
283
  model_list_visible = gr.State(False)
 
284
  selected_model_state = gr.State(None)
 
285
  in_model_view_state = gr.State(False)
286
 
287
  model_toggle_button.click(
@@ -291,6 +314,7 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
291
  )
292
 
293
 
 
294
  def handle_summary_click(history_mode: bool):
295
  description = get_description_text()
296
  links = get_ci_links()
@@ -299,30 +323,30 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
299
  return (
300
  description,
301
  links,
302
- gr.update(visible=False),
303
- gr.update(visible=True),
304
- gr.update(visible=False),
305
- gr.update(visible=False),
306
  fr_plot,
307
  amd_plot,
308
  nvidia_plot,
309
- gr.update(visible=False),
310
- False,
311
  )
312
  else:
313
  fig = create_summary_page(Ci_results.df, Ci_results.available_models)
314
  return (
315
  description,
316
  links,
317
- gr.update(visible=True),
318
- gr.update(visible=False),
319
- gr.update(value=fig, visible=True),
320
- gr.update(visible=False),
321
- gr.update(visible=False),
322
- gr.update(visible=False),
323
- gr.update(visible=False),
324
- gr.update(visible=False),
325
- False,
326
  )
327
 
328
  summary_button.click(
@@ -343,12 +367,15 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
343
  ],
344
  )
345
 
 
346
  def get_ci_links():
347
  """Get CI job links from the most recent data."""
348
  try:
 
349
  if Ci_results.df is None or Ci_results.df.empty:
350
  return "🔗 **CI Jobs:** *Loading...*"
351
 
 
352
  amd_multi_link = None
353
  amd_single_link = None
354
  nvidia_multi_link = None
@@ -357,6 +384,7 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
357
  for model_name in Ci_results.df.index:
358
  row = Ci_results.df.loc[model_name]
359
 
 
360
  if pd.notna(row.get('job_link_amd')) and (not amd_multi_link or not amd_single_link):
361
  amd_link_raw = row.get('job_link_amd')
362
  if isinstance(amd_link_raw, dict):
@@ -365,6 +393,7 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
365
  if 'single' in amd_link_raw and not amd_single_link:
366
  amd_single_link = amd_link_raw['single']
367
 
 
368
  if pd.notna(row.get('job_link_nvidia')) and (not nvidia_multi_link or not nvidia_single_link):
369
  nvidia_link_raw = row.get('job_link_nvidia')
370
  if isinstance(nvidia_link_raw, dict):
@@ -373,13 +402,16 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
373
  if 'single' in nvidia_link_raw and not nvidia_single_link:
374
  nvidia_single_link = nvidia_link_raw['single']
375
 
 
376
  if amd_multi_link and amd_single_link and nvidia_multi_link and nvidia_single_link:
377
  break
378
 
379
 
 
380
  links_md = "❓ [**FAQ**](https://huggingface.co/spaces/transformers-community/transformers-ci-dashboard/blob/main/README.md)\n\n"
381
  links_md += "🔗 **CI Jobs:**\n\n"
382
 
 
383
  if amd_multi_link or amd_single_link:
384
  links_md += "**AMD:**\n"
385
  if amd_multi_link:
@@ -388,6 +420,7 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
388
  links_md += f"• [Single GPU]({amd_single_link})\n"
389
  links_md += "\n"
390
 
 
391
  if nvidia_multi_link or nvidia_single_link:
392
  links_md += "**NVIDIA:**\n"
393
  if nvidia_multi_link:
@@ -404,7 +437,7 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
404
  return "🔗 **CI Jobs:** *Error loading links*\n\n❓ **[FAQ](README.md)**"
405
 
406
 
407
-
408
 
409
  def get_historical_summary_plots():
410
  """Get historical summary plots from preloaded data."""
@@ -417,77 +450,80 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
417
 
418
  def handle_history_toggle(history_mode, last_selected_model, in_model_view):
419
  if history_mode:
 
420
  if in_model_view and last_selected_model:
421
  amd_ts, nvidia_ts = show_time_series_model(last_selected_model)
422
  return (
423
- gr.update(visible=False),
424
- gr.update(visible=True),
425
- gr.update(visible=False),
426
- gr.update(visible=False),
427
- gr.update(visible=False),
428
- gr.update(visible=False),
429
- gr.update(visible=False),
430
- amd_ts,
431
- nvidia_ts,
432
- gr.update(visible=True),
433
- gr.update(),
434
- gr.update(),
435
- gr.update(),
436
- True,
437
  )
 
438
  fr_plot, amd_plot, nvidia_plot = get_historical_summary_plots()
439
  return (
440
- gr.update(visible=False),
441
- gr.update(visible=True),
442
- gr.update(visible=False),
443
- gr.update(visible=False),
444
- fr_plot,
445
- amd_plot,
446
- nvidia_plot,
447
- gr.update(),
448
- gr.update(),
449
- gr.update(visible=False),
450
- gr.update(),
451
- gr.update(),
452
- gr.update(),
453
- False,
454
  )
455
  else:
 
456
  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:
457
  fig, amd_txt, nvidia_txt = plot_model_stats(Ci_results.df, last_selected_model)
458
  return (
459
- gr.update(visible=True),
460
- gr.update(visible=False),
461
- gr.update(visible=False),
462
- gr.update(visible=True),
463
- gr.update(visible=False),
464
- gr.update(visible=False),
465
- gr.update(visible=False),
466
- gr.update(),
467
- gr.update(),
468
- gr.update(visible=False),
469
- fig,
470
- amd_txt,
471
- nvidia_txt,
472
- True,
473
  )
474
  else:
475
  fig = create_summary_page(Ci_results.df, Ci_results.available_models)
476
  return (
477
- gr.update(visible=True),
478
- gr.update(visible=False),
479
- gr.update(value=fig, visible=True),
480
- gr.update(visible=False),
481
- gr.update(visible=False),
482
- gr.update(visible=False),
483
- gr.update(visible=False),
484
- gr.update(),
485
- gr.update(),
486
- gr.update(visible=False),
487
- gr.update(),
488
- gr.update(),
489
- gr.update(),
490
- False,
491
  )
492
 
493
  history_view_button.change(
@@ -512,6 +548,7 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
512
  )
513
 
514
 
 
515
  def show_time_series_model(selected_model):
516
  """Show time-series view for a specific model."""
517
  dfs = get_model_time_series_dfs(Ci_results.historical_df, selected_model)
@@ -520,41 +557,42 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
520
  gr.update(value=dfs['nvidia_df'], visible=True, title=f"{selected_model.upper()} - NVIDIA Results Over Time"),
521
  )
522
 
 
523
  def handle_model_click(selected_model: str, history_mode: bool):
524
  if history_mode:
525
  amd_ts, nvidia_ts = show_time_series_model(selected_model)
526
  return (
527
- gr.update(),
528
- gr.update(),
529
- gr.update(),
530
- gr.update(visible=False),
531
- gr.update(visible=True),
532
- gr.update(visible=False),
533
- gr.update(visible=False),
534
- gr.update(visible=False),
535
- gr.update(visible=False),
536
- gr.update(visible=False),
537
- amd_ts,
538
- nvidia_ts,
539
- gr.update(visible=True),
540
- selected_model, True)
541
  else:
542
  fig, amd_txt, nvidia_txt = plot_model_stats(Ci_results.df, selected_model)
543
  return (
544
  fig,
545
  amd_txt,
546
  nvidia_txt,
547
- gr.update(visible=True),
548
- gr.update(visible=False),
549
- gr.update(visible=False),
550
- gr.update(visible=True),
551
- gr.update(),
552
- gr.update(),
553
- gr.update(),
554
- gr.update(),
555
- gr.update(),
556
- gr.update(visible=False),
557
- selected_model, True)
558
 
559
  for i, btn in enumerate(model_buttons):
560
  model_name = model_choices[i]
@@ -580,11 +618,13 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css(), js=js_func)
580
  ],
581
  )
582
 
 
583
  demo.load(
584
  fn=get_ci_links,
585
  outputs=[ci_links_display]
586
  )
587
 
588
 
 
589
  if __name__ == "__main__":
590
- demo.launch()
 
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
  ])
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
  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
  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
  }
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
  )
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,
195
  interactive=False,
196
  container=False,
197
+ elem_classes=["failed-tests"]
198
  )
199
  with gr.Column(scale=1):
200
  nvidia_failed_tests_output = gr.Textbox(
 
201
  value="",
202
  lines=8,
203
  max_lines=8,
204
  interactive=False,
205
  container=False,
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": "#76B900"},
220
  title="Overall Failure Rates Over Time",
221
  tooltip=["failure_rate", "date", "change"],
222
  height=300,
223
  x_label_angle=45,
224
  y_title="Failure Rate (%)",
225
+ elem_classes=["plot-container"]
226
  )
227
 
228
  time_series_amd_tests = gr.LinePlot(
 
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,
237
  x_label_angle=45,
238
  y_title="Number of Tests",
239
+ elem_classes=["plot-container"]
240
  )
241
 
242
  time_series_nvidia_tests = gr.LinePlot(
 
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,
251
  x_label_angle=45,
252
  y_title="Number of Tests",
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,
268
  x_label_angle=45,
269
  y_title="Number of Tests",
270
+ elem_classes=["plot-container"]
271
  )
272
 
273
  time_series_nvidia_model_plot = gr.LinePlot(
 
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,
282
  x_label_angle=45,
283
  y_title="Number of Tests",
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
 
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
  )
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
  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
  ],
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
  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
  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
  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
  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
  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
 
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
  )
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
  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
  ],
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()