badaoui HF Staff commited on
Commit
33aeb22
·
verified ·
1 Parent(s): b057ebe

update time_series_gradio.py

Browse files
Files changed (1) hide show
  1. time_series_gradio.py +25 -53
time_series_gradio.py CHANGED
@@ -4,10 +4,16 @@ from datetime import datetime
4
  from data import extract_model_data
5
  import gradio as gr
6
 
7
- def get_time_series_summary_dfs(historical_df: pd.DataFrame) -> dict:
8
- """Return dataframes for historical summary plots (failure rates, AMD tests, NVIDIA tests)."""
 
 
 
 
 
 
9
 
10
- # Group by date to get daily statistics
11
  daily_stats = []
12
  dates = sorted(historical_df['date'].unique())
13
  for date in dates:
@@ -36,7 +42,6 @@ def get_time_series_summary_dfs(historical_df: pd.DataFrame) -> dict:
36
  'nvidia_skipped': nvidia_skipped
37
  })
38
 
39
- # Failure rate dataframe
40
  failure_rate_data = []
41
  for i, stat in enumerate(daily_stats):
42
  amd_change = stat['amd_failure_rate'] - daily_stats[i-1]['amd_failure_rate'] if i > 0 else 0
@@ -47,7 +52,6 @@ def get_time_series_summary_dfs(historical_df: pd.DataFrame) -> dict:
47
  ])
48
  failure_rate_df = pd.DataFrame(failure_rate_data)
49
 
50
- # AMD tests dataframe
51
  amd_data = []
52
  for i, stat in enumerate(daily_stats):
53
  passed_change = stat['amd_passed'] - daily_stats[i-1]['amd_passed'] if i > 0 else 0
@@ -60,7 +64,6 @@ def get_time_series_summary_dfs(historical_df: pd.DataFrame) -> dict:
60
  ])
61
  amd_df = pd.DataFrame(amd_data)
62
 
63
- # NVIDIA tests dataframe
64
  nvidia_data = []
65
  for i, stat in enumerate(daily_stats):
66
  passed_change = stat['nvidia_passed'] - daily_stats[i-1]['nvidia_passed'] if i > 0 else 0
@@ -80,7 +83,6 @@ def get_time_series_summary_dfs(historical_df: pd.DataFrame) -> dict:
80
  }
81
 
82
  def get_model_time_series_dfs(historical_df: pd.DataFrame, model_name: str) -> dict:
83
- """Return dataframes for a specific model's historical plots (AMD, NVIDIA)."""
84
  model_data = historical_df[historical_df.index.str.lower() == model_name.lower()]
85
 
86
  if model_data.empty:
@@ -125,9 +127,7 @@ def get_model_time_series_dfs(historical_df: pd.DataFrame, model_name: str) -> d
125
  return {'amd_df': pd.DataFrame(amd_data), 'nvidia_df': pd.DataFrame(nvidia_data)}
126
 
127
  def create_time_series_summary_gradio(historical_df: pd.DataFrame) -> dict:
128
- """Create time-series visualization for overall failure rates over time using Gradio native plots."""
129
  if historical_df.empty or 'date' not in historical_df.columns:
130
- # Return empty plots
131
  empty_df = pd.DataFrame({'date': [], 'failure_rate': [], 'platform': []})
132
  return {
133
  'failure_rates': gr.LinePlot(empty_df, x="date", y="failure_rate", color="platform", title="No historical data available", tooltip=["failure_rate", "date", "change"]),
@@ -135,21 +135,18 @@ def create_time_series_summary_gradio(historical_df: pd.DataFrame) -> dict:
135
  'nvidia_tests': gr.LinePlot(empty_df, x="date", y="failure_rate", color="platform", title="No historical data available", tooltip=["count", "date", "change"])
136
  }
137
 
138
- # Group by date to get daily statistics
139
  daily_stats = []
140
  dates = sorted(historical_df['date'].unique())
141
 
142
  for date in dates:
143
  date_data = historical_df[historical_df['date'] == date]
144
 
145
- # Calculate AMD stats - use the correct column names from the data structure
146
  amd_passed = date_data['success_amd'].sum() if 'success_amd' in date_data.columns else 0
147
  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
148
  amd_skipped = date_data['skipped_amd'].sum() if 'skipped_amd' in date_data.columns else 0
149
  amd_total = amd_passed + amd_failed + amd_skipped
150
  amd_failure_rate = (amd_failed / amd_total * 100) if amd_total > 0 else 0
151
 
152
- # Calculate NVIDIA stats - use the correct column names from the data structure
153
  nvidia_passed = date_data['success_nvidia'].sum() if 'success_nvidia' in date_data.columns else 0
