Skip to content

Commit

Permalink
Revert "Bug 1919588 - Add a new testing alert table, along with new f…
Browse files Browse the repository at this point in the history
…ields. (#8200)" for uniqueness failure

This reverts commit fb59b00.
  • Loading branch information
Archaeopteryx committed Oct 16, 2024
1 parent 34fb534 commit 2f33cc4
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 91 deletions.
11 changes: 4 additions & 7 deletions tests/perfalert/test_alert_modification.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ def test_reassigning_regression(

assert s.status == PerformanceAlertSummary.UNTRIAGED

# reassigning a regression that was in the first summary
# to the second summary should leave the status as UNTRIAGED
reassigned_alert = create_perf_alert(
# reassigning a regression to the initial summary
# which contains only an improvement
create_perf_alert(
summary=s,
series_signature=signature1,
related_summary=test_perf_alert_summary_2,
Expand All @@ -117,12 +117,9 @@ def test_reassigning_regression(
# the regression alert will keep it's status of REASSIGNED
untriaged_improvement_alert.status = PerformanceAlert.ACKNOWLEDGED
untriaged_improvement_alert.save()
assert reassigned_alert.status == PerformanceAlert.REASSIGNED

# Status of the summary with only improvements should automatically
# have a status of IMPROVEMENT
s = PerformanceAlertSummary.objects.get(id=1)
assert s.status == PerformanceAlertSummary.IMPROVEMENT
assert s.status == PerformanceAlertSummary.INVESTIGATING


def test_improvement_summary_status_after_reassigning_regression(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Generated by Django 5.1.2 on 2024-10-16 18:38

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("perf", "0054_performancealert_confidence_and_more"),
]

operations = [
migrations.RemoveField(
model_name="performancealerttesting",
name="related_summary",
),
migrations.RemoveField(
model_name="performancealerttesting",
name="summary",
),
migrations.AlterUniqueTogether(
name="performancealerttesting",
unique_together=None,
),
migrations.RemoveField(
model_name="performancealerttesting",
name="classifier",
),
migrations.RemoveField(
model_name="performancealerttesting",
name="series_signature",
),
migrations.RemoveField(
model_name="performancealert",
name="confidence",
),
migrations.RemoveField(
model_name="performancealert",
name="detection_method",
),
migrations.DeleteModel(
name="PerformanceAlertSummaryTesting",
),
migrations.DeleteModel(
name="PerformanceAlertTesting",
),
]
117 changes: 33 additions & 84 deletions treeherder/perf/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def __str__(self):
return f"{self.name} (tasks via {self.task_base_url})"


class PerformanceAlertSummaryBase(models.Model):
class PerformanceAlertSummary(models.Model):
"""
A summarization of performance alerts
Expand Down Expand Up @@ -351,109 +351,88 @@ def update_status(self, using=None):
self.status = self.autodetermine_status()
self.save(using=using)

def autodetermine_status(self, alert_model=None):
summary_class = self.__class__
if not alert_model:
alert_model = PerformanceAlert

alerts = alert_model.objects.filter(summary=self) | alert_model.objects.filter(
def autodetermine_status(self):
alerts = PerformanceAlert.objects.filter(summary=self) | PerformanceAlert.objects.filter(
related_summary=self
)

# if no alerts yet, we'll say untriaged
if not alerts:
return summary_class.UNTRIAGED
return PerformanceAlertSummary.UNTRIAGED

# if any untriaged, then set to untriaged
if any(alert.status == alert_model.UNTRIAGED for alert in alerts):
return summary_class.UNTRIAGED
if any(alert.status == PerformanceAlert.UNTRIAGED for alert in alerts):
return PerformanceAlertSummary.UNTRIAGED

# if the summary's status is IMPROVEMENT, but a regression is
# reassigned to that summary then set the summary's status to untriaged
# and change all acknowledged statuses to untriaged
if self.status == summary_class.IMPROVEMENT:
if self.status == PerformanceAlertSummary.IMPROVEMENT:
if any(
alert.status == alert_model.REASSIGNED and alert.is_regression for alert in alerts
alert.status == PerformanceAlert.REASSIGNED and alert.is_regression
for alert in alerts
):
acknowledged_alerts = [
alert for alert in alerts if alert.status == alert_model.ACKNOWLEDGED
alert for alert in alerts if alert.status == PerformanceAlert.ACKNOWLEDGED
]
for alert in acknowledged_alerts:
alert.status = alert_model.UNTRIAGED
alert.status = PerformanceAlert.UNTRIAGED
alert.save()
return summary_class.UNTRIAGED
return PerformanceAlertSummary.UNTRIAGED

# if all invalid, then set to invalid
if all(alert.status == alert_model.INVALID for alert in alerts):
return summary_class.INVALID
if all(alert.status == PerformanceAlert.INVALID for alert in alerts):
return PerformanceAlertSummary.INVALID

# otherwise filter out invalid alerts
alerts = [a for a in alerts if a.status != alert_model.INVALID]
alerts = [a for a in alerts if a.status != PerformanceAlert.INVALID]

# if there are any "acknowledged" alerts, then set to investigating
# if not one of the resolved statuses and there are regressions,
# otherwise we'll say it's an improvement
if any(alert.status == alert_model.ACKNOWLEDGED for alert in alerts):
if any(alert.status == PerformanceAlert.ACKNOWLEDGED for alert in alerts):
if all(
not alert.is_regression
for alert in alerts
if alert.status == alert_model.ACKNOWLEDGED
or (alert.status == alert_model.REASSIGNED and alert.related_summary.id == self.id)
if alert.status == PerformanceAlert.ACKNOWLEDGED
or alert.status == PerformanceAlert.REASSIGNED
):
return summary_class.IMPROVEMENT
return PerformanceAlertSummary.IMPROVEMENT
elif self.status not in (
summary_class.IMPROVEMENT,
summary_class.INVESTIGATING,
summary_class.WONTFIX,
summary_class.FIXED,
summary_class.BACKED_OUT,
PerformanceAlertSummary.IMPROVEMENT,
PerformanceAlertSummary.INVESTIGATING,
PerformanceAlertSummary.WONTFIX,
PerformanceAlertSummary.FIXED,
PerformanceAlertSummary.BACKED_OUT,
):
return summary_class.INVESTIGATING
return PerformanceAlertSummary.INVESTIGATING
# keep status if one of the investigating ones
return self.status

# at this point, we've determined that this is a summary with no valid
# alerts of its own: all alerts should be either reassigned,
# downstream, or invalid (but not all invalid, that case is covered
# above)
if any(alert.status == alert_model.REASSIGNED for alert in alerts):
return summary_class.REASSIGNED
if any(alert.status == PerformanceAlert.REASSIGNED for alert in alerts):
return PerformanceAlertSummary.REASSIGNED

return summary_class.DOWNSTREAM
return PerformanceAlertSummary.DOWNSTREAM

def timestamp_first_triage(self):
# called for summary specific updates (e.g. notes, bug linking)
if self.first_triaged is None:
self.first_triaged = django_now()
return self

class Meta:
abstract = True

def __str__(self):
return f"{self.framework} {self.repository} {self.prev_push.revision}-{self.push.revision}"


class PerformanceAlertSummary(PerformanceAlertSummaryBase):
class Meta:
db_table = "performance_alert_summary"
unique_together = ("repository", "framework", "prev_push", "push")


class PerformanceAlertSummaryTesting(PerformanceAlertSummaryBase):
assignee = models.ForeignKey(
User, on_delete=models.SET_NULL, null=True, related_name="assigned_alerts_testing"
)

def autodetermine_status(self, alert_model=None):
super().autodetermine_status(alert_model=PerformanceAlertTesting)

class Meta:
db_table = "performance_alert_summary_testing"
unique_together = ("repository", "framework", "prev_push", "push")
def __str__(self):
return f"{self.framework} {self.repository} {self.prev_push.revision}-{self.push.revision}"


class PerformanceAlertBase(models.Model):
class PerformanceAlert(models.Model):
"""
A single performance alert
Expand Down Expand Up @@ -517,15 +496,6 @@ class PerformanceAlertBase(models.Model):
null=True,
)

confidence = models.FloatField(
help_text=(
"A value that indicates the confidence of the alert (specific to "
"the detection method used)"
),
null=True,
)
detection_method = models.CharField(max_length=100, null=True)

SKEWED = "SKEWED"
OUTLIERS = "OUTLIERS"
MODAL = "MODAL"
Expand Down Expand Up @@ -616,33 +586,12 @@ def timestamp_first_triage(self):
self.summary.timestamp_first_triage().save()
return self

class Meta:
abstract = True

def __str__(self):
return f"{self.summary} {self.series_signature} {self.amount_pct}%"


class PerformanceAlert(PerformanceAlertBase):
class Meta:
db_table = "performance_alert"
unique_together = ("summary", "series_signature")


class PerformanceAlertTesting(PerformanceAlertBase):
summary = models.ForeignKey(
PerformanceAlertSummaryTesting, on_delete=models.CASCADE, related_name="alerts"
)
related_summary = models.ForeignKey(
PerformanceAlertSummaryTesting,
on_delete=models.CASCADE,
related_name="related_alerts",
null=True,
)

class Meta:
db_table = "performance_alert_testing"
unique_together = ("summary", "series_signature")
def __str__(self):
return f"{self.summary} {self.series_signature} {self.amount_pct}%"


class PerformanceTag(models.Model):
Expand Down

0 comments on commit 2f33cc4

Please sign in to comment.