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

Unified Diff: appengine/findit/crash/findit.py

Issue 2673993003: [Predator] Pass config as argument to findit. (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/findit/crash/crash_pipeline.py ('k') | appengine/findit/crash/findit_for_chromecrash.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/crash/findit.py
diff --git a/appengine/findit/crash/findit.py b/appengine/findit/crash/findit.py
index 42bc4f15a8769d87e49cc1723a1ebf8e4c50c5e7..11306af7c54f20b2a3b962af310e4f93885e7012 100644
--- a/appengine/findit/crash/findit.py
+++ b/appengine/findit/crash/findit.py
@@ -11,7 +11,11 @@ from google.appengine.ext import ndb
from common import appengine_util
from common.chrome_dependency_fetcher import ChromeDependencyFetcher
from common import constants
+from crash.component import Component
+from crash.component_classifier import ComponentClassifier
from crash.crash_report import CrashReport
+from crash.project import Project
+from crash.project_classifier import ProjectClassifier
from libs import time_util
from model import analysis_status
from model.crash.crash_config import CrashConfig
@@ -29,7 +33,7 @@ from model.crash.crash_config import CrashConfig
# Think of a good name (e.g.'PredatorApp') for this class.
class Findit(object):
- def __init__(self, get_repository):
+ def __init__(self, get_repository, config):
"""
Args:
get_repository (callable): a function from DEP urls to ``Repository``
@@ -42,6 +46,24 @@ class Findit(object):
"""
self._get_repository = get_repository
self._dep_fetcher = ChromeDependencyFetcher(get_repository)
+
+ project_classifier_config = config.project_classifier
+ projects = [Project(name, path_regexs, function_regexs, host_directories)
+ for name, path_regexs, function_regexs, host_directories
+ in project_classifier_config['project_path_function_hosts']]
+ self._project_classifier = ProjectClassifier(
+ projects, project_classifier_config['top_n'],
+ project_classifier_config['non_chromium_project_rank_priority'])
+
+ component_classifier_config = config.component_classifier
+ components = [Component(component_name, path_regex, function_regex)
+ for path_regex, function_regex, component_name
+ in component_classifier_config['path_function_component']]
+ self._component_classifier = ComponentClassifier(
+ components, component_classifier_config['top_n'])
+
+ self._config = config
+
# TODO(http://crbug.com/659354): because self.client is volatile,
# we need some way of updating the Predator instance whenever the
# config changes. How to do that cleanly?
@@ -87,7 +109,7 @@ class Findit(object):
# what in particular changed) so that we can update our internal state
# as appropriate.
@property
- def config(self):
+ def client_config(self):
"""Get the current value of the client config for the class of this object.
N.B., this property is volatile and may change asynchronously.
@@ -103,7 +125,7 @@ class Findit(object):
returned the empty dict, then calls to ``get`` would "work" just
fine; thereby masking the underlying bug!
"""
- return CrashConfig.Get().GetClientConfig(self.client_id)
+ return self._config.GetClientConfig(self.client_id)
# TODO(http://crbug.com/644476): rename to CanonicalizePlatform or
# something like that.
@@ -111,7 +133,7 @@ class Findit(object):
"""Remap the platform to a different one, based on the config."""
# TODO(katesonia): Remove the default value after adding validity check to
# config.
- return self.config.get('platform_rename', {}).get(platform, platform)
+ return self.client_config.get('platform_rename', {}).get(platform, platform)
def CheckPolicy(self, crash_data): # pylint: disable=W0613
"""Check whether this client supports analyzing the given report.
@@ -214,12 +236,12 @@ class Findit(object):
Returns:
On success, returns a Stacktrace object; on failure, returns None.
"""
- # Use up-to-date ``top_n`` in self.config to filter top n frames.
+ # Use up-to-date ``top_n`` in self.client_config to filter top n frames.
stacktrace = self._stacktrace_parser.Parse(
model.stack_trace,
self._dep_fetcher.GetDependency(model.crashed_version, model.platform),
model.signature,
- self.config.get('top_n'))
+ self.client_config.get('top_n'))
if not stacktrace:
logging.warning('Failed to parse the stacktrace %s', model.stack_trace)
return None
« no previous file with comments | « appengine/findit/crash/crash_pipeline.py ('k') | appengine/findit/crash/findit_for_chromecrash.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698