154
  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
155
  nvidia_skipped = date_data['skipped_nvidia'].sum() if 'skipped_nvidia' in date_data.columns else 0
@@ -168,12 +165,9 @@ def create_time_series_summary_gradio(historical_df: pd.DataFrame) -> dict:
168
  'nvidia_skipped': nvidia_skipped
169
  })
170
 
171
- # Create failure rate data
172
  failure_rate_data = []
173
  for i, stat in enumerate(daily_stats):
174
- # Calculate change from previous point
175
- amd_change = 0
176
- nvidia_change = 0
177
  if i > 0:
178
  amd_change = stat['amd_failure_rate'] - daily_stats[i-1]['amd_failure_rate']
179
  nvidia_change = stat['nvidia_failure_rate'] - daily_stats[i-1]['nvidia_failure_rate']
@@ -185,13 +179,9 @@ def create_time_series_summary_gradio(historical_df: pd.DataFrame) -> dict:
185
 
186
  failure_rate_df = pd.DataFrame(failure_rate_data)
187
 
188
- # Create AMD test results data
189
  amd_data = []
190
  for i, stat in enumerate(daily_stats):
191
- # Calculate change from previous point for each test type
192
- passed_change = 0
193
- failed_change = 0
194
- skipped_change = 0
195
  if i > 0:
196
  passed_change = stat['amd_passed'] - daily_stats[i-1]['amd_passed']
197
  failed_change = stat['amd_failed'] - daily_stats[i-1]['amd_failed']
@@ -205,13 +195,9 @@ def create_time_series_summary_gradio(historical_df: pd.DataFrame) -> dict:
205
 
206
  amd_df = pd.DataFrame(amd_data)
207
 
208
- # Create NVIDIA test results data
209
  nvidia_data = []
210
  for i, stat in enumerate(daily_stats):
211
- # Calculate change from previous point for each test type
212
- passed_change = 0
213
- failed_change = 0
214
- skipped_change = 0
215
  if i > 0:
216
  passed_change = stat['nvidia_passed'] - daily_stats[i-1]['nvidia_passed']
217
  failed_change = stat['nvidia_failed'] - daily_stats[i-1]['nvidia_failed']
@@ -231,10 +217,10 @@ def create_time_series_summary_gradio(historical_df: pd.DataFrame) -> dict:
231
  x="date",
232
  y="failure_rate",
233
  color="platform",
234
- color_map={"AMD": "#FF6B6B", "NVIDIA": "#4ECDC4"},
235
  title="Overall Failure Rates Over Time",
236
  tooltip=["failure_rate", "date", "change"],
237
- height=300,
238
  x_label_angle=45,
239
  y_title="Failure Rate (%)"
240
  ),
@@ -243,10 +229,10 @@ def create_time_series_summary_gradio(historical_df: pd.DataFrame) -> dict:
243
  x="date",
244
  y="count",
245
  color="test_type",
246
- color_map={"Passed": "#4CAF50", "Failed": "#E53E3E", "Skipped": "#FFA500"},
247
  title="AMD Test Results Over Time",
248
  tooltip=["count", "date", "change"],
249
- height=300,
250
  x_label_angle=45,
251
  y_title="Number of Tests"
252
  ),
@@ -255,10 +241,10 @@ def create_time_series_summary_gradio(historical_df: pd.DataFrame) -> dict:
255
  x="date",
256
  y="count",
257
  color="test_type",
258
- color_map={"Passed": "#4CAF50", "Failed": "#E53E3E", "Skipped": "#FFA500"},
259
  title="NVIDIA Test Results Over Time",
260
  tooltip=["count", "date", "change"],
261
- height=300,
262
  x_label_angle=45,
263
  y_title="Number of Tests"
264
  )
@@ -266,27 +252,22 @@ def create_time_series_summary_gradio(historical_df: pd.DataFrame) -> dict:
266
 
267
 
268
  def create_model_time_series_gradio(historical_df: pd.DataFrame, model_name: str) -> dict:
269
- """Create time-series visualization for a specific model using Gradio native plots."""
270
  if historical_df.empty or 'date' not in historical_df.columns:
271
- # Return empty plots
272
  empty_df = pd.DataFrame({'date': [], 'count': [], 'test_type': []})
273
  return {
274
  'amd_plot': gr.LinePlot(empty_df, x="date", y="count", color="test_type", title=f"{model_name.upper()} - AMD Results Over Time", tooltip=["count", "date", "change"]),
275
  'nvidia_plot': gr.LinePlot(empty_df, x="date", y="count", color="test_type", title=f"{model_name.upper()} - NVIDIA Results Over Time", tooltip=["count", "date", "change"])
276
  }
