MCPcopy Create free account
hub / github.com/Flagsmith/flagsmith / validate_rollout_spec

Function validate_rollout_spec

api/experimentation/services.py:548–563  ·  view source on GitHub ↗
(experiment: Experiment, spec: RolloutSpec)

Source from the content-addressed store, hash-verified

546
547
548def 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
566def _sync_rollout_segment(experiment: Experiment, rollout_percentage: float) -> Segment:

Callers 1

apply_experiment_rolloutFunction · 0.85

Calls 2

sortedFunction · 0.85
setFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…