badaoui HF Staff commited on
Commit
51d01ef
·
1 Parent(s): 236e825

summary_page.py

Browse files
Files changed (1) hide show
  1. summary_page.py +12 -44
summary_page.py CHANGED
@@ -1,6 +1,5 @@
1
  import matplotlib.pyplot as plt
2
  import pandas as pd
3
- from matplotlib.patches import FancyBboxPatch
4
  from data import extract_model_data
5
 
6
  # Layout parameters
@@ -38,9 +37,6 @@ LABEL_FONT_SIZE = 14
38
  LABEL_OFFSET = 1
39
  FAILURE_RATE_FONT_SIZE = 28
40
 
41
- # Label box settings (for text labels)
42
- LOGO_BOX_WIDTH = 4.5
43
- LOGO_BOX_HEIGHT = 0.43
44
 
45
 
46
  def calculate_overall_failure_rates(df: pd.DataFrame, available_models: list[str]) -> tuple[float, float]:
@@ -78,7 +74,7 @@ def calculate_overall_failure_rates(df: pd.DataFrame, available_models: list[str
78
  return amd_failure_rate, nvidia_failure_rate
79
 
80
 
81
- def draw_logo_and_bar(
82
  label: str,
83
  stats: dict[str, int],
84
  y_bar: float,
@@ -86,46 +82,19 @@ def draw_logo_and_bar(
86
  bar_height: float,
87
  ax: plt.Axes,
88
  ) -> None:
89
- """Draw a horizontal bar chart for given stats with a logo box on the left."""
90
- # Determine if there are failures
 
91
  failures_present = any(stats[category] > 0 for category in ['failed', 'error'])
92
-
93
- # Calculate box position (centered on the bar vertically)
94
- box_x = column_left_position - LABEL_OFFSET - LOGO_BOX_WIDTH
95
- box_y = y_bar - LOGO_BOX_HEIGHT / 2
96
-
97
- # Draw the colored box
98
  if failures_present:
99
- box_color = COLORS['failed'] # Red for failures
100
- box_alpha = 0.6
101
  else:
102
- box_color = '#2a2a2a' # Dark gray for no failures
103
- box_alpha = 0.5
104
-
105
- box = FancyBboxPatch(
106
- (box_x, box_y),
107
- LOGO_BOX_WIDTH,
108
- LOGO_BOX_HEIGHT,
109
- boxstyle="round,pad=0.05",
110
- facecolor=box_color,
111
- edgecolor='#444444',
112
- linewidth=1,
113
- alpha=box_alpha
114
- )
115
- ax.add_patch(box)
116
-
117
- # Add text label in the box
118
  ax.text(
119
- box_x + LOGO_BOX_WIDTH / 2, y_bar,
120
- label.upper(),
121
- ha='center', va='center',
122
- color='#FFFFFF',
123
- fontsize=10,
124
- fontfamily='monospace',
125
- fontweight='bold'
126
  )
127
-
128
- # Draw the bar
129
  total = sum(stats.values())
130
  if total > 0:
131
  left = column_left_position
@@ -217,10 +186,9 @@ def create_summary_page(df: pd.DataFrame, available_models: list[str]) -> plt.Fi
217
 
218
  # AMD label and bar in this column
219
  bar_height = min(0.4, vertical_spacing * BAR_HEIGHT_RATIO)
220
- # Draw AMD bar with logo
221
- draw_logo_and_bar("amd", amd_stats, y_amd_bar, col_left, bar_height, ax)
222
- # Draw NVIDIA bar with logo
223
- draw_logo_and_bar("nvidia", nvidia_stats, y_nvidia_bar, col_left, bar_height, ax)
224
 
225
  # Increment counter for next visible model
226
  visible_model_count += 1
 
1
  import matplotlib.pyplot as plt
2
  import pandas as pd
 
3
  from data import extract_model_data
4
 
5
  # Layout parameters
 
37
  LABEL_OFFSET = 1
38
  FAILURE_RATE_FONT_SIZE = 28
39
 
 
 
 
40
 
41
 
42
  def calculate_overall_failure_rates(df: pd.DataFrame, available_models: list[str]) -> tuple[float, float]:
 
74
  return amd_failure_rate, nvidia_failure_rate
75
 
76
 
77
+ def draw_text_and_bar(
78
  label: str,
79
  stats: dict[str, int],
80
  y_bar: float,
 
82
  bar_height: float,
83
  ax: plt.Axes,
84
  ) -> None:
85
+ """Draw a horizontal bar chart for given stats and its label on the left."""
86
+ # Text
87
+ label_x = column_left_position - LABEL_OFFSET
88
  failures_present = any(stats[category] > 0 for category in ['failed', 'error'])
 
 
 
 
 
 
89
  if failures_present:
90
+ props = dict(boxstyle='round', facecolor=COLORS['failed'], alpha=0.35)
 
91
  else:
92
+ props = dict(alpha=0)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  ax.text(
94
+ label_x, y_bar, label, ha='right', va='center', color='#CCCCCC', fontsize=LABEL_FONT_SIZE,
95
+ fontfamily='monospace', fontweight='normal', bbox=props
 
 
 
 
 
96
  )
97
+ # Bar
 
98
  total = sum(stats.values())
99
  if total > 0:
100
  left = column_left_position
 
186
 
187
  # AMD label and bar in this column
188
  bar_height = min(0.4, vertical_spacing * BAR_HEIGHT_RATIO)
189
+ draw_text_and_bar("amd", amd_stats, y_amd_bar, col_left, bar_height, ax)
190
+
191
+ draw_text_and_bar("nvidia", nvidia_stats, y_nvidia_bar, col_left, bar_height, ax)
 
192
 
193
  # Increment counter for next visible model
194
  visible_model_count += 1