Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
📝 Walkthrough
Merge Risk: 🟡 Moderate · up to
|
|
@themis-blindfold review |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8798 +/- ##
=======================================
Coverage 98.87% 98.87%
=======================================
Files 1678 1678
Lines 69561 69574 +13
=======================================
+ Hits 68775 68788 +13
Misses 786 786 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Organization UI
- Review profile: ASSERTIVE
- Plan: Advanced
- Run ID:
cb908b70-0bd2-4960-8ef9-fa455bc0cc41
📒 Files selected for processing: 3
api/experimentation/services.pyapi/tests/unit/experimentation/test_services.pydocs/docs/deployment-self-hosting/observability/_events-catalogue.md
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.
| additional_filters=Q( | ||
| feature_segment__segment_id=experiment.rollout_segment_id, | ||
| identity__isnull=True, | ||
| ), |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Account for split changes within the results window.
If a running experiment changes its variant weights, this query returns only the current split. build_results_summary compares that split with exposures aggregated across the results window. Exposures assigned under the earlier split can therefore produce a false SRM alert. Use allocation history for the exposure window, or restrict the check to exposures collected under one stable split.
| if mv_value.percentage_allocation > 0: | ||
| # A zero share has no expected traffic to test against. | ||
| shares[key] = mv_value.percentage_allocation / 100 |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
rg -n 'expected_shares|srm_p_value' api/experimentation/services.py
git diff b6d69889652df199a21dfa9f64a2c8a7550936f0 bb65e7e3e3d7e565e70dcf30058e3e5cffd3647d -- api/experimentation/services.pyRepository: Flagsmith/flagsmith
Length of output: 3006
🏁 Script executed:
set -eu
printf '%s\n' '--- current services.py relevant block ---'
nl -ba api/experimentation/services.py | sed -n '250,420p'
printf '%s\n' '--- merge-base services.py relevant block ---'
git show b6d69889652df199a21dfa9f64a2c8a7550936f0:api/experimentation/services.py | nl -ba | sed -n '250,420p'
printf '%s\n' '--- srm_p_value declaration and implementation references ---'
rg -n -F --glob '*.py' -e 'def srm_p_value' -e 'srm_p_value(' .
printf '%s\n' '--- exposure_counts construction and relevant tests ---'
rg -n -F --glob '*.py' -e 'exposure_counts' -e 'expected_shares' -e 'Sample ratio mismatch' tests apiRepository: Flagsmith/flagsmith
Length of output: 21276
🏁 Script executed:
set -eu
printf '%s\n' '--- srm_p_value implementation ---'
nl -ba api/experimentation/stats.py | sed -n '80,115p'
printf '%s\n' '--- focused build_results_summary tests ---'
nl -ba api/tests/unit/experimentation/test_services.py | sed -n '1160,1355p'
printf '%s\n' '--- exposure aggregation implementation ---'
nl -ba api/experimentation/results_query.py | sed -n '285,325p'Repository: Flagsmith/flagsmith
Length of output: 11975
Flag exposures for variants outside expected_shares.
When a zero-weight variant has exposures, _expected_variant_shares excludes it. build_results_summary then omits its count from srm_p_value, which can hide an SRM mismatch.
Do not restore a zero share directly. srm_p_value returns None for non-positive expected shares. Detect positive exposure counts for keys absent from expected_shares and report a mismatch instead.
Suggested fix
if expected_shares and total >= SRM_MIN_TOTAL_IDENTITIES:
- srm = srm_p_value(
- [exposure_counts.get(variant, 0) for variant in expected_shares],
- list(expected_shares.values()),
- )
+ has_unexpected_exposures = any(
+ count > 0
+ for variant, count in exposure_counts.items()
+ if variant not in expected_shares
+ )
+ if has_unexpected_exposures:
+ srm = 0.0
+ else:
+ srm = srm_p_value(
+ [exposure_counts.get(variant, 0) for variant in expected_shares],
+ list(expected_shares.values()),
+ )
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature.Changes
srm_p_valuewasnullfor every experiment: expected variant shares were read from the environment default, which starting an experiment resets to 0% (all control), so the chi-square test bailed out.How did you test this code?
Unit tests in
tests/unit/experimentation/test_services.py; experimentation suite passes (757).