You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: expose client readiness for local evaluation - #280
When the initial environment-document fetch fails, applications using local evaluation cannot tell whether evaluating a flag will use the local document or fall back to the remote API. Add a non-blocking Flagsmith.ready() check so callers can use their own fallback until the background poller has loaded a document.
Local and offline clients are ready when an environment document is available. A failed refresh leaves the last successful document usable and readiness stays true.
Remote-evaluation clients are immediately ready; this is not an API connectivity or freshness check.
Readiness makes no requests and does not alter evaluation or fallback semantics. The README shows how to guard evaluations to avoid per-evaluation remote fallback during an initial outage. Changing fallback behavior automatically would break existing callers, so this takes the explicit readiness-API approach requested in the issue.
The three new tests fail on unchanged upstream because ready() is absent.
pytest -q: 381 passed, including initial fetch failure, recovery, subsequent refresh failure, remote evaluation and offline evaluation.
mypy --strict .: passed, 33 source files.
Configured Black, isort and Flake8 checks passed for both changed Python files.
git diff --check: passed.
Validated on Python 3.12.13 / Windows using the repository's declared dependency ranges. AI assistance was used to implement and test this contribution.
No actionable comments were generated in the recent review.
Walkthrough
The client adds Flagsmith.ready(). The method returns True for remote evaluation. For local or offline evaluation, it returns whether an environment document is loaded. The method does not make requests or wait for data. Tests cover readiness before and after environment updates, including a failed later update. The README documents the method and shows how to check readiness before evaluating a flag.
This adds a non-blocking readiness check with accompanying tests and documentation. The earlier documentation inaccuracy about realtime clients has been corrected, and no merge-blocking risk remains.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: ASSERTIVE
Plan: Advanced
Run ID: ca560bd8-0457-49cc-933f-0b0ea7f15fdf
Commits
Reviewing files that changed from the base of the PR and between 2af2aad and f3eeaf2.
Files selected for processing: 3
README.md
flagsmith/flagsmith.py
tests/test_flagsmith.py
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: ASSERTIVE
Plan: Advanced
Run ID: 18e99f3f-37bd-494d-bffb-559a107426c3
Commits
Reviewing files that changed from the base of the PR and between b995df4 and 2af2aad.
Files selected for processing: 3
README.md
flagsmith/flagsmith.py
tests/test_flagsmith.py
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
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
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.
Summary
When the initial environment-document fetch fails, applications using local evaluation cannot tell whether evaluating a flag will use the local document or fall back to the remote API. Add a non-blocking
Flagsmith.ready()check so callers can use their own fallback until the background poller has loaded a document.Fixes #197
Verification
ready()is absent.pytest -q: 381 passed, including initial fetch failure, recovery, subsequent refresh failure, remote evaluation and offline evaluation.mypy --strict .: passed, 33 source files.git diff --check: passed.Validated on Python 3.12.13 / Windows using the repository's declared dependency ranges. AI assistance was used to implement and test this contribution.