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

Function apply_experiment_rollout

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

Source from the content-addressed store, hash-verified

628
629
630def apply_experiment_rollout(experiment: Experiment, spec: RolloutSpec) -> None:
631 if experiment.status == ExperimentStatus.COMPLETED:
632 raise ValidationError(
633 f"Cannot change the rollout of a {experiment.status} experiment."
634 )
635 validate_rollout_spec(experiment, spec)
636 environment_id = experiment.environment_id
637 with transaction.atomic():
638 segment = _sync_rollout_segment(experiment, spec.rollout_percentage)
639 _update_rollout_in_place(
640 experiment,
641 FlagChangeSet(
642 author=spec.author,
643 enabled=spec.enabled,
644 feature_state_value=spec.feature_state_value,
645 type_=spec.value_type,
646 segment_id=segment.id,
647 multivariate_values=spec.multivariate_values,
648 ),
649 )
650 # Segment condition changes don't trigger a rebuild on their own.
651 transaction.on_commit(
652 lambda: rebuild_environment_document.delay(
653 kwargs={"environment_id": environment_id}
654 )
655 )
656
657
658def get_experiment_rollout(experiment: Experiment) -> dict[str, typing.Any] | None:

Callers 3

createMethod · 0.90
rolloutMethod · 0.90
experiment_with_rolloutFunction · 0.90

Calls 4

FlagChangeSetClass · 0.90
validate_rollout_specFunction · 0.85
_sync_rollout_segmentFunction · 0.85
_update_rollout_in_placeFunction · 0.85

Tested by 1

experiment_with_rolloutFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…