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

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

Issue 2649503002: [Predator] Switch from scorer-based classifier to loglinear classifier. (Closed)
Patch Set: Fix typo bug 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
« no previous file with comments | « no previous file | appengine/findit/crash/test/findit_for_chromecrash_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import logging 5 import logging
6 6
7 from google.appengine.ext import ndb 7 from google.appengine.ext import ndb
8 8
9 from common import appengine_util 9 from common import appengine_util
10 from crash import detect_regression_range 10 from crash import detect_regression_range
11 from crash.changelist_classifier import ChangelistClassifier
12 from crash.chromecrash_parser import ChromeCrashParser 11 from crash.chromecrash_parser import ChromeCrashParser
13 from crash.component import Component 12 from crash.component import Component
14 from crash.component_classifier import ComponentClassifier 13 from crash.component_classifier import ComponentClassifier
15 from crash.findit import Findit 14 from crash.findit import Findit
15 from crash.loglinear.changelist_classifier import LogLinearChangelistClassifier
16 from crash.loglinear.changelist_features.touch_crashed_file_meta import (
17 TouchCrashedFileMetaFeature)
18 from crash.loglinear.feature import WrapperMetaFeature
19 from crash.loglinear.weight import MetaWeight
20 from crash.loglinear.weight import Weight
16 from crash.predator import Predator 21 from crash.predator import Predator
17 from crash.project import Project 22 from crash.project import Project
18 from crash.project_classifier import ProjectClassifier 23 from crash.project_classifier import ProjectClassifier
19 from crash.type_enums import CrashClient 24 from crash.type_enums import CrashClient
20 from model.crash.cracas_crash_analysis import CracasCrashAnalysis 25 from model.crash.cracas_crash_analysis import CracasCrashAnalysis
21 from model.crash.crash_config import CrashConfig 26 from model.crash.crash_config import CrashConfig
22 from model.crash.fracas_crash_analysis import FracasCrashAnalysis 27 from model.crash.fracas_crash_analysis import FracasCrashAnalysis
23 28
24 # TODO(katesonia): Remove the default value after adding validity check to 29 # TODO(katesonia): Remove the default value after adding validity check to
25 # config. 30 # config.
26 _FRACAS_FEEDBACK_URL_TEMPLATE = 'https://%s/crash/fracas-result-feedback?key=%s' 31 _FRACAS_FEEDBACK_URL_TEMPLATE = 'https://%s/crash/fracas-result-feedback?key=%s'
27 32
28 # TODO(wrengr): [Note#1] in many places below we have to do some ugly 33 # TODO(wrengr): [Note#1] in many places below we have to do some ugly
29 # defaulting in case crash_data is missing certain keys. If we had 34 # defaulting in case crash_data is missing certain keys. If we had
30 # crash_data be a proper class, rather than an anonymous dict, then we 35 # crash_data be a proper class, rather than an anonymous dict, then we
31 # could clean all this up by having the properties themselves do the check 36 # could clean all this up by having the properties themselves do the check
32 # and return the default whenever keys are missing. This would also 37 # and return the default whenever keys are missing. This would also
33 # let us do things like have regression_range be automatically computed 38 # let us do things like have regression_range be automatically computed
34 # from historical_metadata (when historical_metadata is provided and 39 # from historical_metadata (when historical_metadata is provided and
35 # regression_range is not). 40 # regression_range is not).
36 41
42
37 class FinditForChromeCrash(Findit): 43 class FinditForChromeCrash(Findit):
38 """Find culprits for crash reports from the Chrome Crash server.""" 44 """Find culprits for crash reports from the Chrome Crash server."""
39 45
40 @classmethod 46 @classmethod
41 def _ClientID(cls): # pragma: no cover 47 def _ClientID(cls): # pragma: no cover
42 if cls is FinditForChromeCrash: 48 if cls is FinditForChromeCrash:
43 logging.warning('FinditForChromeCrash is abstract, ' 49 logging.warning('FinditForChromeCrash is abstract, '
44 'but someone constructed an instance and called _ClientID') 50 'but someone constructed an instance and called _ClientID')
45 else: 51 else:
46 logging.warning( 52 logging.warning(
47 'FinditForChromeCrash subclass %s forgot to implement _ClientID', 53 'FinditForChromeCrash subclass %s forgot to implement _ClientID',
48 cls.__name__) 54 cls.__name__)
49 raise NotImplementedError() 55 raise NotImplementedError()
50 56
51 # TODO(http://crbug.com/659354): remove the dependency on CrashConfig 57 # TODO(http://crbug.com/659354): remove the dependency on CrashConfig
52 # entirely, by passing the relevant data as arguments to this constructor. 58 # entirely, by passing the relevant data as arguments to this constructor.
53 def __init__(self, get_repository): 59 def __init__(self, get_repository):
54 super(FinditForChromeCrash, self).__init__(get_repository) 60 super(FinditForChromeCrash, self).__init__(get_repository)
61
62 meta_weight = MetaWeight({
wrengr 2017/01/31 19:42:11 This is fine for now, but eventually we'll want to
Sharu Jiang 2017/02/01 19:32:40 Acknowledged. Added a todo.
63 'TouchCrashedFileMeta': MetaWeight({
64 'MinDistance': Weight(1.),
65 'TopFrameIndex': Weight(1.),
66 'TouchCrashedFile': Weight(1.),
67 })
68 })
69 meta_feature = WrapperMetaFeature(
70 [TouchCrashedFileMetaFeature(get_repository)])
71
55 project_classifier_config = CrashConfig.Get().project_classifier 72 project_classifier_config = CrashConfig.Get().project_classifier
56 component_classifier_config = CrashConfig.Get().component_classifier
57
58 self._stacktrace_parser = ChromeCrashParser()
59
60 projects = [Project(name, path_regexs, function_regexs, host_directories) 73 projects = [Project(name, path_regexs, function_regexs, host_directories)
61 for name, path_regexs, function_regexs, host_directories 74 for name, path_regexs, function_regexs, host_directories
62 in project_classifier_config['project_path_function_hosts']] 75 in project_classifier_config['project_path_function_hosts']]
76 component_classifier_config = CrashConfig.Get().component_classifier
63 components = [Component(component_name, path_regex, function_regex) 77 components = [Component(component_name, path_regex, function_regex)
64 for path_regex, function_regex, component_name 78 for path_regex, function_regex, component_name
65 in component_classifier_config['path_function_component']], 79 in component_classifier_config['path_function_component']]
66 # The top_n is the number of components we should return as 80 # The top_n is the number of frames we want to check to get component or
67 # components suggestion results. 81 # project classifications.
68 # TODO(http://crbug.com/679964) Deprecate the scorer-based changelist 82 # TODO(http://crbug.com/679964) Deprecate the scorer-based changelist
wrengr 2017/01/31 19:42:11 This todo is redundant now
Sharu Jiang 2017/02/01 19:32:39 Done.
69 # classifier and use loglinear model instead. 83 # classifier and use loglinear model instead.
70 self._predator = Predator( 84 self._predator = Predator(
71 cl_classifier = ChangelistClassifier(get_repository), 85 cl_classifier = LogLinearChangelistClassifier(get_repository,
86 meta_feature,
87 meta_weight),
72 component_classifier = ComponentClassifier( 88 component_classifier = ComponentClassifier(
73 components, component_classifier_config['top_n']), 89 components, component_classifier_config['top_n']),
74 project_classifier = ProjectClassifier( 90 project_classifier = ProjectClassifier(
75 projects, project_classifier_config['top_n'], 91 projects, project_classifier_config['top_n'],
76 project_classifier_config['non_chromium_project_rank_priority'])) 92 project_classifier_config['non_chromium_project_rank_priority']))
77 93
94 self._stacktrace_parser = ChromeCrashParser()
95
78 def _InitializeAnalysis(self, model, crash_data): 96 def _InitializeAnalysis(self, model, crash_data):
79 super(FinditForChromeCrash, self)._InitializeAnalysis(model, crash_data) 97 super(FinditForChromeCrash, self)._InitializeAnalysis(model, crash_data)
80 # TODO(wrengr): see Note#1 98 # TODO(wrengr): see Note#1
81 customized_data = crash_data.get('customized_data', {}) 99 customized_data = crash_data.get('customized_data', {})
82 model.channel = customized_data.get('channel', None) 100 model.channel = customized_data.get('channel', None)
83 model.historical_metadata = customized_data.get('historical_metadata', []) 101 model.historical_metadata = customized_data.get('historical_metadata', [])
84 102
85 # TODO(wrengr): see Note#1, which would allow us to lift this 103 # TODO(wrengr): see Note#1, which would allow us to lift this
86 # implementation to the Findit base class. 104 # implementation to the Findit base class.
87 @ndb.transactional 105 @ndb.transactional
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 194
177 def GetAnalysis(self, crash_identifiers): 195 def GetAnalysis(self, crash_identifiers):
178 # TODO: inline FracasCrashAnalysis.Get stuff here. 196 # TODO: inline FracasCrashAnalysis.Get stuff here.
179 return FracasCrashAnalysis.Get(crash_identifiers) 197 return FracasCrashAnalysis.Get(crash_identifiers)
180 198
181 def ProcessResultForPublishing(self, result, key): 199 def ProcessResultForPublishing(self, result, key):
182 """Fracas specific processing of result data for publishing.""" 200 """Fracas specific processing of result data for publishing."""
183 result['feedback_url'] = _FRACAS_FEEDBACK_URL_TEMPLATE % ( 201 result['feedback_url'] = _FRACAS_FEEDBACK_URL_TEMPLATE % (
184 appengine_util.GetDefaultVersionHostname(), key) 202 appengine_util.GetDefaultVersionHostname(), key)
185 return result 203 return result
OLDNEW
« no previous file with comments | « no previous file | appengine/findit/crash/test/findit_for_chromecrash_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698