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

Side by Side Diff: appengine/findit/model/flake/master_flake_analysis.py

Issue 2369333002: [Findit] Capture versionized metadata for master_flake_analysis (Closed)
Patch Set: Fixing nits Created 4 years, 2 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 base64 5 import base64
6 6
7 from google.appengine.ext import ndb 7 from google.appengine.ext import ndb
8 8
9 from common import time_util
10 from model import analysis_status
11 from model.base_analysis import BaseAnalysis
9 from model.base_build_model import BaseBuildModel 12 from model.base_build_model import BaseBuildModel
10 from model.base_analysis import BaseAnalysis 13 from model.flake.flake_swarming_task import FlakeSwarmingTaskData
11 from model.flake.flake_swarming_task import FlakeSwarmingTask 14 from model.versioned_model import VersionedModel
12 15
13 16
14 class MasterFlakeAnalysis(BaseAnalysis, BaseBuildModel): 17 class DataPoint(ndb.Model):
18 build_number = ndb.IntegerProperty(indexed=False)
19 pass_rate = ndb.FloatProperty(indexed=False)
20
21
22 class MasterFlakeAnalysis(BaseAnalysis, BaseBuildModel, VersionedModel):
15 """Represents an analysis of a flaky test in a Chromium Waterfall.""" 23 """Represents an analysis of a flaky test in a Chromium Waterfall."""
16 24
17 @staticmethod
18 def _CreateAnalysisId(master_name, builder_name,
19 build_number, step_name, test_name):
20 encoded_test_name = base64.urlsafe_b64encode(test_name)
21 return '%s/%s/%s/%s/%s' % (master_name, builder_name,
22 build_number, step_name, encoded_test_name)
23
24 @ndb.ComputedProperty 25 @ndb.ComputedProperty
25 def step_name(self): 26 def step_name(self):
26 return self.key.pairs()[0][1].split('/')[3] 27 return self.key.pairs()[0][1].split('/')[3]
27 28
28 @ndb.ComputedProperty 29 @ndb.ComputedProperty
29 def test_name(self): 30 def test_name(self):
30 return base64.urlsafe_b64decode(self.key.pairs()[0][1].split('/')[4]) 31 return base64.urlsafe_b64decode(self.key.pairs()[0][1].split('/')[4])
31 32
32 @staticmethod 33 @staticmethod
33 def _CreateKey(master_name, builder_name, build_number, 34 def _CreateAnalysisId(
34 step_name, test_name): # pragma: no cover 35 master_name, builder_name, build_number, step_name, test_name):
35 return ndb.Key('MasterFlakeAnalysis', 36 encoded_test_name = base64.urlsafe_b64encode(test_name)
36 MasterFlakeAnalysis._CreateAnalysisId( 37 return '%s/%s/%s/%s/%s' % (
37 master_name, builder_name, build_number, 38 master_name, builder_name, build_number, step_name, encoded_test_name)
38 step_name, test_name))
39 39
40 @staticmethod 40 # Arguments number differs from overridden method - pylint: disable=W0221
41 def Create(master_name, builder_name, build_number, 41 @classmethod
42 step_name, test_name): # pragma: no cover 42 def Create(cls, master_name, builder_name, build_number, step_name,
43 return MasterFlakeAnalysis( 43 test_name): # pragma: no cover.
44 key=MasterFlakeAnalysis._CreateKey( 44 return super(MasterFlakeAnalysis, cls).Create(
45 master_name, builder_name, build_number, 45 MasterFlakeAnalysis._CreateAnalysisId(
46 step_name, test_name)) 46 master_name, builder_name, build_number, step_name, test_name))
47 47
48 @staticmethod 48 # Arguments number differs from overridden method - pylint: disable=W0221
49 def Get(master_name, builder_name, build_number, 49 @classmethod
50 step_name, test_name): # pragma: no cover 50 def GetVersion(cls, master_name, builder_name, build_number, step_name,
51 return MasterFlakeAnalysis._CreateKey( 51 test_name, version=None): # pragma: no cover.
52 master_name, builder_name, build_number, step_name, test_name).get() 52 return super(MasterFlakeAnalysis, cls).GetVersion(
53 key=MasterFlakeAnalysis._CreateAnalysisId(
54 master_name, builder_name, build_number, step_name, test_name),
55 version=version)
53 56
54 # List of tested build_numbers and their corresponding success rates. 57 def Reset(self):
55 # We need to keep these sorted manually. 58 self.created_time = time_util.GetUTCNow()
56 build_numbers = ndb.IntegerProperty(indexed=False, repeated=True) 59 self.status = analysis_status.PENDING
57 success_rates = ndb.FloatProperty(indexed=False, repeated=True) 60 self.completed_time = None
61 self.swarming_rerun_results = []
62 self.error = None
63 self.correct_regression_range = None
64 self.correct_culprit = None
65 self.algorithm_parameters = None
66 self.suspected_flake_build_number = None
67 self.data_points = []
68
69 # The UTC timestamp this analysis was requested.
70 created_time = ndb.DateTimeProperty(indexed=True)
71
72 # The UTC timestamp this analysis was completed.
73 completed_time = ndb.DateTimeProperty(indexed=True)
74
75 # A list of dicts containing information about each swarming rerun's results
76 # that were involved in this analysis. The contents of this list will be used
77 # for metrics, such as the number of cache hits this analysis benefited from,
78 # the number of swarming tasks that were needed end-to-end to find the
79 # regressed build number (if any), etc. See FlakeSwarmingTaskData for exact
80 # fields.
81 swarming_rerun_results = ndb.LocalStructuredProperty(
82 FlakeSwarmingTaskData, repeated=True, compressed=True)
83
84 # Error code and message, if any.
85 error = ndb.JsonProperty(indexed=False)
86
87 # Boolean whether the suspected regression range/build number is correct.
88 correct_regression_range = ndb.BooleanProperty(indexed=True)
89
90 # Boolean whether the suspected CL for found in the regression range
91 # is correct.
92 correct_culprit = ndb.BooleanProperty(indexed=True)
93
94 # The look back algorithm parameters that were used, as specified in Findit's
95 # configuration. For example,
96 # {
97 # 'iterations_to_rerun': 100,
98 # 'lower_flake_threshold': 0.02,
99 # 'max_build_numbers_to_look_back': 500,
100 # 'max_flake_in_a_row': 4,
101 # 'max_stable_in_a_row': 4,
102 # 'upper_flake_threshold': 0.98
103 # }
104 algorithm_parameters = ndb.JsonProperty(indexed=False)
105
106 # The suspected build number to have introduced the flakiness.
58 suspected_flake_build_number = ndb.IntegerProperty() 107 suspected_flake_build_number = ndb.IntegerProperty()
108
109 # The data points used to plot the flakiness graph build over build.
110 data_points = ndb.LocalStructuredProperty(
111 DataPoint, repeated=True, compressed=True)
OLDNEW
« no previous file with comments | « appengine/findit/model/flake/flake_swarming_task.py ('k') | appengine/findit/model/flake/master_flake_analysis_data.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698