feat: API provider and PyPI publishing (0.2.0) - #2
Conversation
APIFeatureProvider loads one toggle group from a YaFT backend with urllib alone: hash first, group only on change, hash recorded only after the group loaded (R30). refresh() returns whether new data came and raises RefreshError otherwise (R32); refresh_quietly() logs for schedulers. No redirects, a body limit, a deadline that also covers a trickling body, and lookup by name within the group. It sends its own User-Agent: Cloudflare in front of yaft.tehwolf.de answers urllib's "Python-urllib/3.x" with 403, so every refresh would have failed. The suite's refresh cases now run through the provider against a local stand-in backend instead of LocalFeatureProvider.load. publish.yml uploads the build artifact of a push to main via Trusted Publishing, since that cannot name a reusable workflow from another repository. Claude-Session: https://claude.ai/code/session_01RxukupkbvZyVVFzDRuiniV
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Essentials Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (11)
Included review availability: This review used your included allowance. 2 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour. 📝 WalkthroughWalkthroughThe pull request adds and exports ChangesAPI provider and package release
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant Application
participant APIFeatureProvider
participant YaFTBackend
Application->>APIFeatureProvider: refresh()
APIFeatureProvider->>YaFTBackend: request collection hash
YaFTBackend-->>APIFeatureProvider: return collection hash
APIFeatureProvider->>YaFTBackend: request group features when hash changes
YaFTBackend-->>APIFeatureProvider: return group features
APIFeatureProvider-->>Application: return refresh result
Merge Risk: ⚪ Minimal · up to This change adds an API-backed feature provider, its tests and docs, and a PyPI publishing workflow. No actionable merge-blocking risk is evident. PyPI Trusted Publisher configuration must be completed on the PyPI side, and later merges must bump the version. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 22.86% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 35 functions across 6 files. (5 skipped: 5 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
Stage 2 of yaft-python: the API provider, and publishing to PyPI.
API provider
APIFeatureProvider(base_url, group)loads one toggle group from a YaFT backend overurlliband adds no dependency.refresh() -> bool: asks/collectionHash/{uuid}first and fetches/features/{uuid}only when the hash changed. The hash is recorded only after the group was applied, so a failed refresh is retried (R30). A body that is not a group raisesRefreshError(R32), and the old data stays.refresh_quietly()for schedulers: it logs the failure instead of raising.max_body_bytes(default 1 MiB), and atimeoutthat also cuts off a body that trickles in (read1plus a deadline). A body of nothing but[givesRecursionError; that is caught too.uuid|namekey, the same as yaft-go and yaft-java.yaft-python/<version>. Cloudflare in front ofyaft.tehwolf.deanswers urllib's defaultPython-urllib/3.xwith 403. The smoke test against the live backend found this; before the fix every refresh failed.Conformance
The suite's refresh cases now run through
APIFeatureProviderover HTTP, against a local stand-in backend (tests/backend.py), and no longer throughLocalFeatureProvider.load.retrycomes with the same hash as the rejected body.PyPI
.github/workflows/publish.ymluploads thebuildartifact of a push tomainthrough Trusted Publishing, in environmentpypi. It does not live intehw0lf/workflowsbecause a Trusted Publisher cannot name a reusable workflow from another repository. Pull requests from forks are excluded explicitly.Before merging: create a pending Trusted Publisher on pypi.org with project
yaft, ownertehw0lf, repositoryyaft-python, workflowpublish.ymland environmentpypi.Checked
uv build.yaft.tehwolf.de: the first refresh returnsTrueand the secondFalse, with no second fetch. The playground groups are currently empty.https://claude.ai/code/session_01RxukupkbvZyVVFzDRuiniV
Summary by CodeRabbit
yaftpackage on PyPI.