some styling
Browse files- logos/amd_logo.png +0 -0
- logos/nvidia_logo.png +0 -0
- summary_page.py +87 -14
logos/amd_logo.png
ADDED
|
logos/nvidia_logo.png
ADDED
|
summary_page.py
CHANGED
|
@@ -1,5 +1,9 @@
|
|
| 1 |
import matplotlib.pyplot as plt
|
| 2 |
import pandas as pd
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
from data import extract_model_data
|
| 4 |
|
| 5 |
# Layout parameters
|
|
@@ -37,6 +41,22 @@ LABEL_FONT_SIZE = 14
|
|
| 37 |
LABEL_OFFSET = 1 # Distance of label from bar
|
| 38 |
FAILURE_RATE_FONT_SIZE = 28
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
def calculate_overall_failure_rates(df: pd.DataFrame, available_models: list[str]) -> tuple[float, float]:
|
| 42 |
"""Calculate overall failure rates for AMD and NVIDIA across all models."""
|
|
@@ -73,7 +93,7 @@ def calculate_overall_failure_rates(df: pd.DataFrame, available_models: list[str
|
|
| 73 |
return amd_failure_rate, nvidia_failure_rate
|
| 74 |
|
| 75 |
|
| 76 |
-
def
|
| 77 |
label: str,
|
| 78 |
stats: dict[str, int],
|
| 79 |
y_bar: float,
|
|
@@ -81,19 +101,72 @@ def draw_text_and_bar(
|
|
| 81 |
bar_height: float,
|
| 82 |
ax: plt.Axes,
|
| 83 |
) -> None:
|
| 84 |
-
"""Draw a horizontal bar chart for given stats
|
| 85 |
-
#
|
| 86 |
-
label_x = column_left_position - LABEL_OFFSET
|
| 87 |
failures_present = any(stats[category] > 0 for category in ['failed', 'error'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
if failures_present:
|
| 89 |
-
|
|
|
|
| 90 |
else:
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
)
|
| 96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
total = sum(stats.values())
|
| 98 |
if total > 0:
|
| 99 |
left = column_left_position
|
|
@@ -172,10 +245,10 @@ def create_summary_page(df: pd.DataFrame, available_models: list[str]) -> plt.Fi
|
|
| 172 |
|
| 173 |
# AMD label and bar in this column
|
| 174 |
bar_height = min(0.4, vertical_spacing * BAR_HEIGHT_RATIO)
|
| 175 |
-
# Draw AMD bar
|
| 176 |
-
|
| 177 |
-
# Draw NVIDIA bar
|
| 178 |
-
|
| 179 |
|
| 180 |
# Increment counter for next visible model
|
| 181 |
visible_model_count += 1
|
|
|
|
| 1 |
import matplotlib.pyplot as plt
|
| 2 |
import pandas as pd
|
| 3 |
+
from matplotlib.offsetbox import OffsetImage, AnnotationBbox
|
| 4 |
+
from matplotlib.patches import FancyBboxPatch
|
| 5 |
+
import matplotlib.image as mpimg
|
| 6 |
+
import os
|
| 7 |
from data import extract_model_data
|
| 8 |
|
| 9 |
# Layout parameters
|
|
|
|
| 41 |
LABEL_OFFSET = 1 # Distance of label from bar
|
| 42 |
FAILURE_RATE_FONT_SIZE = 28
|
| 43 |
|
| 44 |
+
# Logo settings
|
| 45 |
+
LOGO_BOX_WIDTH = 4.5 # Width of the logo box
|
| 46 |
+
LOGO_BOX_HEIGHT = 0.8 # Height of the logo box
|
| 47 |
+
LOGO_ZOOM = 0.08 # Size of the logo image
|
| 48 |
+
|
| 49 |
+
# Load logos once at module level
|
| 50 |
+
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
| 51 |
+
try:
|
| 52 |
+
AMD_LOGO = mpimg.imread(os.path.join(SCRIPT_DIR, 'logos/amd_logo.png'))
|
| 53 |
+
except:
|
| 54 |
+
AMD_LOGO = None
|
| 55 |
+
try:
|
| 56 |
+
NVIDIA_LOGO = mpimg.imread(os.path.join(SCRIPT_DIR, 'logos/nvidia_logo.png'))
|
| 57 |
+
except:
|
| 58 |
+
NVIDIA_LOGO = None
|
| 59 |
+
|
| 60 |
|
| 61 |
def calculate_overall_failure_rates(df: pd.DataFrame, available_models: list[str]) -> tuple[float, float]:
|
| 62 |
"""Calculate overall failure rates for AMD and NVIDIA across all models."""
|
|
|
|
| 93 |
return amd_failure_rate, nvidia_failure_rate
|
| 94 |
|
| 95 |
|
| 96 |
+
def draw_logo_and_bar(
|
| 97 |
label: str,
|
| 98 |
stats: dict[str, int],
|
| 99 |
y_bar: float,
|
|
|
|
| 101 |
bar_height: float,
|
| 102 |
ax: plt.Axes,
|
| 103 |
) -> None:
|
| 104 |
+
"""Draw a horizontal bar chart for given stats with a logo box on the left."""
|
| 105 |
+
# Determine if there are failures
|
|
|
|
| 106 |
failures_present = any(stats[category] > 0 for category in ['failed', 'error'])
|
| 107 |
+
|
| 108 |
+
# Select the appropriate logo
|
| 109 |
+
logo = AMD_LOGO if label.lower() == "amd" else NVIDIA_LOGO
|
| 110 |
+
|
| 111 |
+
# Calculate box position (centered on the bar vertically)
|
| 112 |
+
box_x = column_left_position - LABEL_OFFSET - LOGO_BOX_WIDTH
|
| 113 |
+
box_y = y_bar - LOGO_BOX_HEIGHT / 2
|
| 114 |
+
|
| 115 |
+
# Draw the colored box
|
| 116 |
if failures_present:
|
| 117 |
+
box_color = COLORS['failed'] # Red for failures
|
| 118 |
+
box_alpha = 0.6
|
| 119 |
else:
|
| 120 |
+
box_color = '#2a2a2a' # Dark gray for no failures
|
| 121 |
+
box_alpha = 0.5
|
| 122 |
+
|
| 123 |
+
box = FancyBboxPatch(
|
| 124 |
+
(box_x, box_y),
|
| 125 |
+
LOGO_BOX_WIDTH,
|
| 126 |
+
LOGO_BOX_HEIGHT,
|
| 127 |
+
boxstyle="round,pad=0.05",
|
| 128 |
+
facecolor=box_color,
|
| 129 |
+
edgecolor='#444444',
|
| 130 |
+
linewidth=1,
|
| 131 |
+
alpha=box_alpha
|
| 132 |
)
|
| 133 |
+
ax.add_patch(box)
|
| 134 |
+
|
| 135 |
+
# Add logo image inside the box if available
|
| 136 |
+
if logo is not None:
|
| 137 |
+
try:
|
| 138 |
+
imagebox = OffsetImage(logo, zoom=LOGO_ZOOM)
|
| 139 |
+
ab = AnnotationBbox(
|
| 140 |
+
imagebox,
|
| 141 |
+
(box_x + LOGO_BOX_WIDTH / 2, y_bar),
|
| 142 |
+
frameon=False,
|
| 143 |
+
box_alignment=(0.5, 0.5)
|
| 144 |
+
)
|
| 145 |
+
ax.add_artist(ab)
|
| 146 |
+
except:
|
| 147 |
+
# Fallback to text if logo doesn't work
|
| 148 |
+
ax.text(
|
| 149 |
+
box_x + LOGO_BOX_WIDTH / 2, y_bar,
|
| 150 |
+
label.upper(),
|
| 151 |
+
ha='center', va='center',
|
| 152 |
+
color='#FFFFFF',
|
| 153 |
+
fontsize=10,
|
| 154 |
+
fontfamily='monospace',
|
| 155 |
+
fontweight='bold'
|
| 156 |
+
)
|
| 157 |
+
else:
|
| 158 |
+
# Fallback to text if logo not loaded
|
| 159 |
+
ax.text(
|
| 160 |
+
box_x + LOGO_BOX_WIDTH / 2, y_bar,
|
| 161 |
+
label.upper(),
|
| 162 |
+
ha='center', va='center',
|
| 163 |
+
color='#FFFFFF',
|
| 164 |
+
fontsize=10,
|
| 165 |
+
fontfamily='monospace',
|
| 166 |
+
fontweight='bold'
|
| 167 |
+
)
|
| 168 |
+
|
| 169 |
+
# Draw the bar
|
| 170 |
total = sum(stats.values())
|
| 171 |
if total > 0:
|
| 172 |
left = column_left_position
|
|
|
|
| 245 |
|
| 246 |
# AMD label and bar in this column
|
| 247 |
bar_height = min(0.4, vertical_spacing * BAR_HEIGHT_RATIO)
|
| 248 |
+
# Draw AMD bar with logo
|
| 249 |
+
draw_logo_and_bar("amd", amd_stats, y_amd_bar, col_left, bar_height, ax)
|
| 250 |
+
# Draw NVIDIA bar with logo
|
| 251 |
+
draw_logo_and_bar("nvidia", nvidia_stats, y_nvidia_bar, col_left, bar_height, ax)
|
| 252 |
|
| 253 |
# Increment counter for next visible model
|
| 254 |
visible_model_count += 1
|