badaoui HF Staff commited on
Commit
fe59685
·
1 Parent(s): 941f5e0

some more code factorization :)

Browse files
Files changed (1) hide show
  1. time_series_gradio.py +184 -512
time_series_gradio.py CHANGED
@@ -10,539 +10,211 @@ import plotly.graph_objects as go
10
  def get_time_series_summary_dfs(historical_df: pd.DataFrame) -> dict:
11
  daily_stats = []
12
  dates = sorted(historical_df['date'].unique())
 
13
  for date in dates:
14
- date_data = historical_df[historical_df['date'] == date]
15
- amd_passed = date_data['success_amd'].sum() if 'success_amd' in date_data.columns else 0
16
- amd_failed = (date_data['failed_multi_no_amd'].sum() + date_data['failed_single_no_amd'].sum()) if 'failed_multi_no_amd' in date_data.columns else 0
17
- amd_skipped = date_data['skipped_amd'].sum() if 'skipped_amd' in date_data.columns else 0
18
- amd_total = amd_passed + amd_failed + amd_skipped
19
- amd_failure_rate = (amd_failed / amd_total * 100) if amd_total > 0 else 0
20
-
21
- nvidia_passed = date_data['success_nvidia'].sum() if 'success_nvidia' in date_data.columns else 0
22
- nvidia_failed = (date_data['failed_multi_no_nvidia'].sum() + date_data['failed_single_no_nvidia'].sum()) if 'failed_multi_no_nvidia' in date_data.columns else 0
23
- nvidia_skipped = date_data['skipped_nvidia'].sum() if 'skipped_nvidia' in date_data.columns else 0
24
- nvidia_total = nvidia_passed + nvidia_failed + nvidia_skipped
25
- nvidia_failure_rate = (nvidia_failed / nvidia_total * 100) if nvidia_total > 0 else 0
26
-
27
- daily_stats.append({
28
- 'date': date,
29
- 'amd_failure_rate': amd_failure_rate,
30
- 'nvidia_failure_rate': nvidia_failure_rate,
31
- 'amd_passed': amd_passed,
32
- 'amd_failed': amd_failed,
33
- 'amd_skipped': amd_skipped,
34
- 'nvidia_passed': nvidia_passed,
35
- 'nvidia_failed': nvidia_failed,
36
- 'nvidia_skipped': nvidia_skipped
37
- })
38
 
39
  failure_rate_data = []
40
- for i, stat in enumerate(daily_stats):
41
- amd_change = stat['amd_failure_rate'] - daily_stats[i-1]['amd_failure_rate'] if i > 0 else 0
42
- nvidia_change = stat['nvidia_failure_rate'] - daily_stats[i-1]['nvidia_failure_rate'] if i > 0 else 0
43
- failure_rate_data.extend([
44
- {'date': stat['date'], 'failure_rate': stat['amd_failure_rate'], 'platform': 'AMD', 'change': amd_change},
45
- {'date': stat['date'], 'failure_rate': stat['nvidia_failure_rate'], 'platform': 'NVIDIA', 'change': nvidia_change}
46
- ])
47
- failure_rate_df = pd.DataFrame(failure_rate_data)
48
-
49
- amd_data = []
50
- for i, stat in enumerate(daily_stats):
51
- passed_change = stat['amd_passed'] - daily_stats[i-1]['amd_passed'] if i > 0 else 0
52
- failed_change = stat['amd_failed'] - daily_stats[i-1]['amd_failed'] if i > 0 else 0
53
- skipped_change = stat['amd_skipped'] - daily_stats[i-1]['amd_skipped'] if i > 0 else 0
54
- amd_data.extend([
55
- {'date': stat['date'], 'count': stat['amd_passed'], 'test_type': 'Passed', 'change': passed_change},
56
- {'date': stat['date'], 'count': stat['amd_failed'], 'test_type': 'Failed', 'change': failed_change},
57
- {'date': stat['date'], 'count': stat['amd_skipped'], 'test_type': 'Skipped', 'change': skipped_change}
58
- ])
59
- amd_df = pd.DataFrame(amd_data)
60
 
61
- nvidia_data = []
62
- for i, stat in enumerate(daily_stats):
63
- passed_change = stat['nvidia_passed'] - daily_stats[i-1]['nvidia_passed'] if i > 0 else 0
64
- failed_change = stat['nvidia_failed'] - daily_stats[i-1]['nvidia_failed'] if i > 0 else 0
65
- skipped_change = stat['nvidia_skipped'] - daily_stats[i-1]['nvidia_skipped'] if i > 0 else 0
66
- nvidia_data.extend([
67
- {'date': stat['date'], 'count': stat['nvidia_passed'], 'test_type': 'Passed', 'change': passed_change},
68
- {'date': stat['date'], 'count': stat['nvidia_failed'], 'test_type': 'Failed', 'change': failed_change},
69
- {'date': stat['date'], 'count': stat['nvidia_skipped'], 'test_type': 'Skipped', 'change': skipped_change}
70
- ])
71
- nvidia_df = pd.DataFrame(nvidia_data)
72
 
73
- return {
74
- 'failure_rates_df': failure_rate_df,
75
- 'amd_tests_df': amd_df,
76
- 'nvidia_tests_df': nvidia_df,
77
- }
78
 
79
  def get_model_time_series_dfs(historical_df: pd.DataFrame, model_name: str) -> dict:
