feat(metrics): adoption baseline snapshot script + daily workflow (UF grant D3/D4) - #480
TimeToBuildBob wants to merge 6 commits into
Conversation
Adds scripts/adoption_snapshot.py (stdlib-only) that captures:
- GitHub stars, forks, watchers, open issues
- GitHub Traffic: clones/views (14-day window; requires push-access token
— the bundled GH Actions workflow captures this automatically)
- PyPI downloads last day/week/month (pypistats.org)
- Recent release versions and dates
Modes:
Snapshot (default): emits metrics/adoption-YYYY-MM-DD.{json,md}
Report (--report BASELINE.json): prints deltas vs baseline for D4
Also adds .github/workflows/adoption-snapshot.yml (daily at 06:00 UTC)
that runs with the repo's GITHUB_TOKEN so traffic data accumulates before
the 14-day window rolls off.
Initial bootstrap snapshot included (2026-09-02): 1011 stars, 375 forks,
1044 PyPI downloads/month.
Per-version download splits require BigQuery (documented in script TODO).
Co-authored-by: Erik Bjäreholt <erik@bjareho.lt>
Git-Session-Id: 3b38
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #480 +/- ##
===========================================
+ Coverage 60.52% 73.26% +12.74%
===========================================
Files 11 12 +1
Lines 1074 2319 +1245
===========================================
+ Hits 650 1699 +1049
- Misses 424 620 +196 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Greptile SummaryThe PR adds a standard-library adoption-metrics collector and daily automation for preserving short-lived GitHub traffic data.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart LR
Schedule[Daily schedule or manual run] --> Collect[Collect GitHub and PyPI metrics]
Token{Traffic PAT valid?} -->|Yes| Collect
Token -->|No| Fail[Fail closed]
Collect --> Validate{Collectors complete?}
Validate -->|No| Fail
Validate -->|Yes| Write[Write dated JSON and Markdown]
Write --> Commit[Commit snapshot]
Commit --> Rebase[Rebase onto target branch]
Rebase --> Push[Push snapshot]
Reviews (5): Last reviewed commit: "fix(metrics): pin collection clock so mi..." | Re-trigger Greptile |
The default Actions GITHUB_TOKEN cannot read /traffic/* (always 403). The workflow now prefers ADOPTION_GITHUB_TOKEN (PAT), runs --strict so failed/skipped collectors do not commit N/A snapshots, retries 429s, and includes traffic deltas in --report. Push path rebases on conflict.
|
Addressed the Greptile P1s in ec22cd4:
Maintainer gate: please add repo secret
@liquid-8 — secret + review whenever you have a moment. |
Same fix as uniswap-python#479 — the v1 UNI exchange has no remaining liquidity so get_price_output raises EVM error InvalidJump on mainnet fork. Git-Session-Id: 8f77
|
@greptileai review |
GitHub Traffic is a rolling 14-day window, not a cumulative counter. Subtracting two windows produced misleading D4 deltas. Store the daily breakdown (per=day) and union it across snapshots for period clone/view counts. Unique visitors stay point-in-time — they are not additive.
|
@greptileai review |
Report mode included today's still-accumulating GitHub Traffic row in D4 period totals, understating clones/views on every 06:00 UTC run. Drop that day from the reconstructed range and label it excluded.
|
@greptileai review |
…al day complete_period_end() re-read datetime.now() after collect_metrics() had already stamped snapshot_at. A report that started before UTC midnight and finished after kept the earlier snapshot day, skipped exclusion, and published that day's still-accumulating Traffic row as a complete total. Use one collected_at for snapshot_at, the filename, and period-end exclusion. When now is omitted, key off the snapshot day rather than a fresh clock.
|
@greptileai review |
|
Self-merge not eligible here (cross-repo / pull-only). Greptile 5/5 and all checks green on b8e3a63. Waiting for human review or merge. Remaining after merge: repo secret |
What
Adds
scripts/adoption_snapshot.pyand a daily GitHub Actions workflow to capture adoption metrics for the UF grant deliverables D3 (baseline) and D4 (final report with deltas).Why now
GitHub Traffic API only retains 14 days of clone/visitor data. Starting collection before the v0.8.0 production release means the baseline will include pre-release traffic. Waiting until November loses the traffic history.
What it tracks
GITHUB_TOKEN403s on/traffic/*. Daily series is stored so D4 can reconstruct period totals.Per-version download splits (to directly answer "any v4 pickup?") require BigQuery; documented in script as a TODO.
How it works
The daily workflow runs at 06:00 UTC. It reads repo secret
ADOPTION_GITHUB_TOKENfor traffic collection, runs--strict(no N/A commits on collector failure), and rebases before push. Please add that secret — without it every scheduled run will fail closed rather than write empty traffic.GitHub Traffic
*_14dfields are rolling 14-day windows, not cumulative counters. Report mode does not subtract them. Period clone/view counts are the union of stored daily series. The current UTC day is excluded from those totals (its row is still accumulating). Unique cloners/visitors cannot be summed across days.Initial baseline (2026-09-02)
Dependencies
None — stdlib only (
urllib,json,argparse,datetime,pathlib).Drafted by Bob (AI agent). Yohan, feel free to adjust the cron schedule or output directory as needed.