| OLD | NEW |
| 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.chromecrash_parser import ChromeCrashParser | 11 from crash.chromecrash_parser import ChromeCrashParser |
| 12 from crash.component import Component | |
| 13 from crash.component_classifier import ComponentClassifier | |
| 14 from crash.findit import Findit | 12 from crash.findit import Findit |
| 15 from crash.loglinear.changelist_classifier import LogLinearChangelistClassifier | 13 from crash.loglinear.changelist_classifier import LogLinearChangelistClassifier |
| 16 from crash.loglinear.changelist_features.touch_crashed_file_meta import ( | 14 from crash.loglinear.changelist_features.touch_crashed_file_meta import ( |
| 17 TouchCrashedFileMetaFeature) | 15 TouchCrashedFileMetaFeature) |
| 18 from crash.loglinear.feature import WrapperMetaFeature | 16 from crash.loglinear.feature import WrapperMetaFeature |
| 19 from crash.loglinear.weight import MetaWeight | 17 from crash.loglinear.weight import MetaWeight |
| 20 from crash.loglinear.weight import Weight | 18 from crash.loglinear.weight import Weight |
| 21 from crash.predator import Predator | 19 from crash.predator import Predator |
| 22 from crash.project import Project | |
| 23 from crash.project_classifier import ProjectClassifier | |
| 24 from crash.type_enums import CrashClient | 20 from crash.type_enums import CrashClient |
| 25 from model.crash.cracas_crash_analysis import CracasCrashAnalysis | 21 from model.crash.cracas_crash_analysis import CracasCrashAnalysis |
| 26 from model.crash.crash_config import CrashConfig | 22 from model.crash.crash_config import CrashConfig |
| 27 from model.crash.fracas_crash_analysis import FracasCrashAnalysis | 23 from model.crash.fracas_crash_analysis import FracasCrashAnalysis |
| 28 | 24 |
| 29 # TODO(katesonia): Remove the default value after adding validity check to | 25 # TODO(katesonia): Remove the default value after adding validity check to |
| 30 # config. | 26 # config. |
| 31 _FRACAS_FEEDBACK_URL_TEMPLATE = 'https://%s/crash/fracas-result-feedback?key=%s' | 27 _FRACAS_FEEDBACK_URL_TEMPLATE = 'https://%s/crash/fracas-result-feedback?key=%s' |
| 32 | 28 |
| 33 # TODO(wrengr): [Note#1] in many places below we have to do some ugly | 29 # TODO(wrengr): [Note#1] in many places below we have to do some ugly |
| (...skipping 15 matching lines...) Expand all Loading... |
| 49 logging.warning('FinditForChromeCrash is abstract, ' | 45 logging.warning('FinditForChromeCrash is abstract, ' |
| 50 'but someone constructed an instance and called _ClientID') | 46 'but someone constructed an instance and called _ClientID') |
| 51 else: | 47 else: |
| 52 logging.warning( | 48 logging.warning( |
| 53 'FinditForChromeCrash subclass %s forgot to implement _ClientID', | 49 'FinditForChromeCrash subclass %s forgot to implement _ClientID', |
| 54 cls.__name__) | 50 cls.__name__) |
| 55 raise NotImplementedError() | 51 raise NotImplementedError() |
| 56 | 52 |
| 57 # TODO(http://crbug.com/659354): remove the dependency on CrashConfig | 53 # TODO(http://crbug.com/659354): remove the dependency on CrashConfig |
| 58 # entirely, by passing the relevant data as arguments to this constructor. | 54 # entirely, by passing the relevant data as arguments to this constructor. |
| 59 def __init__(self, get_repository): | 55 def __init__(self, get_repository, config): |
| 60 super(FinditForChromeCrash, self).__init__(get_repository) | 56 super(FinditForChromeCrash, self).__init__(get_repository, config) |
| 61 | 57 |
| 62 # TODO(http://crbug.com/687670): Move meta weight initial value to config. | 58 # TODO(http://crbug.com/687670): Move meta weight initial value to config. |
| 63 meta_weight = MetaWeight({ | 59 meta_weight = MetaWeight({ |
| 64 'TouchCrashedFileMeta': MetaWeight({ | 60 'TouchCrashedFileMeta': MetaWeight({ |
| 65 'MinDistance': Weight(1.), | 61 'MinDistance': Weight(1.), |
| 66 'TopFrameIndex': Weight(1.), | 62 'TopFrameIndex': Weight(1.), |
| 67 'TouchCrashedFile': Weight(1.), | 63 'TouchCrashedFile': Weight(1.), |
| 68 }) | 64 }) |
| 69 }) | 65 }) |
| 70 meta_feature = WrapperMetaFeature( | 66 meta_feature = WrapperMetaFeature( |
| 71 [TouchCrashedFileMetaFeature(get_repository)]) | 67 [TouchCrashedFileMetaFeature(get_repository)]) |
| 72 | |
| 73 project_classifier_config = CrashConfig.Get().project_classifier | |
| 74 projects = [Project(name, path_regexs, function_regexs, host_directories) | |
| 75 for name, path_regexs, function_regexs, host_directories | |
| 76 in project_classifier_config['project_path_function_hosts']] | |
| 77 component_classifier_config = CrashConfig.Get().component_classifier | |
| 78 components = [Component(component_name, path_regex, function_regex) | |
| 79 for path_regex, function_regex, component_name | |
| 80 in component_classifier_config['path_function_component']] | |
| 81 # The top_n is the number of frames we want to check to get component or | 68 # The top_n is the number of frames we want to check to get component or |
| 82 # project classifications. | 69 # project classifications. |
| 83 self._predator = Predator( | 70 self._predator = Predator( |
| 84 cl_classifier = LogLinearChangelistClassifier(get_repository, | 71 cl_classifier = LogLinearChangelistClassifier(get_repository, |
| 85 meta_feature, | 72 meta_feature, |
| 86 meta_weight), | 73 meta_weight), |
| 87 component_classifier = ComponentClassifier( | 74 project_classifier = self._project_classifier, |
| 88 components, component_classifier_config['top_n']), | 75 component_classifier = self._component_classifier) |
| 89 project_classifier = ProjectClassifier( | |
| 90 projects, project_classifier_config['top_n'], | |
| 91 project_classifier_config['non_chromium_project_rank_priority'])) | |
| 92 | 76 |
| 93 self._stacktrace_parser = ChromeCrashParser() | 77 self._stacktrace_parser = ChromeCrashParser() |
| 94 | 78 |
| 95 def _InitializeAnalysis(self, model, crash_data): | 79 def _InitializeAnalysis(self, model, crash_data): |
| 96 super(FinditForChromeCrash, self)._InitializeAnalysis(model, crash_data) | 80 super(FinditForChromeCrash, self)._InitializeAnalysis(model, crash_data) |
| 97 # TODO(wrengr): see Note#1 | 81 # TODO(wrengr): see Note#1 |
| 98 customized_data = crash_data.get('customized_data', {}) | 82 customized_data = crash_data.get('customized_data', {}) |
| 99 model.channel = customized_data.get('channel', None) | 83 model.channel = customized_data.get('channel', None) |
| 100 model.historical_metadata = customized_data.get('historical_metadata', []) | 84 model.historical_metadata = customized_data.get('historical_metadata', []) |
| 101 | 85 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 124 model.put() | 108 model.put() |
| 125 return True | 109 return True |
| 126 | 110 |
| 127 def CheckPolicy(self, crash_data): | 111 def CheckPolicy(self, crash_data): |
| 128 crash_identifiers = crash_data['crash_identifiers'] | 112 crash_identifiers = crash_data['crash_identifiers'] |
| 129 platform = crash_data['platform'] | 113 platform = crash_data['platform'] |
| 130 # TODO(wrengr): see Note#1 | 114 # TODO(wrengr): see Note#1 |
| 131 channel = crash_data.get('customized_data', {}).get('channel', None) | 115 channel = crash_data.get('customized_data', {}).get('channel', None) |
| 132 # TODO(katesonia): Remove the default value after adding validity check to | 116 # TODO(katesonia): Remove the default value after adding validity check to |
| 133 # config. | 117 # config. |
| 134 if platform not in self.config.get( | 118 if platform not in self.client_config.get( |
| 135 'supported_platform_list_by_channel', {}).get(channel, []): | 119 'supported_platform_list_by_channel', {}).get(channel, []): |
| 136 # Bail out if either the channel or platform is not supported yet. | 120 # Bail out if either the channel or platform is not supported yet. |
| 137 logging.info('Analysis of channel %s, platform %s is not supported. ' | 121 logging.info('Analysis of channel %s, platform %s is not supported. ' |
| 138 'No analysis is scheduled for %s', | 122 'No analysis is scheduled for %s', |
| 139 channel, platform, repr(crash_identifiers)) | 123 channel, platform, repr(crash_identifiers)) |
| 140 return None | 124 return None |
| 141 | 125 |
| 142 signature = crash_data['signature'] | 126 signature = crash_data['signature'] |
| 143 # TODO(wrengr): can this blacklist stuff be lifted to the base class? | 127 # TODO(wrengr): can this blacklist stuff be lifted to the base class? |
| 144 # TODO(katesonia): Remove the default value after adding validity check to | 128 # TODO(katesonia): Remove the default value after adding validity check to |
| 145 # config. | 129 # config. |
| 146 for blacklist_marker in self.config.get('signature_blacklist_markers', []): | 130 for blacklist_marker in self.client_config.get( |
| 131 'signature_blacklist_markers', []): |
| 147 if blacklist_marker in signature: | 132 if blacklist_marker in signature: |
| 148 logging.info('%s signature is not supported. ' | 133 logging.info('%s signature is not supported. ' |
| 149 'No analysis is scheduled for %s', blacklist_marker, | 134 'No analysis is scheduled for %s', blacklist_marker, |
| 150 repr(crash_identifiers)) | 135 repr(crash_identifiers)) |
| 151 return None | 136 return None |
| 152 | 137 |
| 153 # TODO(wrengr): should we clone ``crash_data`` rather than mutating it? | 138 # TODO(wrengr): should we clone ``crash_data`` rather than mutating it? |
| 154 crash_data['platform'] = self.RenamePlatform(platform) | 139 crash_data['platform'] = self.RenamePlatform(platform) |
| 155 return crash_data | 140 return crash_data |
| 156 | 141 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 178 |
| 194 def GetAnalysis(self, crash_identifiers): | 179 def GetAnalysis(self, crash_identifiers): |
| 195 # TODO: inline FracasCrashAnalysis.Get stuff here. | 180 # TODO: inline FracasCrashAnalysis.Get stuff here. |
| 196 return FracasCrashAnalysis.Get(crash_identifiers) | 181 return FracasCrashAnalysis.Get(crash_identifiers) |
| 197 | 182 |
| 198 def ProcessResultForPublishing(self, result, key): | 183 def ProcessResultForPublishing(self, result, key): |
| 199 """Fracas specific processing of result data for publishing.""" | 184 """Fracas specific processing of result data for publishing.""" |
| 200 result['feedback_url'] = _FRACAS_FEEDBACK_URL_TEMPLATE % ( | 185 result['feedback_url'] = _FRACAS_FEEDBACK_URL_TEMPLATE % ( |
| 201 appengine_util.GetDefaultVersionHostname(), key) | 186 appengine_util.GetDefaultVersionHostname(), key) |
| 202 return result | 187 return result |
| OLD | NEW |