ror HF Staff commited on
Commit
065764c
·
1 Parent(s): 7c40087

before claude

Browse files
Files changed (2) hide show
  1. app.py +159 -10
  2. requirements.txt +0 -1
app.py CHANGED
@@ -14,18 +14,167 @@ MODELS = {
14
  def plot_model_stats(model_name: str) -> plt.Figure:
15
  """Draws a pie chart of model's passed, failed, skipped, and error stats."""
16
  model_stats = MODELS[model_name]
17
- fig = plt.figure()
18
- ax = fig.add_subplot(111)
19
- ax.pie(model_stats.values(), labels=model_stats.keys())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  return fig
21
 
22
- demo = gr.Interface(
23
- plot_model_stats,
24
- [
25
- gr.Radio(list(MODELS.keys()), label="Model"),
26
- ],
27
- gr.Plot(label="Model Stats", format="png"),
28
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  if __name__ == "__main__":
31
  demo.launch()
 
14
  def plot_model_stats(model_name: str) -> plt.Figure:
15
  """Draws a pie chart of model's passed, failed, skipped, and error stats."""
16
  model_stats = MODELS[model_name]
17
+
18
+ # Define appropriate colors for each category
19
+ colors = {
20
+ 'passed': '#4CAF50', # Green
21
+ 'failed': '#F44336', # Red
22
+ 'skipped': '#FF9800', # Orange
23
+ 'error': '#9C27B0' # Purple
24
+ }
25
+
26
+ # Filter out categories with 0 values for cleaner visualization
27
+ filtered_stats = {k: v for k, v in model_stats.items() if v > 0}
28
+
29
+ if not filtered_stats:
30
+ # Handle case where all values are 0 - dark theme styling
31
+ fig, ax = plt.subplots(figsize=(10, 8), facecolor='#000000')
32
+ ax.set_facecolor('#000000')
33
+ ax.text(0.5, 0.5, 'No test results available',
34
+ horizontalalignment='center', verticalalignment='center',
35
+ transform=ax.transAxes, fontsize=16, color='white')
36
+ ax.set_xlim(0, 1)
37
+ ax.set_ylim(0, 1)
38
+ ax.axis('off')
39
+ return fig
40
+
41
+ # Create the pie chart with dark theme
42
+ fig, ax = plt.subplots(figsize=(10, 8), facecolor='#000000')
43
+ ax.set_facecolor('#000000')
44
+
45
+ # Get colors for filtered categories
46
+ chart_colors = [colors[category] for category in filtered_stats.keys()]
47
+
48
+ # Create pie chart with custom styling for dark theme
49
+ wedges, texts, autotexts = ax.pie(
50
+ filtered_stats.values(),
51
+ labels=filtered_stats.keys(),
52
+ colors=chart_colors,
53
+ autopct='%1.1f%%',
54
+ startangle=90,
55
+ explode=[0.08] * len(filtered_stats), # Slightly larger separation for dark theme
56
+ shadow=False, # Remove shadow for cleaner dark look
57
+ textprops={'fontsize': 13, 'weight': 'bold', 'color': 'white'}
58
+ )
59
+
60
+ # Enhance text styling for dark theme
61
+ for autotext in autotexts:
62
+ autotext.set_color('white')
63
+ autotext.set_weight('bold')
64
+ autotext.set_fontsize(12)
65
+
66
+ # Set title with white text
67
+ total_tests = sum(model_stats.values())
68
+ ax.set_title(f'{model_name.upper()} Test Results\n({total_tests} total tests)',
69
+ fontsize=18, weight='bold', pad=30, color='white')
70
+
71
+ # Make the chart more minimalist
72
+ plt.tight_layout()
73
+
74
  return fig
75
 
76
+ # Custom CSS for dark theme
77
+ dark_theme_css = """
78
+ /* Global dark theme */
79
+ .gradio-container {
80
+ background-color: #000000 !important;
81
+ color: white !important;
82
+ }
83
+
84
+ /* Remove borders from all components */
85
+ .gr-box, .gr-form, .gr-panel {
86
+ border: none !important;
87
+ background-color: #000000 !important;
88
+ }
89
+
90
+ /* Sidebar styling */
91
+ .sidebar {
92
+ background-color: #111111 !important;
93
+ border: none !important;
94
+ padding: 20px !important;
95
+ }
96
+
97
+ /* Button styling */
98
+ .gr-button {
99
+ background-color: #222222 !important;
100
+ color: white !important;
101
+ border: 1px solid #444444 !important;
102
+ margin: 5px 0 !important;
103
+ border-radius: 8px !important;
104
+ transition: all 0.3s ease !important;
105
+ }
106
+
107
+ .gr-button:hover {
108
+ background-color: #333333 !important;
109
+ border-color: #666666 !important;
110
+ }
111
+
112
+ /* Plot container */
113
+ .plot-container {
114
+ background-color: #000000 !important;
115
+ border: none !important;
116
+ }
117
+
118
+ /* Text elements */
119
+ h1, h2, h3, p, .markdown {
120
+ color: white !important;
121
+ }
122
+
123
+ /* Remove all borders globally */
124
+ * {
125
+ border-color: transparent !important;
126
+ }
127
+
128
+ /* Main content area */
129
+ .main-content {
130
+ background-color: #000000 !important;
131
+ padding: 20px !important;
132
+ }
133
+ """
134
+
135
+ # Create the Gradio interface with sidebar and dark theme
136
+ with gr.Blocks(title="Model Test Results Dashboard", css=dark_theme_css) as demo:
137
+
138
+ with gr.Row():
139
+ # Sidebar for model selection
140
+ with gr.Column(scale=1, elem_classes=["sidebar"]):
141
+ gr.Markdown("# 🎯 Models")
142
+ gr.Markdown("Select a model to view test results")
143
+
144
+ # Model selection buttons in sidebar
145
+ model_buttons = []
146
+ for model_name in MODELS.keys():
147
+ btn = gr.Button(
148
+ f"📊 {model_name.upper()}",
149
+ variant="secondary",
150
+ size="lg",
151
+ elem_classes=["model-button"]
152
+ )
153
+ model_buttons.append(btn)
154
+
155
+ # Main content area
156
+ with gr.Column(scale=4, elem_classes=["main-content"]):
157
+ gr.Markdown("# 📈 Test Results Dashboard")
158
+
159
+ # Create the plot output
160
+ plot_output = gr.Plot(
161
+ label="",
162
+ format="png",
163
+ elem_classes=["plot-container"]
164
+ )
165
+
166
+ # Set up click handlers for each button
167
+ for i, (model_name, button) in enumerate(zip(MODELS.keys(), model_buttons)):
168
+ button.click(
169
+ fn=lambda name=model_name: plot_model_stats(name),
170
+ outputs=plot_output
171
+ )
172
+
173
+ # Initialize with the first model
174
+ demo.load(
175
+ fn=lambda: plot_model_stats(list(MODELS.keys())[0]),
176
+ outputs=plot_output
177
+ )
178
 
179
  if __name__ == "__main__":
180
  demo.launch()
requirements.txt CHANGED
@@ -1,2 +1 @@
1
  matplotlib>=3.8
2
- gradio
 
1
  matplotlib>=3.8