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

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 passing version through pipelines 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.versioned_model import VersionedModel
11 from model.flake.flake_swarming_task import FlakeSwarmingTask
12 14
13 15
14 class MasterFlakeAnalysis(BaseAnalysis, BaseBuildModel): 16 class MasterFlakeAnalysis(BaseAnalysis, BaseBuildModel, VersionedModel):
15 """Represents an analysis of a flaky test in a Chromium Waterfall.""" 17 """Represents an analysis of a flaky test in a Chromium Waterfall."""
16 18
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 19 @ndb.ComputedProperty
25 def step_name(self): 20 def step_name(self):
26 return self.key.pairs()[0][1].split('/')[3] 21 return self.key.pairs()[0][1].split('/')[3]
27 22
28 @ndb.ComputedProperty 23 @ndb.ComputedProperty
29 def test_name(self): 24 def test_name(self):
30 return base64.urlsafe_b64decode(self.key.pairs()[0][1].split('/')[4]) 25 return base64.urlsafe_b64decode(self.key.pairs()[0][1].split('/')[4])
31 26
32 @staticmethod 27 @staticmethod
33 def _CreateKey(master_name, builder_name, build_number, 28 def _CreateAnalysisId(
34 step_name, test_name): # pragma: no cover 29 master_name, builder_name, build_number, step_name, test_name):
35 return ndb.Key('MasterFlakeAnalysis', 30 encoded_test_name = base64.urlsafe_b64encode(test_name)
36 MasterFlakeAnalysis._CreateAnalysisId( 31 return '%s/%s/%s/%s/%s' % (
37 master_name, builder_name, build_number, 32 master_name, builder_name, build_number, step_name, encoded_test_name)
38 step_name, test_name))
39 33
40 @staticmethod 34 # Arguments number differs from overridden method - pylint: disable=W0221
41 def Create(master_name, builder_name, build_number, 35 @classmethod
42 step_name, test_name): # pragma: no cover 36 def Create(cls, master_name, builder_name, build_number, step_name,
43 return MasterFlakeAnalysis( 37 test_name): # pragma: no cover.
44 key=MasterFlakeAnalysis._CreateKey( 38 return super(MasterFlakeAnalysis, cls).Create(
45 master_name, builder_name, build_number, 39 MasterFlakeAnalysis._CreateAnalysisId(
46 step_name, test_name)) 40 master_name, builder_name, build_number, step_name, test_name))
47 41
48 @staticmethod 42 # Arguments number differs from overridden method - pylint: disable=W0221
49 def Get(master_name, builder_name, build_number, 43 @classmethod
50 step_name, test_name): # pragma: no cover 44 def GetVersion(cls, master_name, builder_name, build_number, step_name,
51 return MasterFlakeAnalysis._CreateKey( 45 test_name, version=None): # pragma: no cover.
52 master_name, builder_name, build_number, step_name, test_name).get() 46 return super(MasterFlakeAnalysis, cls).GetVersion(
47 key=MasterFlakeAnalysis._CreateAnalysisId(
48 master_name, builder_name, build_number, step_name, test_name),
49 version=version)
53 50
54 # List of tested build_numbers and their corresponding success rates. 51 def Reset(self):
55 # We need to keep these sorted manually. 52 self.created_time = time_util.GetUTCNow()
53 self.status = analysis_status.PENDING
54 self.completed_time = None
55 self.swarming_rerun_results = {}
56 self.error = None
57 self.correct_regression_range = None
58 self.correct_culprit = None
59 self.algorithm_parameters = None
60 self.suspected_flake_build_number = None
61 self.build_numbers = []
62 self.pass_rates = []
63
64 # The UTC timestamp this analysis was requested.
65 created_time = ndb.DateTimeProperty(indexed=True)
66
67 # The UTC timestamp this analysis was completed.
68 completed_time = ndb.DateTimeProperty(indexed=True)
69
70 # A dict containing information about each swarming rerun's results that were
71 # involved in this analysis. The contents of this dict will be used for
72 # metrics, such as the number of cache hits this analysis benefited from, the
73 # number of swarming tasks that were needed end-to-end to find the regressed
74 # build number (if any), etc.
75 #
76 # Example dict:
77 # {
78 # task_id_1: {
stgao 2016/09/30 21:07:31 Alternative to this is to create a metadata model,
lijeffrey 2016/10/01 01:28:04 Done.
79 # 'request_time': 2016-09-06 (10:21:26.288) UTC
80 # 'start_time': 2016-09-06 (10:21:26.288) UTC,
81 # 'end_time': 2016-09-06 (10:21:26.288) UTC,
82 # 'build_number': 12345,
83 # 'cache_hit': cache_status (hit/miss/partial),
84 # 'number_of_iterations': 100,
85 # 'number_of_passes': 90,
86 # },
87 # task_id_2: {
88 # ...
89 # },
90 # ...
91 # }
92 swarming_rerun_results = ndb.JsonProperty(
93 default={}, indexed=False, compressed=True)
94
95 # Error code and message, if any.
96 error = ndb.JsonProperty(indexed=False)
97
98 # Boolean whether the suspected regression range/build number is correct.
99 correct_regression_range = ndb.BooleanProperty(indexed=True)
100
101 # Boolean whether the suspected CL for found in the regression range
102 # is correct.
103 correct_culprit = ndb.BooleanProperty(indexed=True)
104
105 # The look back algorithm parameters that were used, as specified in Findit's
106 # configuration. For example,
107 # {
108 # 'iterations_to_rerun': 100,
109 # 'lower_flake_threshold': 0.02,
110 # 'max_build_numbers_to_look_back': 500,
111 # 'max_flake_in_a_row': 4,
112 # 'max_stable_in_a_row': 4,
113 # 'upper_flake_threshold': 0.98
114 # }
115 algorithm_parameters = ndb.JsonProperty(indexed=False)
116
117 # The suspected build number to have introduced the flakiness.
118 suspected_flake_build_number = ndb.IntegerProperty()
119
120 # The build numbers that were examined to generate this run's flakiness graph.
121 # This list needs to be kept sorted manually.
56 build_numbers = ndb.IntegerProperty(indexed=False, repeated=True) 122 build_numbers = ndb.IntegerProperty(indexed=False, repeated=True)
57 success_rates = ndb.FloatProperty(indexed=False, repeated=True) 123
58 suspected_flake_build_number = ndb.IntegerProperty() 124 # The corresponding pass rates of build number's swarming rerun results.
125 # This list needs to be kept sorted manually.
126 pass_rates = ndb.FloatProperty(indexed=False, repeated=True)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698