80
- model_data = historical_df[historical_df.index.str.lower() == model_name.lower()]
81
-
82
- if model_data.empty:
83
- empty_df = pd.DataFrame({'date': [], 'count': [], 'test_type': [], 'change': []})
84
- return {'amd_df': empty_df.copy(), 'nvidia_df': empty_df.copy()}
85
-
86
- dates = sorted(model_data['date'].unique())
87
- amd_data = []
88
- nvidia_data = []
89
- for i, date in enumerate(dates):
90
- date_data = model_data[model_data['date'] == date]
91
- row = date_data.iloc[0]
92
-
93
- amd_passed = row.get('success_amd', 0)
94
- amd_failed = row.get('failed_multi_no_amd', 0) + row.get('failed_single_no_amd', 0)
95
- amd_skipped = row.get('skipped_amd', 0)
96
- prev_row = model_data[model_data['date'] == dates[i-1]].iloc[0] if i > 0 and not model_data[model_data['date'] == dates[i-1]].empty else None
97
- amd_passed_change = amd_passed - (prev_row.get('success_amd', 0) if prev_row is not None else 0)
98
- amd_failed_change = amd_failed - (prev_row.get('failed_multi_no_amd', 0) + prev_row.get('failed_single_no_amd', 0) if prev_row is not None else 0)
99
- amd_skipped_change = amd_skipped - (prev_row.get('skipped_amd', 0) if prev_row is not None else 0)
100
- amd_data.extend([
101
- {'date': date, 'count': amd_passed, 'test_type': 'Passed', 'change': amd_passed_change},
102
- {'date': date, 'count': amd_failed, 'test_type': 'Failed', 'change': amd_failed_change},
103
- {'date': date, 'count': amd_skipped, 'test_type': 'Skipped', 'change': amd_skipped_change}
104
- ])
105
-
106
- nvidia_passed = row.get('success_nvidia', 0)
107
- nvidia_failed = row.get('failed_multi_no_nvidia', 0) + row.get('failed_single_no_nvidia', 0)
108
- nvidia_skipped = row.get('skipped_nvidia', 0)
109
- if prev_row is not None:
110
- prev_nvidia_passed = prev_row.get('success_nvidia', 0)
111
- prev_nvidia_failed = prev_row.get('failed_multi_no_nvidia', 0) + prev_row.get('failed_single_no_nvidia', 0)
112
- prev_nvidia_skipped = prev_row.get('skipped_nvidia', 0)
113
- else:
114
- prev_nvidia_passed = prev_nvidia_failed = prev_nvidia_skipped = 0
115
- nvidia_data.extend([
116
- {'date': date, 'count': nvidia_passed, 'test_type': 'Passed', 'change': nvidia_passed - prev_nvidia_passed},
117
- {'date': date, 'count': nvidia_failed, 'test_type': 'Failed', 'change': nvidia_failed - prev_nvidia_failed},
118
- {'date': date, 'count': nvidia_skipped, 'test_type': 'Skipped', 'change': nvidia_skipped - prev_nvidia_skipped}
119
- ])
120
 
121
- return {'amd_df': pd.DataFrame(amd_data), 'nvidia_df': pd.DataFrame(nvidia_data)}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
 
123
  def create_time_series_summary_gradio(historical_df: pd.DataFrame) -> dict:
 
 
 
 
124
  if historical_df.empty or 'date' not in historical_df.columns:
125
- # Create empty Plotly figure
126
- empty_fig = go.Figure()
127
- empty_fig.update_layout(
128
- title="No historical data available",
129
- height=500,
130
- font=dict(size=16, color='#CCCCCC'),
131
- paper_bgcolor='#000000',
132
- plot_bgcolor='#1a1a1a',
133
- margin=dict(b=130)
134
- )
135
- return {
136
- 'failure_rates': empty_fig,
137
- 'amd_tests': empty_fig,
138
- 'nvidia_tests': empty_fig
139
- }
140
 
141
  daily_stats = []
142
- dates = sorted(historical_df['date'].unique())
143
-
144
- for date in dates:
145
- date_data = historical_df[historical_df['date'] == date]
146
-
147
- # Calculate failure rates using the same logic as summary_page.py
148
- # This includes ERROR tests in failures and excludes SKIPPED from total
149
- total_amd_tests = 0
150
- total_amd_failures = 0
151
- total_nvidia_tests = 0
152
- total_nvidia_failures = 0
153
- amd_passed = 0
154
- amd_failed = 0
155
- amd_skipped = 0
156
- nvidia_passed = 0
157
- nvidia_failed = 0
158
- nvidia_skipped = 0
159
 
160
- for _, row in date_data.iterrows():
161
- amd_stats, nvidia_stats = extract_model_data(row)[:2]
162
-
163
- # AMD (matching summary_page.py logic: failed + error, excluding skipped)
164
- amd_total = amd_stats['passed'] + amd_stats['failed'] + amd_stats['error']
165
- if amd_total > 0:
166
- total_amd_tests += amd_total
167
- total_amd_failures += amd_stats['failed'] + amd_stats['error']
168
-
169
- # For test counts graphs (these still use the old logic with skipped)
170
- amd_passed += amd_stats['passed']
171
- amd_failed += amd_stats['failed'] + amd_stats['error']
172
- amd_skipped += amd_stats['skipped']
173
 
