Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 import base64 | |
| 6 | |
| 7 from google.appengine.ext import ndb | |
| 8 | |
| 9 | |
| 10 class CheckFlakeAnalysisData(ndb.Model): | |
| 11 """Represents a check flake task's metadata for a complete run.""" | |
| 12 # The UTC timestamp the check flake task was requested. | |
| 13 created_time = ndb.DateTimeProperty(indexed=True) | |
|
stgao
2016/09/09 18:22:34
Add empty lines in between.
lijeffrey
2016/09/09 19:03:01
Done.
| |
| 14 # The UTC timestamp the check flake task came completed. | |
| 15 completed_time = ndb.DateTimeProperty(indexed=True) | |
| 16 # A dict containing information about each swarming rerun's results that can | |
| 17 # be used for metrics, such as number of cache hits, average run time, etc. | |
| 18 # Example dict: | |
| 19 # { | |
| 20 # task_id: { | |
| 21 # 'start_time': 2016-09-06 (10:21:26.288) UTC, | |
| 22 # 'end_time': 2016-09-06 (10:21:26.288) UTC, | |
|
stgao
2016/09/09 18:22:34
Shouldn't build number be captured too?
lijeffrey
2016/09/09 19:03:01
good catch!
| |
| 23 # 'cache_hit': True/False, | |
| 24 # 'number_of_iterations': 100, | |
| 25 # 'number_of_passes': 90, | |
| 26 # }, | |
| 27 # task_id: { | |
| 28 # ... | |
| 29 # }, | |
| 30 # ... | |
| 31 # } | |
| 32 swarming_rerun_results = ndb.JsonProperty(indexed=False) | |
| 33 # Error code and message, if any. | |
| 34 error = ndb.JsonProperty(indexed=False) | |
| 35 # Integer representing the suspected build number that regressed. | |
| 36 regression_build_number = ndb.IntegerProperty(indexed=False) | |
| 37 # Boolean whether or not the suspected regression range/build is correct. | |
| 38 correct = ndb.BooleanProperty(indexed=False) | |
| 39 # The look back algorithm parameters that were used, as specified in Findit's | |
| 40 # configuration. For example, | |
| 41 # { | |
| 42 # 'iterations_to_rerun': 100, | |
| 43 # 'lower_flake_threshold': 0.02, | |
| 44 # 'max_build_numbers_to_look_back': 500, | |
| 45 # 'max_flake_in_a_row': 4, | |
| 46 # 'max_stable_in_a_row': 4, | |
| 47 # 'upper_flake_threshold': 0.98 | |
| 48 # } | |
| 49 algorithm_parameters = ndb.JsonProperty(indexed=False) | |
| 50 | |
| 51 @staticmethod | |
| 52 def _CreateCheckFlakeAnalysisDataId( | |
|
stgao
2016/09/09 18:22:34
Merge into _CreateKey below?
lijeffrey
2016/09/09 19:03:01
Done.
| |
| 53 master_name, builder_name, build_number, step_name, test_name, version): | |
| 54 encoded_test_name = base64.urlsafe_b64encode(test_name) | |
| 55 return '%s/%s/%s/%s/%s/%s' % (master_name, builder_name, build_number, | |
| 56 step_name, encoded_test_name, version) | |
| 57 | |
| 58 @staticmethod | |
| 59 def _CreateKey(master_name, builder_name, build_number, step_name, test_name, | |
| 60 version): | |
| 61 return ndb.Key( | |
| 62 'CheckFlakeAnalysisData', | |
| 63 CheckFlakeAnalysisData._CreateCheckFlakeAnalysisDataId( | |
| 64 master_name, builder_name, build_number, step_name, test_name, | |
| 65 version)) | |
| 66 | |
| 67 @staticmethod | |
| 68 def Create(master_name, builder_name, build_number, step_name, test_name, | |
| 69 version): | |
| 70 return CheckFlakeAnalysisData(key=CheckFlakeAnalysisData._CreateKey( | |
| 71 master_name, builder_name, build_number, step_name, test_name, version)) | |
| 72 | |
| 73 @staticmethod | |
| 74 def Get(master_name, builder_name, build_number, step_name, test_name, | |
| 75 version): | |
| 76 return CheckFlakeAnalysisData._CreateKey( | |
| 77 master_name, builder_name, build_number, step_name, test_name, | |
| 78 version).get() | |
| 79 | |
| 80 @ndb.ComputedProperty | |
| 81 def master_name(self): | |
|
stgao
2016/09/09 18:22:34
Why not inherent BaseBuildModel to reduce these?
lijeffrey
2016/09/09 19:03:01
Done.
| |
| 82 return self.key.pairs()[0][1].split('/')[0] | |
| 83 | |
| 84 @ndb.ComputedProperty | |
| 85 def builder_name(self): | |
| 86 return self.key.pairs()[0][1].split('/')[1] | |
| 87 | |
| 88 @ndb.ComputedProperty | |
| 89 def build_number(self): | |
| 90 return self.key.pairs()[0][1].split('/')[2] | |
| 91 | |
| 92 @ndb.ComputedProperty | |
| 93 def step_name(self): | |
| 94 return self.key.pairs()[0][1].split('/')[3] | |
| 95 | |
| 96 @ndb.ComputedProperty | |
| 97 def test_name(self): | |
| 98 return base64.urlsafe_b64decode(self.key.pairs()[0][1].split('/')[4]) | |
| 99 | |
| 100 @ndb.ComputedProperty | |
| 101 def version(self): | |
| 102 return self.key.pairs()[0][1].split('/')[5] | |
| OLD | NEW |