Chromium Code Reviews| Index: appengine/findit/model/flake/master_flake_analysis.py |
| diff --git a/appengine/findit/model/flake/master_flake_analysis.py b/appengine/findit/model/flake/master_flake_analysis.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b0cb54ec1294db1c19d9f725101a2824b29748fe |
| --- /dev/null |
| +++ b/appengine/findit/model/flake/master_flake_analysis.py |
| @@ -0,0 +1,72 @@ |
| +# Copyright 2014 The Chromium Authors. All rights reserved. |
|
chanli
2016/07/07 23:38:28
2014 -> 2016
caiw
2016/07/14 00:59:40
Done.
|
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +from google.appengine.ext import ndb |
| + |
| +from common import constants |
| +from model import analysis_status |
| +from model.flake.base_analysis import BaseAnalysis |
| +from model.flake.flake_swarming_task import FlakeSwarmingTask |
| + |
| +class MasterFlakeAnalysis(BaseAnalysis): |
| + """Represents an analysis of a candidate flaky test in a Chromium Waterfall. |
| + |
| + """ |
| + @staticmethod |
| + def CreateAnalysisId(master_name, builder_name, step_name): |
| + return '%s/%s/%s' % (master_name, builder_name, step_name) |
| + |
| + @ndb.ComputedProperty |
| + def master_name(self): |
|
stgao
2016/07/08 22:51:27
Same here for using BaseBuildModel class.
caiw
2016/07/14 00:59:40
Done.
|
| + return self.key.pairs()[0][1].split('/')[0] |
| + |
| + @ndb.ComputedProperty |
| + def builder_name(self): |
| + return self.key.pairs()[0][1].split('/')[1] |
| + |
| + @ndb.ComputedProperty |
| + def step_name(self): |
| + return self.key.pairs()[0][1].split('/')[2] |
| + |
| + @ndb.ComputedProperty |
| + def build_number(self): |
| + return 0 |
| + |
| + @staticmethod |
| + def _CreateKey(master_name, builder_name, step_name): # pragma: no cover |
| + return ndb.Key('MasterFlakeAnalysis', |
| + MasterFlakeAnalysis.CreateAnalysisId( |
| + master_name, builder_name, step_name)) |
| + |
| + @staticmethod |
| + def Create(master_name, builder_name, step_name): # pragma: no cover |
| + return MasterFlakeAnalysis( |
| + |
| + key=MasterFlakeAnalysis._CreateKey( |
| + master_name, builder_name, step_name)) |
| + |
| + @staticmethod |
| + def Get(master_name, builder_name, step_name): # pragma: no cover |
| + return MasterFlakeAnalysis._CreateKey( |
| + master_name, builder_name, step_name).get() |
| + |
| + def generate_data(self): |
| + data = [] |
| + # Generates data in the format which the template can read |
| + # Go through list of flake_swarming_tasks |
| + for fst in self.flake_swarming_tasks: |
| + # Go through list of flake_swarming_task_results |
| + for fstr in fst.flake_swarming_task_results: |
| + # Append results to a list (this is a placeholder) |
| + data.append((fstr.successes, fstr.tries, |
| + fstr.master_name(), fstr.builder_name(), |
| + fstr.step_name(), fstr.build_number(), |
| + fstr.test_name())) |
| + # List of tested build_numbers and their corresponding success rates. |
| + # We need to keep these sorted manually. |
| + # This is not going to work when we have multiple tests. |
| + build_numbers = ndb.IntegerProperty(indexed=True, repeated=True) |
| + success_rates = ndb.FloatProperty(indexed=False, repeated=True) |
|
stgao
2016/07/08 22:51:27
Is the success rate per-test? If so, should we mak
caiw
2016/07/14 00:59:40
Done.
|
| + flake_swarming_tasks = ndb.KeyProperty( |
| + kind='FlakeSwarmingTask', repeated=True) |