174
- # NVIDIA (matching summary_page.py logic: failed + error, excluding skipped)
175
- nvidia_total = nvidia_stats['passed'] + nvidia_stats['failed'] + nvidia_stats['error']
176
- if nvidia_total > 0:
177
- total_nvidia_tests += nvidia_total
178
- total_nvidia_failures += nvidia_stats['failed'] + nvidia_stats['error']
179
-
180
- # For test counts graphs (these still use the old logic with skipped)
181
- nvidia_passed += nvidia_stats['passed']
182
- nvidia_failed += nvidia_stats['failed'] + nvidia_stats['error']
183
- nvidia_skipped += nvidia_stats['skipped']
184
-
185
- amd_failure_rate = (total_amd_failures / total_amd_tests * 100) if total_amd_tests > 0 else 0
186
- nvidia_failure_rate = (total_nvidia_failures / total_nvidia_tests * 100) if total_nvidia_tests > 0 else 0
187
-
188
- daily_stats.append({
189
- 'date': date,
190
- 'amd_failure_rate': amd_failure_rate,
191
- 'nvidia_failure_rate': nvidia_failure_rate,
192
- 'amd_passed': amd_passed,
193
- 'amd_failed': amd_failed,
194
- 'amd_skipped': amd_skipped,
195
- 'nvidia_passed': nvidia_passed,
196
- 'nvidia_failed': nvidia_failed,
197
- 'nvidia_skipped': nvidia_skipped
198
- })
199
-
200
- failure_rate_data = []
201
- for i, stat in enumerate(daily_stats):
202
- amd_change = nvidia_change = 0
203
- if i > 0:
204
- amd_change = stat['amd_failure_rate'] - daily_stats[i-1]['amd_failure_rate']
205
- nvidia_change = stat['nvidia_failure_rate'] - daily_stats[i-1]['nvidia_failure_rate']
206
-
207
- failure_rate_data.extend([
208
- {'date': stat['date'], 'failure_rate': stat['amd_failure_rate'], 'platform': 'AMD', 'change': amd_change},
209
- {'date': stat['date'], 'failure_rate': stat['nvidia_failure_rate'], 'platform': 'NVIDIA', 'change': nvidia_change}
210
- ])
211
-
212
- failure_rate_df = pd.DataFrame(failure_rate_data)
213
-
214
- amd_data = []
215
- for i, stat in enumerate(daily_stats):
216
- passed_change = failed_change = skipped_change = 0
217
- if i > 0:
218
- passed_change = stat['amd_passed'] - daily_stats[i-1]['amd_passed']
219
- failed_change = stat['amd_failed'] - daily_stats[i-1]['amd_failed']
220
- skipped_change = stat['amd_skipped'] - daily_stats[i-1]['amd_skipped']
221
-
222
- amd_data.extend([
223
- {'date': stat['date'], 'count': stat['amd_passed'], 'test_type': 'Passed', 'change': passed_change},
224
- {'date': stat['date'], 'count': stat['amd_failed'], 'test_type': 'Failed', 'change': failed_change},
225
- {'date': stat['date'], 'count': stat['amd_skipped'], 'test_type': 'Skipped', 'change': skipped_change}
226
- ])
227
-
228
- amd_df = pd.DataFrame(amd_data)
229
-
230
- nvidia_data = []
231
- for i, stat in enumerate(daily_stats):
232
- passed_change = failed_change = skipped_change = 0
233
- if i > 0:
234
- passed_change = stat['nvidia_passed'] - daily_stats[i-1]['nvidia_passed']
235
- failed_change = stat['nvidia_failed'] - daily_stats[i-1]['nvidia_failed']
236
- skipped_change = stat['nvidia_skipped'] - daily_stats[i-1]['nvidia_skipped']
237
-
238
- nvidia_data.extend([
239
- {'date': stat['date'], 'count': stat['nvidia_passed'], 'test_type': 'Passed', 'change': passed_change},
240
- {'date': stat['date'], 'count': stat['nvidia_failed'], 'test_type': 'Failed', 'change': failed_change},
241
- {'date': stat['date'], 'count': stat['nvidia_skipped'], 'test_type': 'Skipped', 'change': skipped_change}
242
- ])
243
-
244
- nvidia_df = pd.DataFrame(nvidia_data)
245
-
246
- # Create Plotly figure for failure rates with alternating colors
247
- fig_failure_rates = go.Figure()
248
-
249
- # Add NVIDIA line (green line with white markers - Barcelona style)
250
- nvidia_data = failure_rate_df[failure_rate_df['platform'] == 'NVIDIA']
251
- if not nvidia_data.empty:
252
- fig_failure_rates.add_trace(go.Scatter(
253
- x=nvidia_data['date'],
254
- y=nvidia_data['failure_rate'],
255
- mode='lines+markers',
256
- name='NVIDIA',
257
- line=dict(color='#76B900', width=3), # Green line
258
- marker=dict(size=12, color='#FFFFFF', line=dict(color='#76B900', width=2)), # White markers with green border
259
- hovertemplate='<b>NVIDIA</b><br>Date: %{x}<br>Failure Rate: %{y:.2f}%<extra></extra>'
260
- ))
261
-
262
- # Add AMD line (red line with dark gray markers - Barcelona style)
263
- amd_data = failure_rate_df[failure_rate_df['platform'] == 'AMD']
264
- if not amd_data.empty:
265
- fig_failure_rates.add_trace(go.Scatter(
266
- x=amd_data['date'],
267
- y=amd_data['failure_rate'],
268
- mode='lines+markers',
269
- name='AMD',
270
- line=dict(color='#ED1C24', width=3), # Red line
271
- marker=dict(size=12, color='#404040', line=dict(color='#ED1C24', width=2)), # Dark gray markers with red border
272
- hovertemplate='<b>AMD</b><br>Date: %{x}<br>Failure Rate: %{y:.2f}%<extra></extra>'
273
- ))
274
-
275
- fig_failure_rates.update_layout(
276
- title="Overall Failure Rates Over Time",
277
- height=500,
278
- font=dict(size=16, color='#CCCCCC'),
279
- paper_bgcolor='#000000',
280
- plot_bgcolor='#1a1a1a',
281
- title_font_size=20,
282
- legend=dict(
283
- font=dict(size=16),
284
- bgcolor='rgba(0,0,0,0.5)',
285
- orientation="h",
286
- yanchor="bottom",
287
- y=-0.4,
288
- xanchor="center",
289
- x=0.5
290
- ),
291
  xaxis=dict(title='Date', title_font_size=16, tickfont_size=14, gridcolor='#333333', showgrid=True),
292
  yaxis=dict(title='Failure Rate (%)', title_font_size=16, tickfont_size=14, gridcolor='#333333', showgrid=True),
293
- hovermode='x unified',
294
- margin=dict(b=130)
295
- )
296
-
297
- # Create Plotly figure for AMD tests
298
- fig_amd = px.line(
299
- amd_df,
300
- x='date',
301
- y='count',
302
- color='test_type',
303
- color_discrete_map={"Passed": COLORS['passed'], "Failed": COLORS['failed'], "Skipped": COLORS['skipped']},
304
- title="AMD Test Results Over Time",
305
- labels={'count': 'Number of Tests', 'date': 'Date', 'test_type': 'Test Type'}
306
- )
307
- fig_amd.update_traces(mode='lines+markers', marker=dict(size=8), line=dict(width=3))
308
- fig_amd.update_layout(
309
- height=500,
310
- font=dict(size=16, color='#CCCCCC'),
311
- paper_bgcolor='#000000',
312
- plot_bgcolor='#1a1a1a',
313
- title_font_size=20,
314
- legend=dict(
315
- font=dict(size=16),
316
- bgcolor='rgba(0,0,0,0.5)',
317
- orientation="h",
318
- yanchor="bottom",
319
- y=-0.4,
320
- xanchor="center",
321
- x=0.5
322
- ),
323
- xaxis=dict(title_font_size=16, tickfont_size=14, gridcolor='#333333', showgrid=True),
324
- yaxis=dict(title_font_size=16, tickfont_size=14, gridcolor='#333333', showgrid=True),
325
- hovermode='x unified',
326
- margin=dict(b=130)
327
- )
328
-
329
- # Create Plotly figure for NVIDIA tests
330
- fig_nvidia = px.line(
331
- nvidia_df,
332
- x='date',
333
- y='count',
334
- color='test_type',
335
- color_discrete_map={"Passed": COLORS['passed'], "Failed": COLORS['failed'], "Skipped": COLORS['skipped']},
336
- title="NVIDIA Test Results Over Time",
337
- labels={'count': 'Number of Tests', 'date': 'Date', 'test_type': 'Test Type'}
338
- )
339
- fig_nvidia.update_traces(mode='lines+markers', marker=dict(size=8), line=dict(width=3))
340
- fig_nvidia.update_layout(
341
- height=500,
342
- font=dict(size=16, color='#CCCCCC'),
343
- paper_bgcolor='#000000',
344
- plot_bgcolor='#1a1a1a',
345
- title_font_size=20,
346
- legend=dict(
347
- font=dict(size=16),
348
- bgcolor='rgba(0,0,0,0.5)',
349
- orientation="h",
350
- yanchor="bottom",
351
- y=-0.4,
352
- xanchor="center",
353
- x=0.5
354
- ),
355
- xaxis=dict(title_font_size=16, tickfont_size=14, gridcolor='#333333', showgrid=True),
356
- yaxis=dict(title_font_size=16, tickfont_size=14, gridcolor='#333333', showgrid=True),
357
- hovermode='x unified',
358
- margin=dict(b=130)
359
- )
360
-
361
- return {
362
- 'failure_rates': fig_failure_rates,
363
- 'amd_tests': fig_amd,
364
- 'nvidia_tests': fig_nvidia
365
- }
366
-
367
 
