Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3822)

Unified Diff: appengine/findit/crash/component_classifier.py

Issue 1914113002: [Findit] Enable project classifier and component classifier (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/findit/crash/classifier.py ('k') | appengine/findit/crash/fracas.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/crash/component_classifier.py
diff --git a/appengine/findit/crash/component_classifier.py b/appengine/findit/crash/component_classifier.py
new file mode 100644
index 0000000000000000000000000000000000000000..281b31ea979f92efa89e085fa253a1c0161804a6
--- /dev/null
+++ b/appengine/findit/crash/component_classifier.py
@@ -0,0 +1,68 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import logging
+
+from crash.classifier import Classifier
+from model.crash.crash_config import CrashConfig
+
+
+class ComponentClassifier(Classifier):
+ """Determines the component of a crash.
+
+ For example: ['Blink>DOM', 'Blink>HTML'].
+ """
+
+ def __init__(self):
+ super(ComponentClassifier, self).__init__()
+ self.component_classifier_config = (
+ CrashConfig.Get().compiled_component_classifier)
+
+ def GetClassFromStackFrame(self, frame):
+ """Gets the component from file path and function of a frame."""
+ for path_regex, function_regex, component in (
+ self.component_classifier_config['path_function_component']):
+ path_match = path_regex.match(frame.dep_path + frame.file_path)
+ if not path_match:
+ continue
+
+ if not function_regex:
+ return component
+
+ function_match = function_regex.match(frame.function)
+ if function_match:
+ return component
+
+ return ''
+
+ def GetClassFromResult(self, result):
+ """Gets the component from a result.
+
+ Note that Findit assumes files that the culprit result touched come from
+ the same component.
+ """
+ if result.file_to_stack_infos:
+ # A file in culprit result should always have its stack_info, namely a
+ # list of (frame, callstack_priority) pairs.
+ frame, _ = result.file_to_stack_infos.values()[0][0]
+ return self.GetClassFromStackFrame(frame)
+
+ return ''
+
+ def Classify(self, results, crash_stack):
+ """Classifies project of a crash.
+
+ Args:
+ results (list of Result): Culprit results.
+ crash_stack (CallStack): The callstack that caused the crash.
+
+ Returns:
+ List of top 2 components.
+ """
+ if not self.component_classifier_config:
+ logging.warning('Empty configuration for component classifier.')
+ return []
+
+ return self._Classify(results, crash_stack,
+ self.component_classifier_config['top_n'], 2)
« no previous file with comments | « appengine/findit/crash/classifier.py ('k') | appengine/findit/crash/fracas.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698