zhimin-z
commited on
Commit
·
05edd71
1
Parent(s):
1c9423a
add
Browse files
app.py
CHANGED
|
@@ -304,9 +304,9 @@ def create_monthly_metrics_plot(type="issue", top_n=5):
|
|
| 304 |
print_msg = "discussion"
|
| 305 |
elif type == "wanted":
|
| 306 |
metrics_key = 'wanted_issue_monthly_metrics'
|
| 307 |
-
total_field = '
|
| 308 |
no_data_msg = "No wanted issue data available for visualization"
|
| 309 |
-
total_label = "
|
| 310 |
print_msg = "wanted issue"
|
| 311 |
|
| 312 |
# Load from saved dataset
|
|
@@ -390,41 +390,45 @@ def create_monthly_metrics_plot(type="issue", top_n=5):
|
|
| 390 |
color = agent_colors[agent_name]
|
| 391 |
agent_data = data[agent_name]
|
| 392 |
|
| 393 |
-
# Add line trace for resolved rate (left y-axis)
|
| 394 |
-
resolved_rates = agent_data
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
|
|
|
| 417 |
|
| 418 |
# Add bar trace for total count (right y-axis)
|
| 419 |
# Only show bars for months where assistant has data
|
| 420 |
x_bars = []
|
| 421 |
y_bars = []
|
| 422 |
-
|
|
|
|
| 423 |
if count > 0: # Only include months with data
|
| 424 |
x_bars.append(month)
|
| 425 |
y_bars.append(count)
|
| 426 |
|
| 427 |
if x_bars and y_bars: # Only add trace if there's data
|
|
|
|
|
|
|
| 428 |
fig.add_trace(
|
| 429 |
go.Bar(
|
| 430 |
x=x_bars,
|
|
@@ -432,7 +436,7 @@ def create_monthly_metrics_plot(type="issue", top_n=5):
|
|
| 432 |
name=agent_name,
|
| 433 |
marker=dict(color=color, opacity=0.6),
|
| 434 |
legendgroup=agent_name,
|
| 435 |
-
showlegend=
|
| 436 |
hovertemplate=f'<b>Assistant: %{{fullData.name}}</b><br>' +
|
| 437 |
f'Month: %{{x}}<br>' +
|
| 438 |
f'{total_label}: %{{y}}<br>' +
|
|
@@ -444,15 +448,25 @@ def create_monthly_metrics_plot(type="issue", top_n=5):
|
|
| 444 |
|
| 445 |
# Update axes labels
|
| 446 |
fig.update_xaxes(title_text=None)
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 456 |
fig.update_yaxes(title_text=f"<b>{total_label}</b>", secondary_y=True)
|
| 457 |
|
| 458 |
# Update layout
|
|
@@ -762,7 +776,7 @@ with gr.Blocks(title="SWE Assistant Issue & Discussion Leaderboard", theme=gr.th
|
|
| 762 |
discussion_metrics_plot = gr.Plot()
|
| 763 |
|
| 764 |
with gr.Column():
|
| 765 |
-
gr.Markdown("*
|
| 766 |
wanted_metrics_plot = gr.Plot()
|
| 767 |
|
| 768 |
# Load monthly metrics when app starts
|
|
|
|
| 304 |
print_msg = "discussion"
|
| 305 |
elif type == "wanted":
|
| 306 |
metrics_key = 'wanted_issue_monthly_metrics'
|
| 307 |
+
total_field = 'resolved_wanted' # Only resolved_wanted is available now
|
| 308 |
no_data_msg = "No wanted issue data available for visualization"
|
| 309 |
+
total_label = "Resolved Wanted Issues"
|
| 310 |
print_msg = "wanted issue"
|
| 311 |
|
| 312 |
# Load from saved dataset
|
|
|
|
| 390 |
color = agent_colors[agent_name]
|
| 391 |
agent_data = data[agent_name]
|
| 392 |
|
| 393 |
+
# Add line trace for resolved rate (left y-axis) - only if resolved_rates exists
|
| 394 |
+
resolved_rates = agent_data.get('resolved_rates')
|
| 395 |
+
if resolved_rates:
|
| 396 |
+
# Filter out None values for plotting
|
| 397 |
+
x_resolved = [month for month, rate in zip(months, resolved_rates) if rate is not None]
|
| 398 |
+
y_resolved = [rate for rate in resolved_rates if rate is not None]
|
| 399 |
+
|
| 400 |
+
if x_resolved and y_resolved: # Only add trace if there's data
|
| 401 |
+
fig.add_trace(
|
| 402 |
+
go.Scatter(
|
| 403 |
+
x=x_resolved,
|
| 404 |
+
y=y_resolved,
|
| 405 |
+
name=agent_name,
|
| 406 |
+
mode='lines+markers',
|
| 407 |
+
line=dict(color=color, width=2),
|
| 408 |
+
marker=dict(size=8),
|
| 409 |
+
legendgroup=agent_name,
|
| 410 |
+
showlegend=(top_n is not None and top_n <= 10), # Show legend for top N assistants
|
| 411 |
+
hovertemplate='<b>Assistant: %{fullData.name}</b><br>' +
|
| 412 |
+
'Month: %{x}<br>' +
|
| 413 |
+
'Resolved Rate: %{y:.2f}%<br>' +
|
| 414 |
+
'<extra></extra>'
|
| 415 |
+
),
|
| 416 |
+
secondary_y=False
|
| 417 |
+
)
|
| 418 |
|
| 419 |
# Add bar trace for total count (right y-axis)
|
| 420 |
# Only show bars for months where assistant has data
|
| 421 |
x_bars = []
|
| 422 |
y_bars = []
|
| 423 |
+
total_data = agent_data.get(total_field, [])
|
| 424 |
+
for month, count in zip(months, total_data):
|
| 425 |
if count > 0: # Only include months with data
|
| 426 |
x_bars.append(month)
|
| 427 |
y_bars.append(count)
|
| 428 |
|
| 429 |
if x_bars and y_bars: # Only add trace if there's data
|
| 430 |
+
# For wanted type without resolved_rates, show legend on bar chart
|
| 431 |
+
show_bar_legend = (top_n is not None and top_n <= 10) and not resolved_rates
|
| 432 |
fig.add_trace(
|
| 433 |
go.Bar(
|
| 434 |
x=x_bars,
|
|
|
|
| 436 |
name=agent_name,
|
| 437 |
marker=dict(color=color, opacity=0.6),
|
| 438 |
legendgroup=agent_name,
|
| 439 |
+
showlegend=show_bar_legend, # Show legend if no line chart was added
|
| 440 |
hovertemplate=f'<b>Assistant: %{{fullData.name}}</b><br>' +
|
| 441 |
f'Month: %{{x}}<br>' +
|
| 442 |
f'{total_label}: %{{y}}<br>' +
|
|
|
|
| 448 |
|
| 449 |
# Update axes labels
|
| 450 |
fig.update_xaxes(title_text=None)
|
| 451 |
+
|
| 452 |
+
# For "wanted" type, there's no resolved_rates, so hide the left y-axis
|
| 453 |
+
if type == "wanted":
|
| 454 |
+
fig.update_yaxes(
|
| 455 |
+
title_text=None,
|
| 456 |
+
showticklabels=False,
|
| 457 |
+
showgrid=False,
|
| 458 |
+
secondary_y=False
|
| 459 |
+
)
|
| 460 |
+
else:
|
| 461 |
+
fig.update_yaxes(
|
| 462 |
+
title_text="<b>Resolved Rate (%)</b>",
|
| 463 |
+
range=[0, 100],
|
| 464 |
+
secondary_y=False,
|
| 465 |
+
showticklabels=True,
|
| 466 |
+
tickmode='linear',
|
| 467 |
+
dtick=10,
|
| 468 |
+
showgrid=True
|
| 469 |
+
)
|
| 470 |
fig.update_yaxes(title_text=f"<b>{total_label}</b>", secondary_y=True)
|
| 471 |
|
| 472 |
# Update layout
|
|
|
|
| 776 |
discussion_metrics_plot = gr.Plot()
|
| 777 |
|
| 778 |
with gr.Column():
|
| 779 |
+
gr.Markdown("*Resolved wanted issues over time*")
|
| 780 |
wanted_metrics_plot = gr.Plot()
|
| 781 |
|
| 782 |
# Load monthly metrics when app starts
|