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 FlakeSwarmingTaskData(ndb.Model): | |
|
chanli
2016/09/07 23:20:38
Nit: how about CheckFlakeSwarmingTasksData?
lijeffrey
2016/09/08 13:49:58
How about CheckFlakeAnalysisData?
| |
| 11 """Represents a check flake task's metadata for a complete run.""" | |
| 12 # The UTC timestamp the check flake task was requested UTC. | |
|
chanli
2016/09/07 23:20:38
Nit: remove the 'UTC' at the end?
lijeffrey
2016/09/08 13:49:58
Done.
| |
| 13 created_time = ndb.DateTimeProperty(indexed=True) | |
| 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, | |
| 23 # 'cache_hit': True/False, | |
| 24 # 'number_of_iterations': 100, | |
| 25 # 'number_of_passes': 90, | |
| 26 # }, | |
| 27 # task_id: { | |
| 28 # ... | |
| 29 # },s | |
|
chanli
2016/09/07 23:20:38
nit: remove s?
lijeffrey
2016/09/08 13:49:58
Done.
| |
| 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_numnber = ndb.IntegerProperty(indexed=None) | |
|
chanli
2016/09/07 23:20:38
indexed=False?
chanli
2016/09/07 23:20:38
Nit: regression_build_number
lijeffrey
2016/09/08 13:49:58
Done.
lijeffrey
2016/09/08 13:49:58
oops good catch!
| |
| 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 _CreateFlakeSwarmingTaskDataId(master_name, builder_name, build_number, | |
| 53 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('FlakeSwarmingTaskData', | |
| 62 FlakeSwarmingTaskData._CreateFlakeSwarmingTaskDataId( | |
| 63 master_name, builder_name, build_number, step_name, | |
| 64 test_name, version)) | |
| 65 | |
| 66 @staticmethod | |
| 67 def Create(master_name, builder_name, build_number, step_name, test_name, | |
| 68 version): | |
| 69 return FlakeSwarmingTaskData(key=FlakeSwarmingTaskData._CreateKey( | |
| 70 master_name, builder_name, build_number, step_name, test_name, version)) | |
| 71 | |
| 72 @staticmethod | |
| 73 def Get(master_name, builder_name, build_number, step_name, test_name, | |
| 74 version): | |
| 75 return FlakeSwarmingTaskData._CreateKey( | |
| 76 master_name, builder_name, build_number, step_name, test_name, | |
| 77 version).get() | |
| 78 | |
| 79 @ndb.ComputedProperty | |
| 80 def master_name(self): | |
| 81 return self.key.pairs()[0][1].split('/')[0] | |
| 82 | |
| 83 @ndb.ComputedProperty | |
| 84 def builder_name(self): | |
| 85 return self.key.pairs()[0][1].split('/')[1] | |
| 86 | |
| 87 @ndb.ComputedProperty | |
| 88 def build_number(self): | |
| 89 return self.key.pairs()[0][1].split('/')[2] | |
| 90 | |
| 91 @ndb.ComputedProperty | |
| 92 def step_name(self): | |
| 93 return self.key.pairs()[0][1].split('/')[3] | |
| 94 | |
| 95 @ndb.ComputedProperty | |
| 96 def test_name(self): | |
| 97 return base64.urlsafe_b64decode(self.key.pairs()[0][1].split('/')[4]) | |
| 98 | |
| 99 @ndb.ComputedProperty | |
| 100 def version(self): | |
| 101 return self.key.pairs()[0][1].split('/')[5] | |
| OLD | NEW |