zhimin-z commited on
Commit
05edd71
·
1 Parent(s): 1c9423a
Files changed (1) hide show
  1. app.py +52 -38
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 = 'total_wanted'
308
  no_data_msg = "No wanted issue data available for visualization"
309
- total_label = "Total Wanted Issues"
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['resolved_rates']
395
- # Filter out None values for plotting
396
- x_resolved = [month for month, rate in zip(months, resolved_rates) if rate is not None]
397
- y_resolved = [rate for rate in resolved_rates if rate is not None]
398
-
399
- if x_resolved and y_resolved: # Only add trace if there's data
400
- fig.add_trace(
401
- go.Scatter(
402
- x=x_resolved,
403
- y=y_resolved,
404
- name=agent_name,
405
- mode='lines+markers',
406
- line=dict(color=color, width=2),
407
- marker=dict(size=8),
408
- legendgroup=agent_name,
409
- showlegend=(top_n is not None and top_n <= 10), # Show legend for top N assistants
410
- hovertemplate='<b>Assistant: %{fullData.name}</b><br>' +
411
- 'Month: %{x}<br>' +
412
- 'Resolved Rate: %{y:.2f}%<br>' +
413
- '<extra></extra>'
414
- ),
415
- secondary_y=False
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
- for month, count in zip(months, agent_data[total_field]):
 
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=False, # Hide duplicate legend entry (already shown in Scatter)
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
- fig.update_yaxes(
448
- title_text="<b>Resolved Rate (%)</b>",
449
- range=[0, 100],
450
- secondary_y=False,
451
- showticklabels=True,
452
- tickmode='linear',
453
- dtick=10,
454
- showgrid=True
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("*Wanted issue volume and resolved rate over time*")
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