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

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

Issue 2523343002: [Predator] Refactor ToPublishResult and fix keyerror 'found' (Closed)
Patch Set: . Created 4 years, 1 month 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
Index: appengine/findit/model/crash/crash_analysis.py
diff --git a/appengine/findit/model/crash/crash_analysis.py b/appengine/findit/model/crash/crash_analysis.py
index 30f99a74d4ad61613b7b9236770d3872bcb08373..8f1f533524ccbfe3c8bac9e7e414d9e566f129e0 100644
--- a/appengine/findit/model/crash/crash_analysis.py
+++ b/appengine/findit/model/crash/crash_analysis.py
@@ -9,13 +9,10 @@ import logging
from google.appengine.ext import ndb
-from common import appengine_util
from crash.type_enums import CrashClient
from model import analysis_status
from model import triage_status
-# TODO(katesonia): Move this to fracas config.
-_FINDIT_FRACAS_FEEDBACK_URL_TEMPLATE = '%s/crash/fracas-result-feedback?key=%s'
class CrashAnalysis(ndb.Model):
"""Base class to represent an analysis of a Chrome/Clusterfuzz crash."""
@@ -156,36 +153,35 @@ class CrashAnalysis(ndb.Model):
def Create(cls, crash_identifiers):
return cls(key=cls._CreateKey(crash_identifiers))
+ def ProcessResultForPublishing(self, result):
+ """Client specific processing of result data for publishing."""
+ raise NotImplementedError()
+
def ToPublishableResult(self, crash_identifiers):
"""Convert this datastore analysis into a publishable result.
+ Note, this function must be called by concret subclass of CrashAnalysis
wrengr 2016/11/29 22:11:12 "concret" -> "a concrete"
Sharu Jiang 2016/11/30 02:37:00 Done.
stgao 2016/11/30 04:35:07 I don't think this is actually done. The misspell
Sharu Jiang 2016/11/30 18:14:07 Oops, done.
+ which implements ProcessResultForPublishing abstract function.
wrengr 2016/11/29 22:11:12 -> "which implements the ProcessResultForPublishin
Sharu Jiang 2016/11/30 02:37:00 Done.
+
Args:
- crash_identifiers (dict): ??
+ crash_identifiers (dict): Dict containing identifiers that can uniquely
+ identify CrashAnalysis entity.
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(self.result)
- client_id = self.client_id
-
- # TODO(katesonia): move this to ChromeCrashAnalysis
- if (client_id == CrashClient.FRACAS or
- client_id == CrashClient.CRACAS):
- result['feedback_url'] = _FINDIT_FRACAS_FEEDBACK_URL_TEMPLATE % (
- appengine_util.GetDefaultVersionHostname(), self.key.urlsafe())
- if result['found'] and 'suspected_cls' in result:
- for cl in result['suspected_cls']:
- cl['confidence'] = round(cl['confidence'], 2)
- cl.pop('reason', None)
- elif client_id == CrashClient.CLUSTERFUZZ: # pragma: no cover.
- # TODO(katesonia): Post process clusterfuzz model result if needed.
- pass
+ 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)
logging.info('Publish result:\n%s',
json.dumps(result, indent=4, sort_keys=True))
return {
'crash_identifiers': crash_identifiers,
- 'client_id': client_id,
+ 'client_id': self.client_id,
wrengr 2016/11/29 22:11:12 Since you removed the line where we initialized se
Sharu Jiang 2016/11/30 02:37:00 I think the self.client_id would always exists sin
'result': result,
}

Powered by Google App Engine
This is Rietveld 408576698