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

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

Issue 2523343002: [Predator] Refactor ToPublishResult and fix keyerror 'found' (Closed)
Patch Set: Rebase. Created 4 years 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 2fe8f8b02e499f26d0b714c60a12e30b77612986..932a324aa7519e3211d62498668281bd8b308609 100644
--- a/appengine/findit/crash/findit.py
+++ b/appengine/findit/crash/findit.py
@@ -3,6 +3,7 @@
# found in the LICENSE file.
import copy
+import json
import logging
from google.appengine.ext import ndb
@@ -217,6 +218,41 @@ class Findit(object):
return stacktrace
+ def ProcessResultForPublishing(self, result, key):
+ """Client specific processing of result data for publishing."""
+ raise NotImplementedError()
+
+ def GetPublishableResult(self, crash_identifiers, analysis):
+ """Convert a culprit result into a publishable result for client.
+
+ Note, this function must be called by a concrete subclass of CrashAnalysis
+ which implements the ProcessResultForPublishing method.
+
+ Args:
+ crash_identifiers (dict): Dict containing identifiers that can uniquely
+ identify CrashAnalysis entity.
+ analysis (CrashAnalysis model): Model containing culprit result and other
+ analysis information.
+
+ Returns:
+ A dict of the given ``crash_identifiers``, this model's
+ ``client_id``, and a publishable version of this model's ``result``.
+ """
+ result = copy.deepcopy(analysis.result)
+ if result.get('found') and 'suspected_cls' in result:
+ for cl in result['suspected_cls']:
+ cl['confidence'] = round(cl['confidence'], 2)
+ cl.pop('reason', None)
+
+ result = self.ProcessResultForPublishing(result, analysis.key.urlsafe())
+ logging.info('Publish result:\n%s',
+ json.dumps(result, indent=4, sort_keys=True))
+ return {
+ 'crash_identifiers': crash_identifiers,
+ 'client_id': self.client_id,
+ 'result': result,
+ }
+
# TODO(wrengr): This is only called by ``CrashAnalysisPipeline.run``;
# we should be able to adjust things so that we only need to take in
# ``crash_identifiers``, or a CrashReport, rather than taking in the
« 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