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..f7237d74b36b1660f7f71b77e59c9c023dae9fb6 |
| --- /dev/null |
| +++ b/appengine/findit/model/flake/master_flake_analysis.py |
| @@ -0,0 +1,70 @@ |
| +# Copyright 2016 The Chromium Authors. All rights reserved. |
| +# 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 model import analysis_status |
| +from model.base_build_model import BaseBuildModel |
| +from model.base_analysis import BaseAnalysis |
| +from model.flake.flake_swarming_task import FlakeSwarmingTask |
| + |
| +class MasterFlakeAnalysis(BaseAnalysis, BaseBuildModel): |
| + """Represents an analysis of a candidate flaky test in a Chromium Waterfall. |
| + |
| + """ |
| + @staticmethod |
| + def CreateAnalysisId(master_name, builder_name, |
| + build_number, step_name, test_name): |
| + return '%s/%s/%s/%s/%s' % (master_name, builder_name, |
| + build_number, step_name, test_name) |
| + |
| + @ndb.ComputedProperty |
| + def step_name(self): |
| + return self.key.pairs()[0][1].split('/')[3] |
| + |
| + @ndb.ComputedProperty |
| + def test_name(self): |
| + return self.key.pairs()[0][1].split('/')[4] |
| + |
| + @staticmethod |
| + def _CreateKey(master_name, builder_name, build_number, |
| + step_name, test_name): # pragma: no cover |
| + return ndb.Key('MasterFlakeAnalysis', |
| + MasterFlakeAnalysis.CreateAnalysisId( |
| + master_name, builder_name, build_number, |
| + step_name, test_name)) |
| + |
| + @staticmethod |
| + def Create(master_name, builder_name, build_number, |
| + step_name, test_name): # pragma: no cover |
| + return MasterFlakeAnalysis( |
| + key=MasterFlakeAnalysis._CreateKey( |
| + master_name, builder_name, build_number, |
| + step_name, test_name)) |
| + |
| + @staticmethod |
| + def Get(master_name, builder_name, build_number, |
| + step_name, test_name): # pragma: no cover |
| + return MasterFlakeAnalysis._CreateKey( |
| + master_name, builder_name, build_number, step_name, test_name).get() |
| + |
| + @staticmethod |
| + def generate_data(flake_swarming_tasks): |
|
chanli
2016/07/19 20:02:10
So this function is not needed any more?
caiw
2016/07/20 18:11:00
Correct - I think it would be easier to delete thi
|
| + data = [] |
| + # Generates data in the format which the template can read. |
| + # Goes through list of flake_swarming_tasks. |
| + for fst in flake_swarming_tasks: |
| + # Append results to a list (this is a placeholder). |
| + data.append((fst.successes, fst.tries, |
| + fst.master_name(), fst.builder_name(), |
| + fst.build_number(), fst.step_name(), |
| + fst.test_name())) |
| + return data |
| + |
| + # List of tested build_numbers and their corresponding success rates. |
| + # We need to keep these sorted manually. |
| + build_numbers = ndb.IntegerProperty(indexed=True, repeated=True) |
| + success_rates = ndb.FloatProperty(indexed=False, repeated=True) |
| + flake_swarming_tasks = ndb.KeyProperty( |
| + kind='FlakeSwarmingTask', repeated=True) |