Index: dashboard/dashboard/find_anomalies.py |
diff --git a/dashboard/dashboard/find_anomalies.py b/dashboard/dashboard/find_anomalies.py |
index 6029789c00f9e4ab2081a634c6424b6bc93cb70c..6ba5e7e9b667721c5600a253ad7714cda7cddb96 100644 |
--- a/dashboard/dashboard/find_anomalies.py |
+++ b/dashboard/dashboard/find_anomalies.py |
@@ -23,6 +23,7 @@ from dashboard.models import anomaly |
from dashboard.models import anomaly_config |
from dashboard.models import graph_data |
from dashboard.models import histogram |
+from tracing.value.diagnostics import reserved_infos |
# Number of points to fetch and pass to FindChangePoints. A different number |
# may be used if a test has a "max_window_size" anomaly config parameter. |
@@ -324,6 +325,15 @@ def _MakeAnomalyEntity(change_point, test, rows): |
display_start, display_end = _GetDisplayRange(change_point.x_value, rows) |
median_before = change_point.median_before |
median_after = change_point.median_after |
+ |
+ ownership_component = GetMostRecentDiagnosticValueByName( |
+ test.key, reserved_infos.BUG_COMPONENTS.name) |
+ ownership_owners = GetMostRecentDiagnosticValueByName( |
+ test.key, reserved_infos.OWNERS.name) |
+ ownership_information = { |
+ 'emails': (ownership_owners or None), |
+ 'component': (ownership_component[0] if ownership_component else None)} |
+ |
return anomaly.Anomaly( |
start_revision=start_rev, |
end_revision=end_rev, |
@@ -344,8 +354,7 @@ def _MakeAnomalyEntity(change_point, test, rows): |
units=test.units, |
display_start=display_start, |
display_end=display_end, |
- ownership=GetMostRecentDiagnosticData(test.key, 'Ownership')) |
- |
+ ownership=ownership_information) |
def FindChangePointsForTest(rows, config_dict): |
"""Gets the anomaly data from the anomaly detection module. |
@@ -380,6 +389,30 @@ def _IsImprovement(test, median_before, median_after): |
return True |
return False |
+def GetMostRecentDiagnosticValueByName(test_key, diagnostic_name): |
+ """Gets the data in the latests sparse diagnostic with the given |
+ diagnostic name. |
+ |
+ Args: |
+ test_key: The TestKey entity to lookup the diagnotics by |
+ diagnostic_name: the name of the diagnostics to look up |
+ |
+ Returns: |
+ The diagnostic's values. |
+ None if no diagnostics are found with the given keys or type. |
+ """ |
+ diagnostics = histogram.SparseDiagnostic.query(ndb.AND( |
+ histogram.SparseDiagnostic.end_revision == sys.maxint, |
+ histogram.SparseDiagnostic.test == test_key)).fetch() |
+ |
+ diagnostics_named = [d for d in diagnostics if d.name == diagnostic_name] |
+ |
+ for diagnostic in diagnostics_named: |
+ diagnostic_data = json.loads(diagnostic.data) |
+ return diagnostic_data.get('values') |
+ |
+ return None |
+ |
def GetMostRecentDiagnosticData(test_key, diagnostic_type): |
"""Gets the data in the latest sparse diagnostic for the given |