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

Side by Side Diff: appengine/findit/crash/loglinear/changelist_classifier.py

Issue 2663063007: [Predator] Switch from anonymous dict to CrashData. (Closed)
Patch Set: Rebase and fix delta test. Created 3 years, 10 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
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from collections import defaultdict 5 from collections import defaultdict
6 import logging 6 import logging
7 7
8 from common.chrome_dependency_fetcher import ChromeDependencyFetcher 8 from common.chrome_dependency_fetcher import ChromeDependencyFetcher
9 from crash import changelist_classifier 9 from crash import changelist_classifier
10 from crash.changelist_classifier import StackInfo 10 from crash.changelist_classifier import StackInfo
11 from crash.crash_report_with_dependencies import CrashReportWithDependencies 11 from crash.crash_report import CrashReport
12 from crash.loglinear.model import UnnormalizedLogLinearModel 12 from crash.loglinear.model import UnnormalizedLogLinearModel
13 13
14 14
15 class LogLinearChangelistClassifier(object): 15 class LogLinearChangelistClassifier(object):
16 """A ``LogLinearModel``-based implementation of CL classification.""" 16 """A ``LogLinearModel``-based implementation of CL classification."""
17 17
18 def __init__(self, get_repository, meta_feature, meta_weight, 18 def __init__(self, get_repository, meta_feature, meta_weight,
19 top_n_frames=7, top_n_suspects=3): 19 top_n_frames=7, top_n_suspects=3):
20 """ 20 """
21 Args: 21 Args:
(...skipping 20 matching lines...) Expand all
42 42
43 def __call__(self, report): 43 def __call__(self, report):
44 """Finds changelists suspected of being responsible for the crash report. 44 """Finds changelists suspected of being responsible for the crash report.
45 45
46 Args: 46 Args:
47 report (CrashReport): the report to be analyzed. 47 report (CrashReport): the report to be analyzed.
48 48
49 Returns: 49 Returns:
50 List of ``Suspect``s, sorted by probability from highest to lowest. 50 List of ``Suspect``s, sorted by probability from highest to lowest.
51 """ 51 """
52 annotated_report = CrashReportWithDependencies( 52 suspects = self.GenerateSuspects(report)
53 report, self._dependency_fetcher) 53 if not suspects:
54 if annotated_report is None: 54 logging.warning('%s.__call__: Found no suspects for report: %s',
55 logging.warning('%s.__call__: '
56 'Could not obtain dependencies for report: %s',
57 self.__class__.__name__, str(report)) 55 self.__class__.__name__, str(report))
58 return [] 56 return []
59 57
60 suspects = self.GenerateSuspects(annotated_report) 58 return self.RankSuspects(report, suspects)
61 if not suspects:
62 logging.warning('%s.__call__: Found no suspects for report: %s',
63 self.__class__.__name__, str(annotated_report))
64 return []
65
66 return self.RankSuspects(annotated_report, suspects)
67 59
68 def GenerateSuspects(self, report): 60 def GenerateSuspects(self, report):
69 """Generate all possible suspects for the reported crash. 61 """Generate all possible suspects for the reported crash.
70 62
71 Args: 63 Args:
72 report (CrashReportWithDependencies): the crash we seek to explain. 64 report (CrashReport): the crash we seek to explain.
73 65
74 Returns: 66 Returns:
75 A list of ``Suspect``s who may be to blame for the 67 A list of ``Suspect``s who may be to blame for the
76 ``report``. Notably these ``Suspect`` instances do not have 68 ``report``. Notably these ``Suspect`` instances do not have
77 all their fields filled in. They will be filled in later by 69 all their fields filled in. They will be filled in later by
78 ``RankSuspects``. 70 ``RankSuspects``.
79 """ 71 """
80 # Look at all the frames from any stack in the crash report, and 72 # Look at all the frames from any stack in the crash report, and
81 # organize the ones that come from dependencies we care about. 73 # organize the ones that come from dependencies we care about.
82 dep_to_file_to_stack_infos = defaultdict(lambda: defaultdict(list)) 74 dep_to_file_to_stack_infos = defaultdict(lambda: defaultdict(list))
(...skipping 16 matching lines...) Expand all
99 self._get_repository, 91 self._get_repository,
100 ignore_cls) 92 ignore_cls)
101 93
102 def RankSuspects(self, report, suspects): 94 def RankSuspects(self, report, suspects):
103 """Returns a lineup of the suspects in order of likelihood. 95 """Returns a lineup of the suspects in order of likelihood.
104 96
105 Suspects with a discardable score or lower ranking than top_n_suspects 97 Suspects with a discardable score or lower ranking than top_n_suspects
106 will be filtered. 98 will be filtered.
107 99
108 Args: 100 Args:
109 report (CrashReportWithDependencies): the crash we seek to explain. 101 report (CrashReport): the crash we seek to explain.
110 suspects (iterable of Suspect): the CLs to consider blaming for the crash. 102 suspects (iterable of Suspect): the CLs to consider blaming for the crash.
111 103
112 Returns: 104 Returns:
113 A list of suspects in order according to their likelihood. This 105 A list of suspects in order according to their likelihood. This
114 list contains elements of the ``suspects`` list, where we mutate 106 list contains elements of the ``suspects`` list, where we mutate
115 some of the fields to store information about why that suspect 107 some of the fields to store information about why that suspect
116 is being blamed (e.g., the ``confidence``, ``reasons``, and 108 is being blamed (e.g., the ``confidence``, ``reasons``, and
117 ``changed_files`` fields are updated). In addition to sorting the 109 ``changed_files`` fields are updated). In addition to sorting the
118 suspects, we also filter out those which are exceedingly unlikely 110 suspects, we also filter out those which are exceedingly unlikely
119 or don't make the ``top_n_suspects`` cut. 111 or don't make the ``top_n_suspects`` cut.
(...skipping 13 matching lines...) Expand all
133 suspect.confidence = score 125 suspect.confidence = score
134 # features is ``MetaFeatureValue`` object containing all feature values. 126 # features is ``MetaFeatureValue`` object containing all feature values.
135 features = features_given_report(suspect) 127 features = features_given_report(suspect)
136 suspect.reasons = features.reason 128 suspect.reasons = features.reason
137 suspect.changed_files = [changed_file.ToDict() 129 suspect.changed_files = [changed_file.ToDict()
138 for changed_file in features.changed_files] 130 for changed_file in features.changed_files]
139 scored_suspects.append(suspect) 131 scored_suspects.append(suspect)
140 132
141 scored_suspects.sort(key=lambda suspect: suspect.confidence) 133 scored_suspects.sort(key=lambda suspect: suspect.confidence)
142 return scored_suspects[:self._top_n_suspects] 134 return scored_suspects[:self._top_n_suspects]
OLDNEW
« no previous file with comments | « appengine/findit/crash/findit_for_chromecrash.py ('k') | appengine/findit/crash/loglinear/changelist_features/min_distance.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698