368
  def create_model_time_series_gradio(historical_df: pd.DataFrame, model_name: str) -> dict:
369
- if historical_df.empty or 'date' not in historical_df.columns:
370
- # Create empty Plotly figures
371
- empty_fig_amd = go.Figure()
372
- empty_fig_amd.update_layout(
373
- title=f"{model_name.upper()} - AMD Results Over Time",
374
- height=500,
375
- font=dict(size=16, color='#CCCCCC'),
376
- paper_bgcolor='#000000',
377
- plot_bgcolor='#1a1a1a',
378
- margin=dict(b=130)
379
- )
380
- empty_fig_nvidia = go.Figure()
381
- empty_fig_nvidia.update_layout(
382
- title=f"{model_name.upper()} - NVIDIA Results Over Time",
383
- height=500,
384
- font=dict(size=16, color='#CCCCCC'),
385
- paper_bgcolor='#000000',
386
- plot_bgcolor='#1a1a1a',
387
- margin=dict(b=130)
388
- )
389
- return {
390
- 'amd_plot': empty_fig_amd,
391
- 'nvidia_plot': empty_fig_nvidia
392
- }
393
-
394
- model_data = historical_df[historical_df.index.str.lower() == model_name.lower()]
395
-
396
- if model_data.empty:
397
- # Create empty Plotly figures
398
- empty_fig_amd = go.Figure()
399
- empty_fig_amd.update_layout(
400
- title=f"{model_name.upper()} - AMD Results Over Time",
401
- height=500,
402
- font=dict(size=16, color='#CCCCCC'),
403
- paper_bgcolor='#000000',
404
- plot_bgcolor='#1a1a1a',
405
- margin=dict(b=130)
406
- )
407
- empty_fig_nvidia = go.Figure()
408
- empty_fig_nvidia.update_layout(
409
- title=f"{model_name.upper()} - NVIDIA Results Over Time",
410
- height=500,
411
- font=dict(size=16, color='#CCCCCC'),
412
- paper_bgcolor='#000000',
413
- plot_bgcolor='#1a1a1a',
414
- margin=dict(b=130)
415
- )
416
- return {
417
- 'amd_plot': empty_fig_amd,
418
- 'nvidia_plot': empty_fig_nvidia
419
- }
420
 
