-
Notifications
You must be signed in to change notification settings - Fork 312
Add data-science.md prompt for chart/trend workflow generation #22032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
61a7c86
Initial plan
Copilot 487b7af
feat: add data-science.md prompt and link in agentic-workflows dispat…
Copilot 780f8b1
fix: make data-science.md self-contained with shared/* imports
Copilot 35c50df
fix: inline shared workflow content into data-science.md — no imports…
Copilot 56c7835
chore: optimize data-science.md prompt — 50% shorter, no redundancy
Copilot 6da1c67
Merge branch 'main' into copilot/add-data-viz-instructions
pelikhan 8e971c5
feat: advertise data-science.md in agentic-workflows.agent.md dispatcher
Copilot 067c529
fix: trim non-data-science frontmatter fields and use ?raw=true URL i…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| --- | ||
| description: Guidelines for creating agentic workflows that generate charts and trend visualizations using Python scientific computing libraries with persistent historical data. | ||
| --- | ||
|
|
||
| # Data Science & Chart Generation | ||
|
|
||
| Use when creating a workflow that generates charts, trend visualizations, dashboards, or any Python-based metric output. | ||
|
|
||
| ## Frontmatter Template | ||
|
|
||
| ```yaml | ||
| --- | ||
| network: | ||
| allowed: | ||
| - defaults | ||
| - python | ||
| safe-outputs: | ||
| upload-asset: | ||
| create-issue: # or create-discussion | ||
| title-prefix: "📊 [Report Name]:" | ||
| labels: [report] | ||
| close-older-issues: true | ||
| expires: 30 | ||
| steps: | ||
| - name: setup | ||
| run: | | ||
| mkdir -p /tmp/gh-aw/python/{data,charts} | ||
| mkdir -p /tmp/gh-aw/cache-memory/trending | ||
| pip install --user --quiet numpy pandas matplotlib seaborn scipy | ||
| --- | ||
| ``` | ||
|
|
||
| ## Agent Prompt Structure | ||
|
|
||
| Write the agent prompt as five ordered steps: | ||
|
|
||
| 1. **Load history** — read `/tmp/gh-aw/cache-memory/trending/<metric>/history.jsonl` into a DataFrame if it exists; otherwise start empty. | ||
| 2. **Collect data** — fetch metrics from the GitHub API (or generate with NumPy). Save to `/tmp/gh-aw/python/data/<metric>.csv` — **never inline data in Python code**. | ||
| 3. **Append & prune** — append a JSON Lines record `{"timestamp": "<iso8601>", "metric": "...", "value": ...}` to `history.jsonl`; drop records older than 90 days. | ||
| 4. **Chart** — if ≥ 2 history points exist, generate a time-series line chart with 7-day moving average; otherwise use a bar/distribution chart. Save to `/tmp/gh-aw/python/charts/` at DPI 300. | ||
| 5. **Report** — upload each chart with `upload asset`, then create an issue/discussion embedding the URLs. Call `noop` if there is nothing to report. | ||
|
|
||
| ## Python Patterns | ||
|
|
||
| ### History: load → append → prune | ||
|
|
||
| ```python | ||
| import json, os, pandas as pd | ||
| from datetime import datetime, timedelta | ||
|
|
||
| HISTORY = '/tmp/gh-aw/cache-memory/trending/issues/history.jsonl' | ||
|
|
||
| # Load | ||
| df = pd.read_json(HISTORY, lines=True) if os.path.exists(HISTORY) else pd.DataFrame() | ||
| if not df.empty: | ||
| df['timestamp'] = pd.to_datetime(df['timestamp']) | ||
| df = df.sort_values('timestamp') | ||
|
|
||
| # Append | ||
| with open(HISTORY, 'a') as f: | ||
| f.write(json.dumps({"timestamp": datetime.now().isoformat(), "metric": "issue_count", "value": 42}) + '\n') | ||
|
|
||
| # Prune to 90 days | ||
| if not df.empty: | ||
| df = df[df['timestamp'] >= pd.Timestamp.now() - timedelta(days=90)] | ||
| df.to_json(HISTORY, orient='records', lines=True) | ||
| ``` | ||
|
|
||
| ### Chart: trend with moving average | ||
|
|
||
| ```python | ||
| import matplotlib.pyplot as plt | ||
| import seaborn as sns | ||
|
|
||
| sns.set_style("whitegrid"); sns.set_palette("husl") | ||
| fig, ax = plt.subplots(figsize=(12, 7), dpi=300) | ||
|
|
||
| df['rolling'] = df['value'].rolling(window=7, min_periods=1).mean() | ||
| ax.plot(df['timestamp'], df['value'], label='Actual', alpha=0.5, marker='o') | ||
| ax.plot(df['timestamp'], df['rolling'], label='7-day avg', linewidth=2.5) | ||
| ax.fill_between(df['timestamp'], df['value'], df['rolling'], alpha=0.2) | ||
| ax.set_title('Metric Trend', fontsize=16, fontweight='bold') | ||
| ax.set_xlabel('Date', fontsize=12); ax.set_ylabel('Value', fontsize=12) | ||
| ax.legend(); ax.grid(True, alpha=0.3); plt.xticks(rotation=45); plt.tight_layout() | ||
| plt.savefig('/tmp/gh-aw/python/charts/trend.png', dpi=300, bbox_inches='tight', facecolor='white') | ||
| ``` | ||
|
|
||
| **Chart standards**: 300 DPI · 12×7 in · labeled axes and title · legend for multi-series · `husl` palette | ||
|
|
||
| ### Multiple metrics | ||
|
|
||
| ```python | ||
| for metric in metrics: | ||
| sub = df[df['metric'] == metric] | ||
| ax.plot(sub['timestamp'], sub['value'], marker='o', label=metric, linewidth=2) | ||
| ``` | ||
|
|
||
| ## Report Template | ||
|
|
||
| ```markdown | ||
| # 📊 [Title] — [Date] | ||
|
|
||
| ## Summary | ||
| [2–3 sentences on trends and key findings] | ||
|
|
||
| ### [Metric] Trend | ||
|  | ||
| [direction, moving average, notable events] | ||
|
|
||
| ## Data Details | ||
| - **Source**: … | **Points**: … | **Range**: … | **Period**: …N days | ||
| - **Cache**: `/tmp/gh-aw/cache-memory/trending/` | ||
| ``` | ||
|
|
||
| Use `###` and deeper for all headers inside the report body. | ||
|
|
||
| ## Use Cases | ||
|
|
||
| | Intent | Trigger | Notes | | ||
| |---|---|---| | ||
| | Weekly GitHub activity chart | `schedule` weekly | track issues, PRs, commits | | ||
| | Test coverage trends | `push`/`pull_request` | append per-run | | ||
| | Workflow run durations | `schedule` daily | GitHub Actions API | | ||
| | Stale repo aging distribution | `workflow_dispatch` | no cache needed | | ||
| | Contributor growth | `schedule` monthly | 365-day retention | | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot this file should be self container, import the content needed from shared/*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
imports:frontmatter in 780f8b1 to pull inshared/python-dataviz.md,shared/charts-with-trending.md, andshared/trending-charts-simple.md— the file is now self-contained.