chore(): minor fixes around codebase

This commit is contained in:
ITQ
2026-02-24 10:35:25 +03:00
parent 16b48fee40
commit 50941c1321
12 changed files with 62 additions and 33 deletions
+3 -6
View File
@@ -28,11 +28,6 @@ from apps.notifications.services import (
)
from apps.reports.services import calculate_metric_value
_ACTION_SEVERITY = {
GuardrailAction.ROLLBACK: 0,
GuardrailAction.PAUSE: 1,
}
@transaction.atomic
def guardrail_create(
@@ -69,6 +64,7 @@ def guardrail_update(
guardrail: Guardrail,
**fields: Any,
) -> Guardrail:
guardrail.experiment.refresh_from_db(fields=["status"])
if guardrail.experiment.status in STARTED_STATUSES:
raise ValidationError(
{
@@ -96,6 +92,7 @@ def guardrail_update(
def guardrail_delete(*, guardrail: Guardrail) -> None:
guardrail.experiment.refresh_from_db(fields=["status"])
if guardrail.experiment.status in STARTED_STATUSES:
raise ValidationError(
{
@@ -171,7 +168,7 @@ def _execute_guardrail_action(
guardrail: Guardrail,
experiment: Experiment,
actual_value: Decimal,
) -> GuardrailTrigger:
) -> GuardrailTrigger | None:
now = timezone.now()
experiment = Experiment.objects.select_for_update().get(pk=experiment.pk)