421
- dates = sorted(model_data['date'].unique())
422
-
423
- amd_data = []
424
- nvidia_data = []
425
-
426
- for i, date in enumerate(dates):
427
- date_data = model_data[model_data['date'] == date]
428
-
429
- if not date_data.empty:
430
- row = date_data.iloc[0]
431
-
432
- amd_passed = row.get('success_amd', 0)
433
- amd_failed = row.get('failed_multi_no_amd', 0) + row.get('failed_single_no_amd', 0)
434
- amd_skipped = row.get('skipped_amd', 0)
435
-
436
- passed_change = failed_change = skipped_change = 0
437
- if i > 0:
438
- prev_date_data = model_data[model_data['date'] == dates[i-1]]
439
- if not prev_date_data.empty:
440
- prev_row = prev_date_data.iloc[0]
441
- prev_amd_passed = prev_row.get('success_amd', 0)
442
- prev_amd_failed = prev_row.get('failed_multi_no_amd', 0) + prev_row.get('failed_single_no_amd', 0)
443
- prev_amd_skipped = prev_row.get('skipped_amd', 0)
444
-
445
- passed_change = amd_passed - prev_amd_passed
446
- failed_change = amd_failed - prev_amd_failed
447
- skipped_change = amd_skipped - prev_amd_skipped
448
-
449
- amd_data.extend([
450
- {'date': date, 'count': amd_passed, 'test_type': 'Passed', 'change': passed_change},
451
- {'date': date, 'count': amd_failed, 'test_type': 'Failed', 'change': failed_change},
452
- {'date': date, 'count': amd_skipped, 'test_type': 'Skipped', 'change': skipped_change}
453
- ])
454
-
455
- nvidia_passed = row.get('success_nvidia', 0)
456
- nvidia_failed = row.get('failed_multi_no_nvidia', 0) + row.get('failed_single_no_nvidia', 0)
457
- nvidia_skipped = row.get('skipped_nvidia', 0)
458
 
459
- nvidia_passed_change = nvidia_failed_change = nvidia_skipped_change = 0
460
  if i > 0:
461
- prev_date_data = model_data[model_data['date'] == dates[i-1]]
462
- if not prev_date_data.empty:
463
- prev_row = prev_date_data.iloc[0]
464
- prev_nvidia_passed = prev_row.get('success_nvidia', 0)
465
- prev_nvidia_failed = prev_row.get('failed_multi_no_nvidia', 0) + prev_row.get('failed_single_no_nvidia', 0)
466
- prev_nvidia_skipped = prev_row.get('skipped_nvidia', 0)
467
-
468
- nvidia_passed_change = nvidia_passed - prev_nvidia_passed
469
- nvidia_failed_change = nvidia_failed - prev_nvidia_failed
470
- nvidia_skipped_change = nvidia_skipped - prev_nvidia_skipped
471
 
472
- nvidia_data.extend([
473
- {'date': date, 'count': nvidia_passed, 'test_type': 'Passed', 'change': nvidia_passed_change},
474
- {'date': date, 'count': nvidia_failed, 'test_type': 'Failed', 'change': nvidia_failed_change},
475
- {'date': date, 'count': nvidia_skipped, 'test_type': 'Skipped', 'change': nvidia_skipped_change}
476
  ])
