(experiment: Experiment, spec: RolloutSpec)
| 546 | |
| 547 | |
| 548 | def validate_rollout_spec(experiment: Experiment, spec: RolloutSpec) -> None: |
| 549 | option_ids = [v.multivariate_feature_option_id for v in spec.multivariate_values] |
| 550 | if len(option_ids) != len(set(option_ids)): |
| 551 | raise ValidationError("Multivariate options must be unique") |
| 552 | valid_option_ids = set( |
| 553 | experiment.feature.multivariate_options.values_list("id", flat=True) |
| 554 | ) |
| 555 | if invalid := set(option_ids) - valid_option_ids: |
| 556 | raise ValidationError( |
| 557 | f"Multivariate options {sorted(invalid)} do not belong to the feature" |
| 558 | ) |
| 559 | total = sum(v.percentage_allocation for v in spec.multivariate_values) |
| 560 | if total > 100: |
| 561 | raise ValidationError( |
| 562 | f"Multivariate allocations must not exceed 100%, got {total}%." |
| 563 | ) |
| 564 | |
| 565 | |
| 566 | def _sync_rollout_segment(experiment: Experiment, rollout_percentage: float) -> Segment: |
no test coverage detected
searching dependent graphs…