| Index: appengine/findit/crash/project_classifier.py
|
| diff --git a/appengine/findit/crash/project_classifier.py b/appengine/findit/crash/project_classifier.py
|
| index 7e537a3e50702e3db47446f9d411a615b38f7e6f..207fa87ba40652ec60515b7f5a6a559415cbae3e 100644
|
| --- a/appengine/findit/crash/project_classifier.py
|
| +++ b/appengine/findit/crash/project_classifier.py
|
| @@ -4,12 +4,11 @@
|
|
|
| import logging
|
|
|
| -from crash import classifier
|
| +from crash.occurrence import RankByOccurrence
|
| from crash.type_enums import CallStackLanguageType
|
| from model.crash.crash_config import CrashConfig
|
|
|
| -
|
| -class ProjectClassifier(classifier.Classifier):
|
| +class ProjectClassifier(object):
|
| """Determines the project of a crash - (project_name, project_path).
|
|
|
| For example: ('chromium', 'src/'), ('skia', 'src/skia/'), ...etc.
|
| @@ -62,6 +61,8 @@ class ProjectClassifier(classifier.Classifier):
|
|
|
| return ''
|
|
|
| + # TODO(wrengr): should return an object of some "Project" class;
|
| + # similar to how we handle components.
|
| def Classify(self, results, crash_stack):
|
| """Classify project of a crash.
|
|
|
| @@ -73,29 +74,36 @@ class ProjectClassifier(classifier.Classifier):
|
| A tuple, project of the crash - (project_name, project_path).
|
| """
|
| if not self.project_classifier_config:
|
| - logging.warning('Empty configuration for project classifier.')
|
| - return ''
|
| -
|
| - def _GetRankFunction(language_type):
|
| - if language_type == CallStackLanguageType.JAVA:
|
| - def _RankFunctionForJava(occurrence):
|
| - project_name = occurrence.name
|
| - return (len(occurrence),
|
| - 0 if 'chromium' in project_name else
|
| - self.project_classifier_config[
|
| - 'non_chromium_project_rank_priority'][project_name])
|
| -
|
| - return _RankFunctionForJava
|
| -
|
| - return classifier.DefaultRankFunction
|
| -
|
| - # Set the max_classes to 1, so the returned projects only has one element.
|
| - projects = self._Classify(
|
| - results, crash_stack,
|
| - self.project_classifier_config['top_n'], 1,
|
| - rank_function=_GetRankFunction(crash_stack.language_type))
|
| + logging.warning('ProjectClassifier.Classify: Empty configuration.')
|
| + return None
|
| +
|
| + rank_function = None
|
| + if crash_stack.language_type == CallStackLanguageType.JAVA:
|
| + def _RankFunctionForJava(occurrence):
|
| + project_name = occurrence.name
|
| + return (len(occurrence),
|
| + 0 if 'chromium' in project_name else
|
| + self.project_classifier_config[
|
| + 'non_chromium_project_rank_priority'][project_name])
|
| +
|
| + rank_function = _RankFunctionForJava
|
| +
|
| + top_n_frames = self.project_classifier_config['top_n']
|
| + # If |results| are available, we use the projects from there since
|
| + # they're more reliable than the ones from the |crash_stack|.
|
| + if results:
|
| + classes = map(self.GetClassFromResult, results[:top_n_frames])
|
| + else:
|
| + classes = map(self.GetClassFromStackFrame, crash_stack[:top_n_frames])
|
| +
|
| + # Since we're only going to return the highest-ranked class, might
|
| + # as well set |max_classes| to 1.
|
| + projects = RankByOccurrence(classes, 1, rank_function=rank_function)
|
|
|
| if projects:
|
| + if projects[0] is None:
|
| + logging.warning('ProjectClassifier.Classify: the highest ranking project is None.')
|
| return projects[0]
|
|
|
| - return ''
|
| + logging.warning('ProjectClassifier.Classify: no projects found.')
|
| + return None
|
|
|