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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « appengine/findit/crash/classifier.py ('k') | appengine/findit/crash/fracas.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import logging
6
7 from crash.classifier import Classifier
8 from model.crash.crash_config import CrashConfig
9
10
11 class ComponentClassifier(Classifier):
12 """Determines the component of a crash.
13
14 For example: ['Blink>DOM', 'Blink>HTML'].
15 """
16
17 def __init__(self):
18 super(ComponentClassifier, self).__init__()
19 self.component_classifier_config = (
20 CrashConfig.Get().compiled_component_classifier)
21
22 def GetClassFromStackFrame(self, frame):
23 """Gets the component from file path and function of a frame."""
24 for path_regex, function_regex, component in (
25 self.component_classifier_config['path_function_component']):
26 path_match = path_regex.match(frame.dep_path + frame.file_path)
27 if not path_match:
28 continue
29
30 if not function_regex:
31 return component
32
33 function_match = function_regex.match(frame.function)
34 if function_match:
35 return component
36
37 return ''
38
39 def GetClassFromResult(self, result):
40 """Gets the component from a result.
41
42 Note that Findit assumes files that the culprit result touched come from
43 the same component.
44 """
45 if result.file_to_stack_infos:
46 # A file in culprit result should always have its stack_info, namely a
47 # list of (frame, callstack_priority) pairs.
48 frame, _ = result.file_to_stack_infos.values()[0][0]
49 return self.GetClassFromStackFrame(frame)
50
51 return ''
52
53 def Classify(self, results, crash_stack):
54 """Classifies project of a crash.
55
56 Args:
57 results (list of Result): Culprit results.
58 crash_stack (CallStack): The callstack that caused the crash.
59
60 Returns:
61 List of top 2 components.
62 """
63 if not self.component_classifier_config:
64 logging.warning('Empty configuration for component classifier.')
65 return []
66
67 return self._Classify(results, crash_stack,
68 self.component_classifier_config['top_n'], 2)
OLDNEW
« 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