277
 
278
- # Filter data for the specific model (model_name is the index)
279
  model_data = historical_df[historical_df.index.str.lower() == model_name.lower()]
280
 
281
  if model_data.empty:
282
- # Return empty plots
283
  empty_df = pd.DataFrame({'date': [], 'count': [], 'test_type': []})
284
  return {
285
  'amd_plot': gr.LinePlot(empty_df, x="date", y="count", color="test_type", title=f"{model_name.upper()} - AMD Results Over Time", tooltip=["count", "date", "change"]),
286
  'nvidia_plot': gr.LinePlot(empty_df, x="date", y="count", color="test_type", title=f"{model_name.upper()} - NVIDIA Results Over Time", tooltip=["count", "date", "change"])
287
  }
288
 
289
- # Group by date
290
  dates = sorted(model_data['date'].unique())
291
 
292
  amd_data = []
@@ -296,18 +277,13 @@ def create_model_time_series_gradio(historical_df: pd.DataFrame, model_name: str
296
  date_data = model_data[model_data['date'] == date]
297
 
298
  if not date_data.empty:
299
- # Get the first row for this date (should be only one)
300
  row = date_data.iloc[0]
301
 
302
- # AMD data - use the correct column names from the data structure
303
  amd_passed = row.get('success_amd', 0)
304
  amd_failed = row.get('failed_multi_no_amd', 0) + row.get('failed_single_no_amd', 0)
305
  amd_skipped = row.get('skipped_amd', 0)
306
 
307
- # Calculate change from previous point
308
- passed_change = 0
309
- failed_change = 0
310
- skipped_change = 0
311
  if i > 0:
312
  prev_date_data = model_data[model_data['date'] == dates[i-1]]
313
  if not prev_date_data.empty:
@@ -326,15 +302,11 @@ def create_model_time_series_gradio(historical_df: pd.DataFrame, model_name: str
326
  {'date': date, 'count': amd_skipped, 'test_type': 'Skipped', 'change': skipped_change}
327
  ])
328
 
329
- # NVIDIA data - use the correct column names from the data structure
330
  nvidia_passed = row.get('success_nvidia', 0)
331
  nvidia_failed = row.get('failed_multi_no_nvidia', 0) + row.get('failed_single_no_nvidia', 0)
332
  nvidia_skipped = row.get('skipped_nvidia', 0)
333
 
334
- # Calculate change from previous point for NVIDIA
335
- nvidia_passed_change = 0
336
- nvidia_failed_change = 0
337
- nvidia_skipped_change = 0
338
  if i > 0:
339
  prev_date_data = model_data[model_data['date'] == dates[i-1]]
340
  if not prev_date_data.empty:
@@ -362,11 +334,11 @@ def create_model_time_series_gradio(historical_df: pd.DataFrame, model_name: str
362
  x="date",
363
  y="count",
364
  color="test_type",
365
- color_map={"Passed": "#4CAF50", "Failed": "#E53E3E", "Skipped": "#FFA500"},
366
  title=f"{model_name.upper()} - AMD Results Over Time",
367
  x_label_angle=45,
368
  y_title="Number of Tests",
369
- height=300,
370
  tooltip=["count", "date", "change"]
371
  ),
372
  'nvidia_plot': gr.LinePlot(
@@ -374,11 +346,11 @@ def create_model_time_series_gradio(historical_df: pd.DataFrame, model_name: str
374
  x="date",
375
  y="count",
376
  color="test_type",
377
- color_map={"Passed": "#4CAF50", "Failed": "#E53E3E", "Skipped": "#FFA500"},
378
  title=f"{model_name.upper()} - NVIDIA Results Over Time",
379
  x_label_angle=45,
380
  y_title="Number of Tests",
381
- height=300,
382
  tooltip=["count", "date", "change"]
383
  )
384
- }
 
4
  from data import extract_model_data
5
  import gradio as gr
6
 
7
+ COLORS = {
8
+ 'passed': '#4CAF50',
9
+ 'failed': '#E53E3E',
10
+ 'skipped': '#FFD54F',
11
+ 'error': '#8B0000',
12
+ 'amd': '#ED1C24',
13
+ 'nvidia': '#76B900'
14
+ }
15
 
16
+ def get_time_series_summary_dfs(historical_df: pd.DataFrame) -> dict:
17
  daily_stats = []
18
  dates = sorted(historical_df['date'].unique())
19
  for date in dates:
 
42
  'nvidia_skipped': nvidia_skipped