477
-
478
- amd_df = pd.DataFrame(amd_data)
479
- nvidia_df = pd.DataFrame(nvidia_data)
480
-
481
- # Create Plotly figure for AMD
482
- fig_amd = px.line(
483
- amd_df,
484
- x='date',
485
- y='count',
486
- color='test_type',
487
- color_discrete_map={"Passed": COLORS['passed'], "Failed": COLORS['failed'], "Skipped": COLORS['skipped']},
488
- title=f"{model_name.upper()} - AMD Results Over Time",
489
- labels={'count': 'Number of Tests', 'date': 'Date', 'test_type': 'Test Type'}
490
- )
491
- fig_amd.update_traces(mode='lines+markers', marker=dict(size=8), line=dict(width=3))
492
- fig_amd.update_layout(
493
- height=500,
494
- font=dict(size=16, color='#CCCCCC'),
495
- paper_bgcolor='#000000',
496
- plot_bgcolor='#1a1a1a',
497
- title_font_size=20,
498
- legend=dict(
499
- font=dict(size=16),
500
- bgcolor='rgba(0,0,0,0.5)',
501
- orientation="h",
502
- yanchor="bottom",
503
- y=-0.4,
504
- xanchor="center",
505
- x=0.5
506
- ),
507
- xaxis=dict(title_font_size=16, tickfont_size=14, gridcolor='#333333', showgrid=True),
508
- yaxis=dict(title_font_size=16, tickfont_size=14, gridcolor='#333333', showgrid=True),
509
- hovermode='x unified',
510
- margin=dict(b=130)
511
- )
512
-
513
- # Create Plotly figure for NVIDIA
514
- fig_nvidia = px.line(
515
- nvidia_df,
516
- x='date',
517
- y='count',
518
- color='test_type',
519
- color_discrete_map={"Passed": COLORS['passed'], "Failed": COLORS['failed'], "Skipped": COLORS['skipped']},
520
- title=f"{model_name.upper()} - NVIDIA Results Over Time",
521
- labels={'count': 'Number of Tests', 'date': 'Date', 'test_type': 'Test Type'}
522
- )
523
- fig_nvidia.update_traces(mode='lines+markers', marker=dict(size=8), line=dict(width=3))
524
- fig_nvidia.update_layout(
525
- height=500,
526
- font=dict(size=16, color='#CCCCCC'),
527
- paper_bgcolor='#000000',
528
- plot_bgcolor='#1a1a1a',
529
- title_font_size=20,
530
- legend=dict(
531
- font=dict(size=16),
532
- bgcolor='rgba(0,0,0,0.5)',
533
- orientation="h",
534
- yanchor="bottom",
535
- y=-0.4,
536
- xanchor="center",
537
- x=0.5
538
- ),
539
- xaxis=dict(title_font_size=16, tickfont_size=14, gridcolor='#333333', showgrid=True),
540
- yaxis=dict(title_font_size=16, tickfont_size=14, gridcolor='#333333', showgrid=True),
541
- hovermode='x unified',
542
- margin=dict(b=130)
543
- )
544
-
545
- return {
546
- 'amd_plot': fig_amd,
547
- 'nvidia_plot': fig_nvidia
548
- }
 
10
  def get_time_series_summary_dfs(historical_df: pd.DataFrame) -> dict:
11
  daily_stats = []
12
  dates = sorted(historical_df['date'].unique())
13
+
14
  for date in dates:
15
+ dd = historical_df[historical_df['date'] == date]
16
+ stats = {}
17
+ for platform in ['amd', 'nvidia']:
18
+ p, f, s = (dd[f'success_{platform}'].sum() if f'success_{platform}' in dd.columns else 0,
19
+ (dd[f'failed_multi_no_{platform}'].sum() + dd[f'failed_single_no_{platform}'].sum()) if f'failed_multi_no_{platform}' in dd.columns else 0,
20
+ dd[f'skipped_{platform}'].sum() if f'skipped_{platform}' in dd.columns else 0)
21
+ tot = p + f + s
22
+ stats.update({f'{platform}_passed': p, f'{platform}_failed': f, f'{platform}_skipped': s,
23
+ f'{platform}_failure_rate': (f / tot * 100) if tot > 0 else 0})
24
+ stats['date'] = date
25
+ daily_stats.append(stats)
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
  failure_rate_data = []
28
+ for i, s in enumerate(daily_stats):
29
+ for p in ['amd', 'nvidia']:
30
+ chg = s[f'{p}_failure_rate'] - daily_stats[i-1][f'{p}_failure_rate'] if i > 0 else 0
31
+ failure_rate_data.append({'date': s['date'], 'failure_rate': s[f'{p}_failure_rate'],
32
+ 'platform': p.upper(), 'change': chg})
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
+ def build_test_data(platform):
35
+ data = []
36
+ for i, s in enumerate(daily_stats):
37
+ for tt in ['passed', 'failed', 'skipped']:
38
+ chg = s[f'{platform}_{tt}'] - daily_stats[i-1][f'{platform}_{tt}'] if i > 0 else 0
39
+ data.append({'date': s['date'], 'count': s[f'{platform}_{tt}'],
40
+ 'test_type': tt.capitalize(), 'change': chg})
41
+ return pd.DataFrame(data)
 
 
 
42
 
43
+ return {'failure_rates_df': pd.DataFrame(failure_rate_data),
44
+ 'amd_tests_df': build_test_data('amd'),
45
+ 'nvidia_tests_df': build_test_data('nvidia')}
 
 
46
 
47
  def get_model_time_series_dfs(historical_df: pd.DataFrame, model_name: str) -> dict:
