(experiment: Experiment, spec: RolloutSpec)
| 628 | |
| 629 | |
| 630 | def 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 | |
| 658 | def get_experiment_rollout(experiment: Experiment) -> dict[str, typing.Any] | None: |
searching dependent graphs…