43
  })
44
 
 
45
  failure_rate_data = []
46
  for i, stat in enumerate(daily_stats):
47
  amd_change = stat['amd_failure_rate'] - daily_stats[i-1]['amd_failure_rate'] if i > 0 else 0
 
52
  ])
53
  failure_rate_df = pd.DataFrame(failure_rate_data)
54
 
 
55
  amd_data = []
56
  for i, stat in enumerate(daily_stats):
57
  passed_change = stat['amd_passed'] - daily_stats[i-1]['amd_passed'] if i > 0 else 0
 
64
  ])
65
  amd_df = pd.DataFrame(amd_data)
66
 
 
67
  nvidia_data = []
68
  for i, stat in enumerate(daily_stats):
69
  passed_change = stat['nvidia_passed'] - daily_stats[i-1]['nvidia_passed'] if i > 0 else 0
 
83
  }
84
 
85
  def get_model_time_series_dfs(historical_df: pd.DataFrame, model_name: str) -> dict:
 
86
  model_data = historical_df[historical_df.index.str.lower() == model_name.lower()]
87
 
88
  if model_data.empty:
 
127
  return {'amd_df': pd.DataFrame(amd_data), 'nvidia_df': pd.DataFrame(nvidia_data)}
128
 
129
  def create_time_series_summary_gradio(historical_df: pd.DataFrame) -> dict:
 
130
  if historical_df.empty or 'date' not in historical_df.columns:
 
131
  empty_df = pd.DataFrame({'date': [], 'failure_rate': [], 'platform': []})
132
  return {
133
  'failure_rates': gr.LinePlot(empty_df, x="date", y="failure_rate", color="platform", title="No historical data available", tooltip=["failure_rate", "date", "change"]),
 
135
  'nvidia_tests': gr.LinePlot(empty_df, x="date", y="failure_rate", color="platform", title="No historical data available", tooltip=["count", "date", "change"])
136
  }
137
 
 
138
  daily_stats = []
139
  dates = sorted(historical_df['date'].unique())
140
 
141
  for date in dates:
142
  date_data = historical_df[historical_df['date'] == date]
143
 
 
144
  amd_passed = date_data['success_amd'].sum() if 'success_amd' in date_data.columns else 0
145
  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
146
  amd_skipped = date_data['skipped_amd'].sum() if 'skipped_amd' in date_data.columns else 0
147
  amd_total = amd_passed + amd_failed + amd_skipped
148
  amd_failure_rate = (amd_failed / amd_total * 100) if amd_total > 0 else 0
149
 
 
150
  nvidia_passed = date_data['success_nvidia'].sum() if 'success_nvidia' in date_data.columns else 0
151
  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
152
  nvidia_skipped = date_data['skipped_nvidia'].sum() if 'skipped_nvidia' in date_data.columns else 0
 
165
  'nvidia_skipped': nvidia_skipped
166
  })
167
 
 
168
  failure_rate_data = []
169
  for i, stat in enumerate(daily_stats):
170
+ amd_change = nvidia_change = 0
 
 
171
  if i > 0:
172
  amd_change = stat['amd_failure_rate'] - daily_stats[i-1]['amd_failure_rate']
173
  nvidia_change = stat['nvidia_failure_rate'] - daily_stats[i-1]['nvidia_failure_rate']
 
179
 
180
  failure_rate_df = pd.DataFrame(failure_rate_data)
181
 
 
182
  amd_data = []
183
  for i, stat in enumerate(daily_stats):
184
+ passed_change = failed_change = skipped_change = 0
 
 
 
185
  if i > 0:
186
  passed_change = stat['amd_passed'] - daily_stats[i-1]['amd_passed']
187
  failed_change = stat['amd_failed'] - daily_stats[i-1]['amd_failed']
 
195
 
196
  amd_df = pd.DataFrame(amd_data)
197
 
 
198
  nvidia_data = []
199
  for i, stat in enumerate(daily_stats):
200
+ passed_change = failed_change = skipped_change = 0
 
 
 
201
  if i > 0:
202
  passed_change = stat['nvidia_passed'] - daily_stats[i-1]['nvidia_passed']
203
  failed_change = stat['nvidia_failed'] - daily_stats[i-1]['nvidia_failed']
 
217
  x="date",
218
  y="failure_rate",
219
  color="platform",
220
+ color_map={"AMD": COLORS['amd'], "NVIDIA": COLORS['nvidia']},
221
  title="Overall Failure Rates Over Time",
222
  tooltip=["failure_rate", "date", "change"],
223
+ height=350,
224
  x_label_angle=45,
225
  y_title="Failure Rate (%)"
