-
Notifications
You must be signed in to change notification settings - Fork 215
Description
Pattern Overview
The Python Chart Discussion Report pattern appears in 7 workflows that generate visualizations with Python/matplotlib, upload charts as assets, and create discussion reports with embedded chart images. Extracting this into a shared component would eliminate ~700 lines of duplicated code and ensure consistent report formatting.
Current Usage
This pattern appears in the following workflows:
-
daily-issues-report.md(lines 31-34, 187-230, 235-262) -
daily-code-metrics.md(lines 30-31, 66-230, 240-365) -
python-data-charts.md -
daily-copilot-token-report.md -
daily-performance-summary.md -
session-analysis-charts.md(via shared import) -
trending-charts-simple.md(via shared import)
Proposed Shared Component
File: .github/workflows/shared/python-chart-discussion-report.md
Configuration:
```yaml
imports:
- shared/python-dataviz.md
- shared/reporting.md
safe-outputs:
upload-asset:
create-discussion:
max: 1
close-older-discussions: true
tools:
cache-memory: true
Python Chart Discussion Report Guide
This component extends python-dataviz.md for workflows that generate comprehensive reports with multiple visualization charts.
Standard Report Structure
All chart-based reports should follow this structure:
```markdown
[Report Title] - [Date]
Executive Summary
[2-3 paragraphs summarizing key findings, trends, and recommendations]
Key Statistics:
- Metric 1: [value]
- Metric 2: [value]
- Metric 3: [value]
Key Visualizations
[Chart 1 Title]
[2-3 sentence analysis of what this chart shows and key insights]
[Chart 2 Title]
[2-3 sentence analysis of what this chart shows and key insights]
[Chart 3 Title] (if applicable)
[2-3 sentence analysis]
📊 Detailed Metrics and Analysis
[Section 1]
[Detailed tables, metrics, and analysis]
| Metric | Value | Change (7d) | Change (30d) |
|---|---|---|---|
| ... | ... | ... | ... |
[Section 2]
[More detailed analysis]
💡 Insights and Recommendations
- [Specific actionable recommendation based on data]
- [Another recommendation]
- [Additional recommendation]
- [...]
Report generated by [Workflow Name] workflow
Data period: [period] | Generated: [timestamp]
```
Chart Upload Process
After generating charts in /tmp/gh-aw/python/charts/:
Step 1: Upload charts as assets
```bash
Upload each chart and collect URLs
declare -A chart_urls
for chart_file in /tmp/gh-aw/python/charts/*.png; do
if [ -f "$chart_file" ]; then
chart_name=$(basename "$chart_file" .png)
echo "Uploading $chart_name..."
# Use upload-asset tool (returns URL)
# Store URL in associative array
# chart_urls["$chart_name"]="$returned_url"
fi
done
```
Step 2: Create discussion with embedded charts
Use the collected URLs to embed charts in your discussion markdown. Follow the standard report structure above.
Standard Chart Set
Most workflows should generate 2-4 charts:
-
Primary Trend Chart: Time series showing main metrics over 30 days
- Line chart with multiple series
- Include 7-day moving average
- Annotate significant changes
-
Distribution Chart: Breakdown of current state
- Bar chart or pie chart
- Show proportions or counts
- Sort by significance
-
Comparison Chart (optional): Before/after or comparative analysis
- Grouped bars or side-by-side comparison
- Highlight differences
- Include percentage changes
-
Detailed Analysis Chart (optional): Deep dive into specific aspect
- Heatmap, scatter plot, or specialized visualization
- Focus on specific insight
Chart Quality Standards
All charts MUST meet these requirements (from python-dataviz.md):
- DPI: 300 minimum for publication quality
- Figure Size: 12x7 inches (or 10x6 for smaller charts)
- Styling: Use seaborn styling (
sns.set_style("whitegrid")) - Color Palette: Professional colors (
sns.set_palette("husl")or custom) - Labels: Clear titles, axis labels, and legends
- Grid Lines: Enable for readability (
ax.grid(True, alpha=0.3)) - Save Format: PNG with
bbox_inches='tight'
Chart Generation Template
```python
#!/usr/bin/env python3
"""
Chart generation script for [workflow name]
Generates [number] charts for the daily report
"""
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from datetime import datetime
Set consistent style
sns.set_style("whitegrid")
sns.set_palette("husl")
Load data (NEVER inline - always from external file)
data = pd.read_json('/tmp/gh-aw/python/data/metrics.json')
Chart 1: Trend Chart
def generate_trend_chart():
fig, ax = plt.subplots(figsize=(12, 7), dpi=300)
# Your plotting code
data.plot(x='date', y=['metric1', 'metric2'], ax=ax)
# Customize
ax.set_title('Metric Trends - Last 30 Days', fontsize=16, fontweight='bold')
ax.set_xlabel('Date', fontsize=12)
ax.set_ylabel('Value', fontsize=12)
ax.legend(loc='best')
ax.grid(True, alpha=0.3)
# Save
plt.savefig('/tmp/gh-aw/python/charts/trend_chart.png',
dpi=300, bbox_inches='tight', facecolor='white')
print("✓ Trend chart generated")
Chart 2: Distribution Chart
def generate_distribution_chart():
fig, ax = plt.subplots(figsize=(10, 6), dpi=300)
# Your plotting code
data['category'].value_counts().plot(kind='barh', ax=ax)
# Customize
ax.set_title('Distribution by Category', fontsize=16, fontweight='bold')
ax.set_xlabel('Count', fontsize=12)
ax.grid(True, alpha=0.3)
# Save
plt.savefig('/tmp/gh-aw/python/charts/distribution_chart.png',
dpi=300, bbox_inches='tight', facecolor='white')
print("✓ Distribution chart generated")
Generate all charts
if name == 'main':
generate_trend_chart()
generate_distribution_chart()
print("All charts generated successfully")
```
Discussion Creation Best Practices
- Title format:
[Category] Report Name - YYYY-MM-DD - Executive summary: 2-3 paragraphs max, highlight key findings
- Chart placement: Embed charts early, before detailed metrics
- Analysis text: 2-3 sentences per chart explaining insights
- Collapsible details: Put detailed tables/metrics in
<details>tag - Recommendations: 3-5 bullet points, specific and actionable
- Metadata footer: Include workflow name, data period, generation timestamp
Cache Memory Integration
Store reusable chart generation code in cache:
```bash
Check for cached chart utilities
if [ -f /tmp/gh-aw/cache-memory/chart_utils.py ]; then
cp /tmp/gh-aw/cache-memory/chart_utils.py /tmp/gh-aw/python/
echo "Using cached chart utilities"
fi
Save new utilities to cache
if [ -f /tmp/gh-aw/python/chart_utils.py ]; then
cp /tmp/gh-aw/python/chart_utils.py /tmp/gh-aw/cache-memory/
echo "Saved chart utilities to cache"
fi
```
Complete Example Usage
```yaml
imports:
- shared/python-chart-discussion-report.md
- shared/issues-data-fetch.md # Or other data source
safe-outputs:
create-discussion:
category: "audits"
```
Then in your workflow:
- Load and process data
- Generate charts with Python
- Upload charts as assets (collect URLs)
- Create discussion using standard structure
- Embed chart URLs in markdown
```
Usage Example:
```yaml
In a workflow
imports:
- shared/python-chart-discussion-report.md
- shared/issues-data-fetch.md
```
Impact
- Workflows affected: 7 workflows
- Lines saved: ~700 lines (100 per workflow)
- Maintenance benefit:
- Consistent report formatting across all chart-based workflows
- Enforces chart quality standards (DPI, sizing, styling)
- Easier to update report structure (cascades to all workflows)
- Reduces copy-paste errors in chart generation code
Implementation Plan
- Create shared component at
.github/workflows/shared/python-chart-discussion-report.md - Pilot: Update
daily-issues-report.mdto use shared component - Validate pilot: Check chart quality and discussion format
- Update
daily-code-metrics.md - Update
python-data-charts.md - Update remaining 4 workflows
- Test all workflows to ensure charts display correctly
- Update documentation with examples
Related Analysis
This recommendation comes from the Workflow Pattern Harvester analysis run on 2026-01-16.
AI generated by Workflow Pattern Harvester