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

Side by Side Diff: appengine/findit/model/crash/crash_analysis.py

Issue 2414523002: [Findit] Reorganizing findit_for_*.py (Closed)
Patch Set: rebasing against recently landed cls 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 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 copy
5 import hashlib 6 import hashlib
6 import json 7 import json
7 import logging 8 import logging
8 9
9 from google.appengine.ext import ndb 10 from google.appengine.ext import ndb
10 11
12 from common import appengine_util
13 from crash.type_enums import CrashClient
11 from model import analysis_status 14 from model import analysis_status
12 from model import triage_status 15 from model import triage_status
13 16
17 # TODO(katesonia): Move this to fracas config.
18 _FINDIT_FRACAS_FEEDBACK_URL_TEMPLATE = '%s/crash/fracas-result-feedback?key=%s'
14 19
15 class CrashAnalysis(ndb.Model): 20 class CrashAnalysis(ndb.Model):
16 """Base class to represent an analysis of a Chrome/Clusterfuzz crash.""" 21 """Base class to represent an analysis of a Chrome/Clusterfuzz crash."""
17 ################### Properties for the crash itself. ################### 22 ################### Properties for the crash itself. ###################
18 # In which version or revision of Chrome the crash occurred. Either a version 23 # In which version or revision of Chrome the crash occurred. Either a version
19 # number for Chrome build or a git commit hash/position for chromium build. 24 # number for Chrome build or a git commit hash/position for chromium build.
20 crashed_version = ndb.StringProperty(indexed=False) 25 crashed_version = ndb.StringProperty(indexed=False)
21 26
22 # The stack_trace_string. 27 # The stack_trace_string.
23 stack_trace = ndb.StringProperty(indexed=False) 28 stack_trace = ndb.StringProperty(indexed=False)
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 return ndb.Key(cls.__name__, hashlib.sha1( 148 return ndb.Key(cls.__name__, hashlib.sha1(
144 json.dumps(crash_identifiers, sort_keys=True)).hexdigest()) 149 json.dumps(crash_identifiers, sort_keys=True)).hexdigest())
145 150
146 @classmethod 151 @classmethod
147 def Get(cls, crash_identifiers): 152 def Get(cls, crash_identifiers):
148 return cls._CreateKey(crash_identifiers).get() 153 return cls._CreateKey(crash_identifiers).get()
149 154
150 @classmethod 155 @classmethod
151 def Create(cls, crash_identifiers): 156 def Create(cls, crash_identifiers):
152 return cls(key=cls._CreateKey(crash_identifiers)) 157 return cls(key=cls._CreateKey(crash_identifiers))
158
159 def ToPublishableResult(self, crash_identifiers):
160 """Convert this datastore analysis into a publishable result.
161
162 Args:
163 crash_identifiers (dict): ??
164
165 Returns:
166 A dict of the given |crash_identifiers|, this model's |client_id|,
167 and a publishable version of this model's |result|.
168 """
169 result = copy.deepcopy(self.result)
170 client_id = self.client_id
171
172 if (client_id == CrashClient.FRACAS or
173 client_id == CrashClient.CRACAS):
Sharu Jiang 2016/10/26 19:09:32 I think this part should be in ChromeCrashAnalysis
174 result['feedback_url'] = _FINDIT_FRACAS_FEEDBACK_URL_TEMPLATE % (
175 appengine_util.GetDefaultVersionHostname(), self.key.urlsafe())
176 if result['found']:
177 for cl in result['suspected_cls']:
178 cl['confidence'] = round(cl['confidence'], 2)
179 cl.pop('reason', None)
180 elif client_id == CrashClient.CLUSTERFUZZ: # pragma: no cover.
181 # TODO(katesonia): Post process clusterfuzz model result if needed.
182 pass
183
184 return {
185 'crash_identifiers': crash_identifiers,
186 'client_id': client_id,
187 'result': result,
188 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698