feat(__future__): Identify MV options by key in experimental update-flags endpoint#8000
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Docker builds report
|
Playwright Test Results (oss - depot-ubuntu-latest-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)Details
|
Visual Regression19 screenshots compared. See report for details. |
31389bf to
0c2b855
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feat/multivariate-update-flag-endpoints #8000 +/- ##
========================================================================
Coverage 98.64% 98.64%
========================================================================
Files 1498 1498
Lines 59410 59494 +84
========================================================================
+ Hits 58604 58688 +84
Misses 806 806 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
0c2b855 to
541931c
Compare
| def _validate_overrides_reweight_environment_options( | ||
| feature: Feature, | ||
| environment_multivariate_values: Sequence[EnvironmentMultivariateValuePayload], | ||
| override_multivariate_value_lists: Sequence[ | ||
| Sequence[SegmentOverrideMultivariateValuePayload] | ||
| ], | ||
| ) -> None: | ||
| option_id_by_key: dict[str, int] = { | ||
| key: option_id | ||
| for key, option_id in feature.multivariate_options.filter( | ||
| key__isnull=False | ||
| ).values_list("key", "id") | ||
| if key is not None | ||
| } | ||
| allowed_keys = {mv["key"] for mv in environment_multivariate_values if "key" in mv} | ||
| allowed_option_ids = { | ||
| mv["multivariate_feature_option"] | ||
| for mv in environment_multivariate_values | ||
| if "multivariate_feature_option" in mv | ||
| } | {option_id_by_key[key] for key in allowed_keys if key in option_id_by_key} | ||
| for multivariate_values in override_multivariate_value_lists: | ||
| for mv in multivariate_values: | ||
| if "multivariate_feature_option" in mv: | ||
| allowed = mv["multivariate_feature_option"] in allowed_option_ids | ||
| else: | ||
| allowed = ( | ||
| mv["key"] in allowed_keys | ||
| or option_id_by_key.get(mv["key"]) in allowed_option_ids | ||
| ) | ||
| if not allowed: | ||
| raise serializers.ValidationError( | ||
| { | ||
| "multivariate_feature_state_values": [ | ||
| "Segment overrides can only re-weight existing variants." | ||
| ] | ||
| } | ||
| ) |
There was a problem hiding this comment.
Can you explain why we need this together with _validate_multivariate_keys_exist?
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature.Changes
Timeline for context
"key"attribute to identify multivariate options (feat(multivariate): add per-feature unique key to multivariate options #7698).Changes
Contributes to #7642
Similarly to how a feature can be identified in the experimental update-flag endpoints, i.e. by either its ID or name, now we allow multivariate options to be identified by either their ID or [the new] key.
This means to make it easier to use update-flag, eliminating retrieving an MV ID as an extra step to achieving the use case of updating or re-weighting multivariates.
How did you test this code?
New tests.