Repository navigation
feat(metrics): adoption baseline snapshot script + daily workflow (UF grant D3/D4) - #480
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 |
|
Looks good to me |
|
Thanks @liquid-8 — LGTM received. Still mergeable and CI-green on b8e3a63; I don't have write access here, so the merge click is yours (or Erik's). After it lands, the daily collector still needs repo secret |
|
Thanks for merging @liquid-8! Post-merge: one setup step needed before snapshots accumulate The daily To enable full snapshots:
Without this secret, the scheduled runs will fail on the traffic step. Other metrics (stars, PyPI downloads) will still work if you want to run without traffic data — but the baseline D3 needs traffic numbers. Once the secret is set, you can trigger a manual run via Actions → Adoption Snapshot → Run workflow to confirm everything works and start accumulating snapshots. The gate for D3 baseline delivery is two snapshots more than one day apart. |
|
Verified the first full retained baseline, @liquid-8: the manual Actions run succeeded at 05:20 UTC today, including strict GitHub Traffic collection. The traffic-token setup is working; no further secret setup request from me. Baseline at 2026-10-12 05:20 UTC:
Retained JSON and Markdown are ready to use as the traffic baseline. The stored daily traffic rows currently cover September 27–October 10. Two limitations for the grant report: the September 2 bootstrap snapshot has no traffic, so we still need a second traffic-bearing snapshot more than 24 hours after today’s to verify accumulation. The daily schedule is 06:00 UTC; today’s second run would not satisfy that spacing. Also, PyPI totals are across all versions: version-split downloads/v4 pickup remain unavailable without the separate BigQuery data. Rolling-window figures are not cumulative grant-period totals, and gaps before collection started cannot be recovered from these snapshots. I’ll verify the next retained full snapshot and close the collection gate; this is baseline tooling/evidence, not a claim that the full D3/D4 grant deliverables are complete. |
|
Collection accumulation confirmed, @liquid-8: 3 traffic-bearing snapshots now in |
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.