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

Side by Side Diff: appengine/findit/crash/results.py

Issue 1914113002: [Findit] Enable project classifier and component classifier (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Address comments. 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
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 _INFINITY = 1000 5 _INFINITY = 1000
6 6
7 7
8 class Result(object): 8 class Result(object):
9 """Represents findit culprit result.""" 9 """Represents findit culprit result."""
10 10
11 def __init__(self, changelog, dep_path, component, 11 def __init__(self, changelog, dep_path,
12 confidence=None, reason=None): 12 confidence=None, reason=None):
13 self.changelog = changelog 13 self.changelog = changelog
14 self.dep_path = dep_path 14 self.dep_path = dep_path
15 self.component = component
16 self.confidence = confidence 15 self.confidence = confidence
17 self.reason = reason 16 self.reason = reason
18 17
19 self.file_to_stack_infos = {} 18 self.file_to_stack_infos = {}
20 19
21 def ToDict(self): 20 def ToDict(self):
22 return { 21 return {
23 'url': self.changelog.commit_url, 22 'url': self.changelog.commit_url,
24 'revision': self.changelog.revision, 23 'revision': self.changelog.revision,
25 'dep_path': self.dep_path, 24 'dep_path': self.dep_path,
26 'component': self.component,
27 'author': self.changelog.author_email, 25 'author': self.changelog.author_email,
28 'time': self.changelog.author_time, 26 'time': self.changelog.author_time,
29 'reason': self.reason, 27 'reason': self.reason,
30 'confidence': self.confidence, 28 'confidence': self.confidence,
31 } 29 }
32 30
33 def ToString(self): 31 def ToString(self):
34 if not self.file_to_stack_infos: 32 if not self.file_to_stack_infos:
35 return '' 33 return ''
36 34
37 lines = [] 35 lines = []
38 for file_path, stack_infos in self.file_to_stack_infos.iteritems(): 36 for file_path, stack_infos in self.file_to_stack_infos.iteritems():
39 line_parts = [] 37 line_parts = []
40 for frame, _ in stack_infos: 38 for frame, _ in stack_infos:
41 line_parts.append('%s (#%d)' % (frame.function, frame.index)) 39 line_parts.append('%s (#%d)' % (frame.function, frame.index))
42 40
43 lines.append('Changed file %s crashed in %s' % ( 41 lines.append('Changed file %s crashed in %s' % (
44 file_path, ', '.join(line_parts))) 42 file_path, ', '.join(line_parts)))
45 43
46 return '\n'.join(lines) 44 return '\n'.join(lines)
47 45
48 def __str__(self): 46 def __str__(self):
49 return self.ToString() 47 return self.ToString()
50 48
51 49
52 class MatchResult(Result): 50 class MatchResult(Result):
53 """Represents findit culprit result got from match algorithm.""" 51 """Represents findit culprit result got from match algorithm."""
54 52
55 def __init__(self, changelog, dep_path, component, 53 def __init__(self, changelog, dep_path,
56 confidence=None, reason=None): 54 confidence=None, reason=None):
57 super(MatchResult, self).__init__( 55 super(MatchResult, self).__init__(
58 changelog, dep_path, component, confidence, reason) 56 changelog, dep_path, confidence, reason)
59 57
60 self.min_distance = _INFINITY 58 self.min_distance = _INFINITY
61 59
62 def Update(self, file_path, stack_infos, blame): 60 def Update(self, file_path, stack_infos, blame):
63 """Updates a match result with file path and its stack_infos and blame. 61 """Updates a match result with file path and its stack_infos and blame.
64 62
65 When a file_path is found both shown in stacktrace and touched by 63 When a file_path is found both shown in stacktrace and touched by
66 the revision of this result, update result with the information of 64 the revision of this result, update result with the information of
67 this file. 65 this file.
68 66
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 frames. 120 frames.
123 changelogs (list): List of Changelog objects in the dep in regression 121 changelogs (list): List of Changelog objects in the dep in regression
124 range which touched the file. 122 range which touched the file.
125 blame (Blame): Blame of the file. 123 blame (Blame): Blame of the file.
126 """ 124 """
127 for changelog in changelogs: 125 for changelog in changelogs:
128 if self.ignore_cls and changelog.revision in self.ignore_cls: 126 if self.ignore_cls and changelog.revision in self.ignore_cls:
129 continue 127 continue
130 128
131 if changelog.revision not in self: 129 if changelog.revision not in self:
132 # TODO(katesonia): Enable component classifier later. Get it from 130 self[changelog.revision] = MatchResult(changelog, dep_path)
133 # file_path and dep_path.
134 component = ''
135 self[changelog.revision] = MatchResult(changelog, dep_path, component)
136 131
137 match_result = self[changelog.revision] 132 match_result = self[changelog.revision]
138 133
139 match_result.Update(file_path, stack_infos, blame) 134 match_result.Update(file_path, stack_infos, blame)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698