(experiment_id: int)
| 75 | |
| 76 | @register_task_handler() |
| 77 | def compute_experiment_exposures(experiment_id: int) -> None: |
| 78 | experiment = ( |
| 79 | Experiment.objects.select_related("environment__project", "feature") |
| 80 | .filter(id=experiment_id) |
| 81 | .first() |
| 82 | ) |
| 83 | if experiment is None or not experiment.started_at: |
| 84 | return |
| 85 | |
| 86 | exposures, _ = ExperimentExposures.objects.get_or_create(experiment=experiment) |
| 87 | if exposures.is_final: |
| 88 | return |
| 89 | |
| 90 | as_of = experiment.ended_at or timezone.now() |
| 91 | try: |
| 92 | summary = compute_exposures_summary( |
| 93 | environment_key=experiment.environment.api_key, |
| 94 | feature_name=experiment.feature.name, |
| 95 | window_start=experiment.started_at, |
| 96 | window_end=as_of, |
| 97 | ) |
| 98 | except Exception as exc: |
| 99 | exposures.record_failure() |
| 100 | logger.error( |
| 101 | "exposures.compute_failed", |
| 102 | exc_info=exc, |
| 103 | experiment__id=experiment.id, |
| 104 | environment__id=experiment.environment_id, |
| 105 | organisation__id=experiment.environment.project.organisation_id, |
| 106 | ) |
| 107 | return |
| 108 | |
| 109 | exposures.record_refresh(summary, as_of) |
| 110 | |
| 111 | |
| 112 | @register_task_handler() |
searching dependent graphs…