48
+ md = historical_df[historical_df.index.str.lower() == model_name.lower()]
49
+ if md.empty:
50
+ empty = pd.DataFrame({'date': [], 'count': [], 'test_type': [], 'change': []})
51
+ return {'amd_df': empty.copy(), 'nvidia_df': empty.copy()}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
+ dates = sorted(md['date'].unique())
54
+
55
+ def build_platform_data(platform):
56
+ data = []
57
+ for i, date in enumerate(dates):
58
+ dd = md[md['date'] == date]
59
+ if dd.empty:
60
+ continue
61
+ r = dd.iloc[0]
62
+ p = r.get(f'success_{platform}', 0)
63
+ f = r.get(f'failed_multi_no_{platform}', 0) + r.get(f'failed_single_no_{platform}', 0)
64
+ s = r.get(f'skipped_{platform}', 0)
65
+
66
+ pr = md[md['date'] == dates[i-1]].iloc[0] if i > 0 and not md[md['date'] == dates[i-1]].empty else None
67
+ pc = pr.get(f'success_{platform}', 0) if pr is not None else 0
68
+ fc = (pr.get(f'failed_multi_no_{platform}', 0) + pr.get(f'failed_single_no_{platform}', 0)) if pr is not None else 0
69
+ sc = pr.get(f'skipped_{platform}', 0) if pr is not None else 0
70
+
71
+ data.extend([
72
+ {'date': date, 'count': p, 'test_type': 'Passed', 'change': p - pc},
73
+ {'date': date, 'count': f, 'test_type': 'Failed', 'change': f - fc},
74
+ {'date': date, 'count': s, 'test_type': 'Skipped', 'change': s - sc}
75
+ ])
76
+ return pd.DataFrame(data)
77
+
78
+ return {'amd_df': build_platform_data('amd'), 'nvidia_df': build_platform_data('nvidia')}
79
 
80
  def create_time_series_summary_gradio(historical_df: pd.DataFrame) -> dict:
81
+ empty_fig = lambda title: go.Figure().update_layout(title=title, height=500,
82
+ font=dict(size=16, color='#CCCCCC'), paper_bgcolor='#000000',
83
+ plot_bgcolor='#1a1a1a', margin=dict(b=130)) or go.Figure()
84
+
85
  if historical_df.empty or 'date' not in historical_df.columns:
86
+ ef = empty_fig("No historical data available")
87
+ return {'failure_rates': ef, 'amd_tests': ef, 'nvidia_tests': ef}
 
 
 
 
 
 
 
 
 
 
 
 
 
88
 
89
  daily_stats = []
90
+ for date in sorted(historical_df['date'].unique()):
91
+ dd = historical_df[historical_df['date'] == date]
92
+ counts = {'date': date}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
 
94
+ for platform in ['amd', 'nvidia']:
95
+ tot_tests = tot_fails = p = f = s = 0
96
+ for _, row in dd.iterrows():
97
+ stats = extract_model_data(row)[0 if platform == 'amd' else 1]
98
+ tot = stats['passed'] + stats['failed'] + stats['error']
99
+ if tot > 0:
100
+ tot_tests += tot
101
+ tot_fails += stats['failed'] + stats['error']
102
+ p += stats['passed']
103
+ f += stats['failed'] + stats['error']
104
+ s += stats['skipped']
 
 
105
 
106
+ counts.update({f'{platform}_failure_rate': (tot_fails / tot_tests * 100) if tot_tests > 0 else 0,
107
+ f'{platform}_passed': p, f'{platform}_failed': f, f'{platform}_skipped': s})
108
+ daily_stats.append(counts)
109
+
110
+ fr_data = []
111
+ for i, s in enumerate(daily_stats):
112
+ for p in ['amd', 'nvidia']:
113
+ chg = s[f'{p}_failure_rate'] - daily_stats[i-1][f'{p}_failure_rate'] if i > 0 else 0
114
+ fr_data.append({'date': s['date'], 'failure_rate': s[f'{p}_failure_rate'],
115
+ 'platform': p.upper(), 'change': chg})
116
+
117
+ def build_test_data(platform):
118
+ data = []
119
+ for i, s in enumerate(daily_stats):
120
+ for tt in ['passed', 'failed', 'skipped']:
121
+ chg = s[f'{platform}_{tt}'] - daily_stats[i-1][f'{platform}_{tt}'] if i > 0 else 0
122
+ data.append({'date': s['date'], 'count': s[f'{platform}_{tt}'],
123
+ 'test_type': tt.capitalize(), 'change': chg})
124
+ return pd.DataFrame(data)
125
+
126
+ fr_df = pd.DataFrame(fr_data)
127
+
128
+ fig_fr = go.Figure()
129
+ for p, lc, mc in [('NVIDIA', '#76B900', '#FFFFFF'), ('AMD', '#ED1C24', '#404040')]:
130
+ d = fr_df[fr_df['platform'] == p]
131
+ if not d.empty:
132
+ fig_fr.add_trace(go.Scatter(x=d['date'], y=d['failure_rate'], mode='lines+markers',
133
+ name=p, line=dict(color=lc, width=3),
134
+ marker=dict(size=12, color=mc, line=dict(color=lc, width=2)),
135
+ hovertemplate=f'<b>{p}</b><br>Date: %{{x}}<br>Failure Rate: %{{y:.2f}}%<extra></extra>'))
136
+
137
+ fig_fr.update_layout(title="Overall Failure Rates Over Time", height=500,
138
+ font=dict(size=16, color='#CCCCCC'), paper_bgcolor='#000000', plot_bgcolor='#1a1a1a',
139
+ title_font_size=20, legend=dict(font=dict(size=16), bgcolor='rgba(0,0,0,0.5)',
140
+ orientation="h", yanchor="bottom", y=-0.4, xanchor="center", x=0.5),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  xaxis=dict(title='Date', title_font_size=16, tickfont_size=14, gridcolor='#333333', showgrid=True),
142
  yaxis=dict(title='Failure Rate (%)', title_font_size=16, tickfont_size=14, gridcolor='#333333', showgrid=True),
143
+ hovermode='x unified', margin=dict(b=130))
144
+
145
+ def create_line_fig(df, title):
146
+ fig = px.line(df, x='date', y='count', color='test_type',
147
+ color_discrete_map={"Passed": COLORS['passed'], "Failed": COLORS['failed'], "Skipped": COLORS['skipped']},
148
+ title=title, labels={'count': 'Number of Tests', 'date': 'Date', 'test_type': 'Test Type'})
149
+ fig.update_traces(mode='lines+markers', marker=dict(size=8), line=dict(width=3))
150
+ fig.update_layout(height=500, font=dict(size=16, color='#CCCCCC'), paper_bgcolor='#000000',
151
+ plot_bgcolor='#1a1a1a', title_font_size=20, legend=dict(font=dict(size=16),
152
+ bgcolor='rgba(0,0,0,0.5)', orientation="h", yanchor="bottom", y=-0.4, xanchor="center", x=0.5),
153
+ xaxis=dict(title_font_size=16, tickfont_size=14, gridcolor='#333333', showgrid=True),
154
+ yaxis=dict(title_font_size=16, tickfont_size=14, gridcolor='#333333', showgrid=True),
155
+ hovermode='x unified', margin=dict(b=130))
156
+ return fig
157
+
158
+ return {'failure_rates': fig_fr,
159
+ 'amd_tests': create_line_fig(build_test_data('amd'), "AMD Test Results Over Time"),
160
+ 'nvidia_tests': create_line_fig(build_test_data('nvidia'), "NVIDIA Test Results Over Time")}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
 
