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

Side by Side Diff: appengine/findit/crash/scorers/aggregators.py

Issue 2157433002: [Findit] Pass changed files info to Fracas, 2 face design. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Fix nits. Created 4 years, 5 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
(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 """Aggregator aggregates scorer results list passed in."""
6
7 class Aggregator(object):
8
9 def Aggregate(self, data_list):
10 raise NotImplementedError()
11
12 def __call__(self, data_list):
13 data_list = filter(lambda data: not data is None, data_list)
14 if not data_list:
15 return None
16
17 return self.Aggregate(data_list)
18
19
20 # TODO(katesonia): Compare this mutiply aggregator with a vector of scores
21 # aggregator later.
22 class Multiplier(Aggregator):
23
24 def Aggregate(self, data_list):
25 result = 1.0
26 for data in data_list:
27 result *= data
28
29 return result
30
31
32 class IdentityAggregator(Aggregator):
33
34 def Aggregate(self, data_list):
35 return data_list
36
37
38 class ChangedFilesAggregator(Aggregator):
39 """Aggregates a list of changed files got from many scorers.
40
41 Note: This Aggregator only aggregates the info part of each changed file.
42
43 For example, the data_list is:
44 [
45 [
46 {
47 'file': 'f1',
48 'blame_url': 'https://blame1',
49 'info': 'f1 info scorer1'
50 },
51 {
52 'file': 'f2',
53 'blame_url': 'https://blame2',
54 'info': 'f2 info scorer1'
55 }
56 ],
57 [
58 {
59 'file': 'f1',
60 'blame_url': 'https://blame1',
61 'info': 'f1 info scorer2'
62 },
63 {
64 'file': 'f2',
65 'blame_url': 'https://blame2',
66 'info': 'f2 info scorer2'
67 }
68 ]
69 ]
70
71 Aggregated result should be:
72 [
73 {
74 'file': 'f1',
75 'blame_url': 'https://blame1',
76 'info': 'f1 info scorer1\nf1 info scorer2'
77 },
78 {
79 'file': 'f2',
80 'blame_url': 'https://blame2',
81 'info': 'f2 info scorer1\nf2 info scorer2'
82 }
83 ]
84 """
85
86 def Aggregate(self, data_list):
87
88 def AggregateFileInfos(file_info_list):
89 """Aggregates file infos from different scorers for one file."""
90 infos = []
91 for file_info in file_info_list:
92 if file_info['info']:
93 infos.append(file_info['info'])
94
95 return {
96 'file': file_info_list[0]['file'],
97 'blame_url': file_info_list[0]['blame_url'],
98 'info': '\n'.join(infos)
99 }
100
101 aggregated_changed_files = []
102 for data in zip(*data_list):
103 aggregated_changed_files.append(AggregateFileInfos(data))
104
105 return aggregated_changed_files
OLDNEW
« no previous file with comments | « appengine/findit/crash/scorers/aggregator.py ('k') | appengine/findit/crash/scorers/min_distance.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698