226
  ),
 
229
  x="date",
230
  y="count",
231
  color="test_type",
232
+ color_map={"Passed": COLORS['passed'], "Failed": COLORS['failed'], "Skipped": COLORS['skipped']},
233
  title="AMD Test Results Over Time",
234
  tooltip=["count", "date", "change"],
235
+ height=350,
236
  x_label_angle=45,
237
  y_title="Number of Tests"
238
  ),
 
241
  x="date",
242
  y="count",
243
  color="test_type",
244
+ color_map={"Passed": COLORS['passed'], "Failed": COLORS['failed'], "Skipped": COLORS['skipped']},
245
  title="NVIDIA Test Results Over Time",
246
  tooltip=["count", "date", "change"],
247
+ height=350,
248
  x_label_angle=45,
249
  y_title="Number of Tests"
250
  )
 
252
 
253
 
254
  def create_model_time_series_gradio(historical_df: pd.DataFrame, model_name: str) -> dict:
 
255
  if historical_df.empty or 'date' not in historical_df.columns:
 
256
  empty_df = pd.DataFrame({'date': [], 'count': [], 'test_type': []})
257
  return {
258
  'amd_plot': gr.LinePlot(empty_df, x="date", y="count", color="test_type", title=f"{model_name.upper()} - AMD Results Over Time", tooltip=["count", "date", "change"]),
259
  'nvidia_plot': gr.LinePlot(empty_df, x="date", y="count", color="test_type", title=f"{model_name.upper()} - NVIDIA Results Over Time", tooltip=["count", "date", "change"])
260
  }
261
 
 
262
  model_data = historical_df[historical_df.index.str.lower() == model_name.lower()]
263
 
264
  if model_data.empty:
 
265
  empty_df = pd.DataFrame({'date': [], 'count': [], 'test_type': []})
266
  return {
267
  'amd_plot': gr.LinePlot(empty_df, x="date", y="count", color="test_type", title=f"{model_name.upper()} - AMD Results Over Time", tooltip=["count", "date", "change"]),
268
  'nvidia_plot': gr.LinePlot(empty_df, x="date", y="count", color="test_type", title=f"{model_name.upper()} - NVIDIA Results Over Time", tooltip=["count", "date", "change"])
269
  }
270
 
 
271
  dates = sorted(model_data['date'].unique())
272
 
273
  amd_data = []
 
277
  date_data = model_data[model_data['date'] == date]
278
 
279
  if not date_data.empty:
 
280
  row = date_data.iloc[0]
281
 
 
282
  amd_passed = row.get('success_amd', 0)
283
  amd_failed = row.get('failed_multi_no_amd', 0) + row.get('failed_single_no_amd', 0)
284
  amd_skipped = row.get('skipped_amd', 0)
285
 
286
+ passed_change = failed_change = skipped_change = 0
 
 
 
287
  if i > 0:
288
  prev_date_data = model_data[model_data['date'] == dates[i-1]]
289
  if not prev_date_data.empty:
 
302
  {'date': date, 'count': amd_skipped, 'test_type': 'Skipped', 'change': skipped_change}
303
  ])
304
 
 
305
  nvidia_passed = row.get('success_nvidia', 0)
306
  nvidia_failed = row.get('failed_multi_no_nvidia', 0) + row.get('failed_single_no_nvidia', 0)
307
  nvidia_skipped = row.get('skipped_nvidia', 0)
308
 
309
+ nvidia_passed_change = nvidia_failed_change = nvidia_skipped_change = 0
 
 
 
310
  if i > 0:
311
  prev_date_data = model_data[model_data['date'] == dates[i-1]]
312
  if not prev_date_data.empty:
 
334
  x="date",
335
  y="count",
336
  color="test_type",
337
+ color_map={"Passed": COLORS['passed'], "Failed": COLORS['failed'], "Skipped": COLORS['skipped']},
338
  title=f"{model_name.upper()} - AMD Results Over Time",
339
  x_label_angle=45,
340
  y_title="Number of Tests",
341
+ height=350,
342
  tooltip=["count", "date", "change"]
343
  ),
344
  'nvidia_plot': gr.LinePlot(
 
346
  x="date",
347
  y="count",
348
  color="test_type",
349
+ color_map={"Passed": COLORS['passed'], "Failed": COLORS['failed'], "Skipped": COLORS['skipped']},
350
  title=f"{model_name.upper()} - NVIDIA Results Over Time",
351
  x_label_angle=45,
352
  y_title="Number of Tests",
353
+ height=350,
354
  tooltip=["count", "date", "change"]
355
  )
356
+ }