162
  def create_model_time_series_gradio(historical_df: pd.DataFrame, model_name: str) -> dict:
163
+ def empty_figs():
164
+ ef = lambda plat: go.Figure().update_layout(title=f"{model_name.upper()} - {plat} Results Over Time",
165
+ height=500, font=dict(size=16, color='#CCCCCC'), paper_bgcolor='#000000',
166
+ plot_bgcolor='#1a1a1a', margin=dict(b=130)) or go.Figure()
167
+ return {'amd_plot': ef('AMD'), 'nvidia_plot': ef('NVIDIA')}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
 
169
+ if historical_df.empty or 'date' not in historical_df.columns:
170
+ return empty_figs()
171
+
172
+ md = historical_df[historical_df.index.str.lower() == model_name.lower()]
173
+ if md.empty:
174
+ return empty_figs()
175
+
176
+ dates = sorted(md['date'].unique())
177
+
178
+ def build_data(platform):
179
+ data = []
180
+ for i, date in enumerate(dates):
181
+ dd = md[md['date'] == date]
182
+ if dd.empty:
183
+ continue
184
+ r = dd.iloc[0]
185
+ passed = r.get(f'success_{platform}', 0)
186
+ failed = r.get(f'failed_multi_no_{platform}', 0) + r.get(f'failed_single_no_{platform}', 0)
187
+ skipped = r.get(f'skipped_{platform}', 0)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
 
189
+ pc = fc = sc = 0
190
  if i > 0:
191
+ prev_dd = md[md['date'] == dates[i-1]]
192
+ if not prev_dd.empty:
193
+ pr = prev_dd.iloc[0]
194
+ pc = pr.get(f'success_{platform}', 0)
195
+ fc = pr.get(f'failed_multi_no_{platform}', 0) + pr.get(f'failed_single_no_{platform}', 0)
196
+ sc = pr.get(f'skipped_{platform}', 0)
 
 
 
 
197
 
198
+ data.extend([
199
+ {'date': date, 'count': passed, 'test_type': 'Passed', 'change': passed - pc},
200
+ {'date': date, 'count': failed, 'test_type': 'Failed', 'change': failed - fc},
201
+ {'date': date, 'count': skipped, 'test_type': 'Skipped', 'change': skipped - sc}
202
  ])
203
+ return pd.DataFrame(data)
204
+
205
+ def create_fig(df, platform):
206
+ fig = px.line(df, x='date', y='count', color='test_type',
207
+ color_discrete_map={"Passed": COLORS['passed'], "Failed": COLORS['failed'], "Skipped": COLORS['skipped']},
208
+ title=f"{model_name.upper()} - {platform} Results Over Time",
209
+ labels={'count': 'Number of Tests', 'date': 'Date', 'test_type': 'Test Type'})
210
+ fig.update_traces(mode='lines+markers', marker=dict(size=8), line=dict(width=3))
211
+ fig.update_layout(height=500, font=dict(size=16, color='#CCCCCC'), paper_bgcolor='#000000',
212
+ plot_bgcolor='#1a1a1a', title_font_size=20, legend=dict(font=dict(size=16),
213
+ bgcolor='rgba(0,0,0,0.5)', orientation="h", yanchor="bottom", y=-0.4, xanchor="center", x=0.5),
214
+ xaxis=dict(title_font_size=16, tickfont_size=14, gridcolor='#333333', showgrid=True),
215
+ yaxis=dict(title_font_size=16, tickfont_size=14, gridcolor='#333333', showgrid=True),
216
+ hovermode='x unified', margin=dict(b=130))
217
+ return fig
218
+
219
+ return {'amd_plot': create_fig(build_data('amd'), 'AMD'),
220
+ 'nvidia_plot': create_fig(build_data('nvidia'), 'NVIDIA')}