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

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

Issue 2663063007: [Predator] Switch from anonymous dict to CrashData. (Closed)
Patch Set: Rebase and fix delta test. 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 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 copy
6 import hashlib 6 import hashlib
7 import json 7 import json
8 import logging 8 import logging
9 9
10 from google.appengine.ext import ndb 10 from google.appengine.ext import ndb
11 11
12 from crash.type_enums import CrashClient 12 from crash.crash_report import CrashReport
13 from libs import time_util
13 from model import analysis_status 14 from model import analysis_status
14 from model import triage_status 15 from model import triage_status
15 16
16 17
17 class CrashAnalysis(ndb.Model): 18 class CrashAnalysis(ndb.Model):
18 """Base class to represent an analysis of a Chrome/Clusterfuzz crash.""" 19 """Base class to represent an analysis of a Chrome/Clusterfuzz crash."""
19 ################### Properties for the crash itself. ################### 20 ################### Properties for the crash itself. ###################
20 # In which version or revision of Chrome the crash occurred. Either a version 21 # In which version or revision of Chrome the crash occurred. Either a version
21 # number for Chrome build or a git commit hash/position for chromium build. 22 # number for Chrome build or a git commit hash/position for chromium build.
22 crashed_version = ndb.StringProperty(indexed=False) 23 crashed_version = ndb.StringProperty(indexed=False)
23 24
24 # The stack_trace_string. 25 # The parsed ``Stacktrace`` object.
25 stack_trace = ndb.StringProperty(indexed=False) 26 stack_trace = ndb.PickleProperty(indexed=False)
26 27
27 # The signature of the crash. 28 # The signature of the crash.
28 signature = ndb.StringProperty(indexed=False) 29 signature = ndb.StringProperty(indexed=False)
29 30
30 # The platform of this crash. 31 # The platform of this crash.
31 platform = ndb.StringProperty(indexed=False) 32 platform = ndb.StringProperty(indexed=False)
32 33
33 # ID to differentiate different client.
34 client_id = ndb.StringProperty(indexed=False)
35
36 # Chrome regression range. 34 # Chrome regression range.
37 regression_range = ndb.JsonProperty(indexed=False) 35 regression_range = ndb.JsonProperty(indexed=False)
38 36
37 # Dict of ``Dependency``s of ``crashed_version``, which appears in crash stack
38 # N.B. ``dependencies`` includes chromium itself.
39 dependencies = ndb.PickleProperty(indexed=False)
40
41 # Dict of ``DependencyRoll``s in ``regression_range``, which appears in crash
42 # stack. N.B. ``dependencies`` includes chromium itself.
43 dependency_rolls = ndb.PickleProperty(indexed=False)
44
39 ################### Properties for the analysis progress. ################### 45 ################### Properties for the analysis progress. ###################
40 46
41 # The url path to the pipeline status page. 47 # The url path to the pipeline status page.
42 pipeline_status_path = ndb.StringProperty(indexed=False) 48 pipeline_status_path = ndb.StringProperty(indexed=False)
43 49
44 # The status of the analysis. 50 # The status of the analysis.
45 status = ndb.IntegerProperty( 51 status = ndb.IntegerProperty(
46 default=analysis_status.PENDING, indexed=False) 52 default=analysis_status.PENDING, indexed=False)
47 53
48 # When the analysis was requested. 54 # When the analysis was requested.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 return ndb.Key(cls.__name__, hashlib.sha1( 151 return ndb.Key(cls.__name__, hashlib.sha1(
146 json.dumps(crash_identifiers, sort_keys=True)).hexdigest()) 152 json.dumps(crash_identifiers, sort_keys=True)).hexdigest())
147 153
148 @classmethod 154 @classmethod
149 def Get(cls, crash_identifiers): 155 def Get(cls, crash_identifiers):
150 return cls._CreateKey(crash_identifiers).get() 156 return cls._CreateKey(crash_identifiers).get()
151 157
152 @classmethod 158 @classmethod
153 def Create(cls, crash_identifiers): 159 def Create(cls, crash_identifiers):
154 return cls(key=cls._CreateKey(crash_identifiers)) 160 return cls(key=cls._CreateKey(crash_identifiers))
161
162 def Initialize(self, crash_data):
163 """(Re)Initialize a CrashAnalysis ndb.Model from ``CrashData``.
164
165 This method is only ever called from _NeedsNewAnalysis which is only
166 ever called from ScheduleNewAnalysis. It is used for filling in the
167 fields of a CrashAnalysis ndb.Model for the first time (though it
168 can also be used to re-initialize a given CrashAnalysis). Subclasses
169 should extend (not override) this to (re)initialize any
170 client-specific fields they may have.
171 """
172 # Get rid of any previous values there may have been.
173 self.Reset()
174
175 # Set the version.
176 self.crashed_version = crash_data.crashed_version
177
178 # Set (other) common properties.
179 self.stack_trace = crash_data.stacktrace
180 self.signature = crash_data.signature
181 self.platform = crash_data.platform
182 self.regression_range = crash_data.regression_range
183 self.dependencies = crash_data.dependencies
184 self.dependency_rolls = crash_data.dependency_rolls
185
186 # Set progress properties.
187 self.status = analysis_status.PENDING
188 self.requested_time = time_util.GetUTCNow()
189
190 def ToCrashReport(self):
191 """Converts this model to ``CrashReport`` to give to Predator library."""
192 return CrashReport(self.crashed_version, self.signature, self.platform,
193 self.stack_trace, self.regression_range,
194 self.dependencies, self.dependency_rolls)
OLDNEW
« no previous file with comments | « appengine/findit/model/crash/chrome_crash_analysis.py ('k') | appengine/findit/model/crash/test/chrome_crash_analysis_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698