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

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

Issue 2608483002: Changed FindSuspects to take a Repository factory, rather than mutating it (Closed)
Patch Set: Created 3 years, 12 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 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
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 cls.__name__) 47 cls.__name__)
48 raise NotImplementedError() 48 raise NotImplementedError()
49 49
50 # TODO(http://crbug.com/659354): remove the dependency on CrashConfig 50 # TODO(http://crbug.com/659354): remove the dependency on CrashConfig
51 # entirely, by passing the relevant data as arguments to this constructor. 51 # entirely, by passing the relevant data as arguments to this constructor.
52 def __init__(self, repository): 52 def __init__(self, repository):
53 super(FinditForChromeCrash, self).__init__(repository) 53 super(FinditForChromeCrash, self).__init__(repository)
54 component_classifier_config = CrashConfig.Get().component_classifier 54 component_classifier_config = CrashConfig.Get().component_classifier
55 55
56 self._stacktrace_parser = ChromeCrashParser() 56 self._stacktrace_parser = ChromeCrashParser()
57
58 def MutateTheRepo(dep_url): # pragma: no cover
59 """A factory function for returning ``Repository`` objects.
60
61 The current definition captures the functionality of before
62 we actored out this factory method. That is, it's not really a
63 "factory" but rather mutates the main repo object in place. In
64 the future this should be changed to do the right thing instead.
65 """
66 repository.repo_url = dep_url
67 return repository
68
57 # The top_n is the number of components we should return as 69 # The top_n is the number of components we should return as
58 # components suggestion results. 70 # components suggestion results.
59 self._predator = Predator( 71 self._predator = Predator(
60 cl_classifier = ChangelistClassifier(repository = repository), 72 cl_classifier = ChangelistClassifier(repository, MutateTheRepo),
61 component_classifier = ComponentClassifier( 73 component_classifier = ComponentClassifier(
62 [Component(component_name, path_regex, function_regex) 74 [Component(component_name, path_regex, function_regex)
63 for path_regex, function_regex, component_name 75 for path_regex, function_regex, component_name
64 in component_classifier_config['path_function_component']], 76 in component_classifier_config['path_function_component']],
65 component_classifier_config['top_n']), 77 component_classifier_config['top_n']),
66 project_classifier = ProjectClassifier()) 78 project_classifier = ProjectClassifier())
67 79
68 def _InitializeAnalysis(self, model, crash_data): 80 def _InitializeAnalysis(self, model, crash_data):
69 super(FinditForChromeCrash, self)._InitializeAnalysis(model, crash_data) 81 super(FinditForChromeCrash, self)._InitializeAnalysis(model, crash_data)
70 # TODO(wrengr): see Note#1 82 # TODO(wrengr): see Note#1
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 178
167 def GetAnalysis(self, crash_identifiers): 179 def GetAnalysis(self, crash_identifiers):
168 # TODO: inline FracasCrashAnalysis.Get stuff here. 180 # TODO: inline FracasCrashAnalysis.Get stuff here.
169 return FracasCrashAnalysis.Get(crash_identifiers) 181 return FracasCrashAnalysis.Get(crash_identifiers)
170 182
171 def ProcessResultForPublishing(self, result, key): 183 def ProcessResultForPublishing(self, result, key):
172 """Fracas specific processing of result data for publishing.""" 184 """Fracas specific processing of result data for publishing."""
173 result['feedback_url'] = _FRACAS_FEEDBACK_URL_TEMPLATE % ( 185 result['feedback_url'] = _FRACAS_FEEDBACK_URL_TEMPLATE % (
174 appengine_util.GetDefaultVersionHostname(), key) 186 appengine_util.GetDefaultVersionHostname(), key)
175 return result 187 return result
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698