Spaces:
Running
Running
Simplified summary page code
Browse files- summary_page.py +81 -78
summary_page.py
CHANGED
@@ -1,6 +1,68 @@
|
|
1 |
import matplotlib.pyplot as plt
|
2 |
import pandas as pd
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
def create_summary_page(df: pd.DataFrame, available_models: list[str]) -> plt.Figure:
|
5 |
"""Create a summary page with model names and both AMD/NVIDIA test stats bars."""
|
6 |
if df.empty:
|
@@ -15,34 +77,18 @@ def create_summary_page(df: pd.DataFrame, available_models: list[str]) -> plt.Fi
|
|
15 |
|
16 |
# Calculate dimensions for N-column layout
|
17 |
model_count = len(available_models)
|
18 |
-
|
19 |
-
rows = (model_count + columns - 1) // columns # Ceiling division
|
20 |
|
21 |
-
# Figure dimensions - wider for
|
22 |
-
|
23 |
-
|
24 |
-
height_per_row = min(2.2, max_height / max(rows, 1))
|
25 |
-
figure_height = min(max_height, rows * height_per_row + 2)
|
26 |
|
27 |
-
fig, ax = plt.subplots(figsize=(
|
28 |
ax.set_facecolor('#000000')
|
29 |
|
30 |
-
colors = {
|
31 |
-
'passed': '#4CAF50',
|
32 |
-
'failed': '#E53E3E',
|
33 |
-
'skipped': '#FFD54F',
|
34 |
-
'error': '#8B0000',
|
35 |
-
'empty': "#5B5B5B"
|
36 |
-
}
|
37 |
-
|
38 |
visible_model_count = 0
|
39 |
max_y = 0
|
40 |
|
41 |
-
# Column layout parameters
|
42 |
-
column_width = 100 / columns # Each column takes 25% of width
|
43 |
-
bar_width = column_width * 0.8 # 80% of column width for bars
|
44 |
-
bar_margin = column_width * 0.1 # 10% margin on each side
|
45 |
-
|
46 |
for i, model_name in enumerate(available_models):
|
47 |
if model_name not in df.index:
|
48 |
continue
|
@@ -71,75 +117,34 @@ def create_summary_page(df: pd.DataFrame, available_models: list[str]) -> plt.Fi
|
|
71 |
'skipped': 0,
|
72 |
'error': 0
|
73 |
}
|
74 |
-
|
75 |
-
amd_total = sum(amd_stats.values())
|
76 |
-
nvidia_total = sum(nvidia_stats.values())
|
77 |
-
|
78 |
-
if amd_total == 0 and nvidia_total == 0:
|
79 |
-
continue
|
80 |
|
81 |
# Calculate position in 4-column grid
|
82 |
-
col = visible_model_count %
|
83 |
-
row = visible_model_count //
|
84 |
|
85 |
# Calculate horizontal position for this column
|
86 |
-
col_left = col *
|
87 |
-
col_center = col *
|
88 |
|
89 |
# Calculate vertical position for this row - start from top
|
90 |
vertical_spacing = height_per_row
|
91 |
-
y_base = (
|
92 |
y_model_name = y_base # Model name above AMD bar
|
93 |
-
y_amd_bar = y_base + vertical_spacing *
|
94 |
-
y_nvidia_bar = y_base + vertical_spacing *
|
95 |
max_y = max(max_y, y_nvidia_bar + vertical_spacing * 0.3)
|
96 |
|
97 |
# Model name centered above the bars in this column
|
98 |
ax.text(col_center, y_model_name, model_name.lower(),
|
99 |
ha='center', va='center', color='#FFFFFF',
|
100 |
-
fontsize=
|
101 |
|
102 |
# AMD label and bar in this column
|
103 |
-
bar_height = min(0.4, vertical_spacing *
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
# AMD bar starts at column left position
|
109 |
-
left = col_left
|
110 |
-
for category in ['passed', 'failed', 'skipped', 'error']:
|
111 |
-
if amd_stats[category] > 0:
|
112 |
-
width = amd_stats[category] / amd_total * bar_width
|
113 |
-
ax.barh(y_amd_bar, width, left=left, height=bar_height,
|
114 |
-
color=colors[category], alpha=0.9)
|
115 |
-
# if width > 2: # Smaller threshold for text display
|
116 |
-
# ax.text(left + width/2, y_amd_bar, str(amd_stats[category]),
|
117 |
-
# ha='center', va='center', color='black',
|
118 |
-
# fontweight='bold', fontsize=10, fontfamily='monospace')
|
119 |
-
left += width
|
120 |
-
else:
|
121 |
-
ax.barh(y_amd_bar, bar_width, left=col_left, height=bar_height, color=colors['empty'], alpha=0.9)
|
122 |
-
# ax.text(col_center, y_amd_bar, "No data", ha='center', va='center', color='black', fontweight='bold', fontsize=10, fontfamily='monospace')
|
123 |
-
|
124 |
-
# NVIDIA label and bar in this column
|
125 |
-
ax.text(label_x, y_nvidia_bar, "nvidia", ha='right', va='center', color='#CCCCCC', fontsize=14, fontfamily='monospace', fontweight='normal')
|
126 |
-
|
127 |
-
if nvidia_total > 0:
|
128 |
-
# NVIDIA bar starts at column left position
|
129 |
-
left = col_left
|
130 |
-
for category in ['passed', 'failed', 'skipped', 'error']:
|
131 |
-
if nvidia_stats[category] > 0:
|
132 |
-
width = nvidia_stats[category] / nvidia_total * bar_width
|
133 |
-
ax.barh(y_nvidia_bar, width, left=left, height=bar_height,
|
134 |
-
color=colors[category], alpha=0.9)
|
135 |
-
# if width > 2: # Smaller threshold for text display
|
136 |
-
# ax.text(left + width/2, y_nvidia_bar, str(nvidia_stats[category]),
|
137 |
-
# ha='center', va='center', color='black',
|
138 |
-
# fontweight='bold', fontsize=10, fontfamily='monospace')
|
139 |
-
left += width
|
140 |
-
else:
|
141 |
-
ax.barh(y_nvidia_bar, bar_width, left=col_left, height=bar_height, color=colors['empty'], alpha=0.9)
|
142 |
-
# ax.text(col_center, y_nvidia_bar, "No data", ha='center', va='center', color='black', fontweight='bold', fontsize=10, fontfamily='monospace')
|
143 |
|
144 |
# Increment counter for next visible model
|
145 |
visible_model_count += 1
|
@@ -158,7 +163,5 @@ def create_summary_page(df: pd.DataFrame, available_models: list[str]) -> plt.Fi
|
|
158 |
ax.yaxis.set_inverted(True)
|
159 |
|
160 |
# Remove all margins to make figure stick to top
|
161 |
-
plt.tight_layout()
|
162 |
-
plt.subplots_adjust(left=0.02, right=0.98, top=1.0, bottom=0.02)
|
163 |
-
|
164 |
return fig
|
|
|
1 |
import matplotlib.pyplot as plt
|
2 |
import pandas as pd
|
3 |
|
4 |
+
# Layout parameters
|
5 |
+
COLUMNS = 3
|
6 |
+
|
7 |
+
# Derived constants
|
8 |
+
COLUMN_WIDTH = 100 / COLUMNS # Each column takes 25% of width
|
9 |
+
BAR_WIDTH = COLUMN_WIDTH * 0.8 # 80% of column width for bars
|
10 |
+
BAR_MARGIN = COLUMN_WIDTH * 0.1 # 10% margin on each side
|
11 |
+
|
12 |
+
# Figure dimensions
|
13 |
+
FIGURE_WIDTH = 20 # Wider to accommodate columns
|
14 |
+
MAX_HEIGHT = 12 # Maximum height in inches
|
15 |
+
MIN_HEIGHT_PER_ROW = 2.2
|
16 |
+
FIGURE_PADDING = 2
|
17 |
+
|
18 |
+
# Bar styling
|
19 |
+
BAR_HEIGHT_RATIO = 0.22 # Bar height as ratio of vertical spacing
|
20 |
+
VERTICAL_SPACING_RATIO = 0.2 # Base vertical position ratio
|
21 |
+
AMD_BAR_OFFSET = 0.25 # AMD bar offset ratio
|
22 |
+
NVIDIA_BAR_OFFSET = 0.54 # NVIDIA bar offset ratio
|
23 |
+
|
24 |
+
# Colors
|
25 |
+
COLORS = {
|
26 |
+
'passed': '#4CAF50',
|
27 |
+
'failed': '#E53E3E',
|
28 |
+
'skipped': '#FFD54F',
|
29 |
+
'error': '#8B0000',
|
30 |
+
'empty': "#5B5B5B"
|
31 |
+
}
|
32 |
+
|
33 |
+
# Font styling
|
34 |
+
MODEL_NAME_FONT_SIZE = 16
|
35 |
+
LABEL_FONT_SIZE = 14
|
36 |
+
LABEL_OFFSET = 1 # Distance of label from bar
|
37 |
+
|
38 |
+
|
39 |
+
def draw_text_and_bar(
|
40 |
+
label: str,
|
41 |
+
stats: dict[str, int],
|
42 |
+
y_bar: float,
|
43 |
+
column_left_position: float,
|
44 |
+
bar_height: float,
|
45 |
+
ax: plt.Axes,
|
46 |
+
) -> None:
|
47 |
+
"""Draw a horizontal bar chart for given stats and its label on the left."""
|
48 |
+
# Text
|
49 |
+
label_x = column_left_position - LABEL_OFFSET
|
50 |
+
ax.text(
|
51 |
+
label_x, y_bar, label, ha='right', va='center', color='#CCCCCC', fontsize=LABEL_FONT_SIZE,
|
52 |
+
fontfamily='monospace', fontweight='normal'
|
53 |
+
)
|
54 |
+
# Bar
|
55 |
+
total = sum(stats.values())
|
56 |
+
if total > 0:
|
57 |
+
left = column_left_position
|
58 |
+
for category in ['passed', 'failed', 'skipped', 'error']:
|
59 |
+
if stats[category] > 0:
|
60 |
+
width = stats[category] / total * BAR_WIDTH
|
61 |
+
ax.barh(y_bar, width, left=left, height=bar_height, color=COLORS[category], alpha=0.9)
|
62 |
+
left += width
|
63 |
+
else:
|
64 |
+
ax.barh(y_bar, BAR_WIDTH, left=column_left_position, height=bar_height, color=COLORS['empty'], alpha=0.9)
|
65 |
+
|
66 |
def create_summary_page(df: pd.DataFrame, available_models: list[str]) -> plt.Figure:
|
67 |
"""Create a summary page with model names and both AMD/NVIDIA test stats bars."""
|
68 |
if df.empty:
|
|
|
77 |
|
78 |
# Calculate dimensions for N-column layout
|
79 |
model_count = len(available_models)
|
80 |
+
rows = (model_count + COLUMNS - 1) // COLUMNS # Ceiling division
|
|
|
81 |
|
82 |
+
# Figure dimensions - wider for columns, height based on rows
|
83 |
+
height_per_row = min(MIN_HEIGHT_PER_ROW, MAX_HEIGHT / max(rows, 1))
|
84 |
+
figure_height = min(MAX_HEIGHT, rows * height_per_row + FIGURE_PADDING)
|
|
|
|
|
85 |
|
86 |
+
fig, ax = plt.subplots(figsize=(FIGURE_WIDTH, figure_height), facecolor='#000000')
|
87 |
ax.set_facecolor('#000000')
|
88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
visible_model_count = 0
|
90 |
max_y = 0
|
91 |
|
|
|
|
|
|
|
|
|
|
|
92 |
for i, model_name in enumerate(available_models):
|
93 |
if model_name not in df.index:
|
94 |
continue
|
|
|
117 |
'skipped': 0,
|
118 |
'error': 0
|
119 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
|
121 |
# Calculate position in 4-column grid
|
122 |
+
col = visible_model_count % COLUMNS
|
123 |
+
row = visible_model_count // COLUMNS
|
124 |
|
125 |
# Calculate horizontal position for this column
|
126 |
+
col_left = col * COLUMN_WIDTH + BAR_MARGIN
|
127 |
+
col_center = col * COLUMN_WIDTH + COLUMN_WIDTH / 2
|
128 |
|
129 |
# Calculate vertical position for this row - start from top
|
130 |
vertical_spacing = height_per_row
|
131 |
+
y_base = (VERTICAL_SPACING_RATIO + row) * vertical_spacing
|
132 |
y_model_name = y_base # Model name above AMD bar
|
133 |
+
y_amd_bar = y_base + vertical_spacing * AMD_BAR_OFFSET # AMD bar
|
134 |
+
y_nvidia_bar = y_base + vertical_spacing * NVIDIA_BAR_OFFSET # NVIDIA bar
|
135 |
max_y = max(max_y, y_nvidia_bar + vertical_spacing * 0.3)
|
136 |
|
137 |
# Model name centered above the bars in this column
|
138 |
ax.text(col_center, y_model_name, model_name.lower(),
|
139 |
ha='center', va='center', color='#FFFFFF',
|
140 |
+
fontsize=MODEL_NAME_FONT_SIZE, fontfamily='monospace', fontweight='bold')
|
141 |
|
142 |
# AMD label and bar in this column
|
143 |
+
bar_height = min(0.4, vertical_spacing * BAR_HEIGHT_RATIO)
|
144 |
+
# Draw AMD bar
|
145 |
+
draw_text_and_bar("amd", amd_stats, y_amd_bar, col_left, bar_height, ax)
|
146 |
+
# Draw NVIDIA bar
|
147 |
+
draw_text_and_bar("nvidia", nvidia_stats, y_nvidia_bar, col_left, bar_height, ax)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
|
149 |
# Increment counter for next visible model
|
150 |
visible_model_count += 1
|
|
|
163 |
ax.yaxis.set_inverted(True)
|
164 |
|
165 |
# Remove all margins to make figure stick to top
|
166 |
+
plt.tight_layout()
|
|
|
|
|
167 |
return fig
|