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

Side by Side Diff: appengine/findit/model/flake/flake_try_job.py

Issue 2605803002: [Findit] Refactoring WfTryJobData into BaseTryJobData, WfTryJobData, and FlakeTryJobData (Closed)
Patch Set: Fixing nits Created 3 years, 11 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 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 model.base_try_job import BaseTryJob 9 from model.base_try_job import BaseTryJob
10 10
11 11
12 class FlakeTryJob(BaseTryJob): 12 class FlakeTryJob(BaseTryJob):
13 """Represents a try job results for a check flake try job.""" 13 """Represents a try job results for a check flake try job."""
14 # A list of dict containing results and urls of each flake try job. 14 # A list of dict containing results and urls of each flake try job.
15 # For example: 15 # For example:
16 # [ 16 # [
17 # { 17 # {
18 # 'report': (dict) The 'result' dict of the try job, 18 # 'report': (dict) The 'result' dict of the try job,
19 # 'url': (str) The url to the try job, 19 # 'url': (str) The url to the try job,
20 # 'try_job_id': (str) The try job id. 20 # 'try_job_id': (str) The try job id.
21 # }, 21 # },
22 # ... 22 # ...
23 # ] 23 # ]
24 flake_results = ndb.JsonProperty(indexed=False, compressed=True) 24 flake_results = ndb.JsonProperty(indexed=False, compressed=True)
25 25
26 @classmethod
27 def GetMasterName(cls, key):
28 return key.pairs()[0][1].split('/')[0]
29
30 @classmethod
31 def GetBuilderName(cls, key):
32 return key.pairs()[0][1].split('/')[1]
33
34 @classmethod
35 def GetStepName(cls, key):
36 return key.pairs()[0][1].split('/')[2]
37
38 @classmethod
39 def GetTestName(cls, key):
40 return base64.b64decode(key.pairs()[0][1].split('/')[3])
41
42 @classmethod
43 def GetGitHash(cls, key):
44 return key.pairs()[0][1].split('/')[4]
45
46 @ndb.ComputedProperty
47 def master_name(self):
48 return self.GetMasterName(self.key)
49
50 @ndb.ComputedProperty
51 def builder_name(self):
52 return self.GetBuilderName(self.key)
53
54 @ndb.ComputedProperty
55 def step_name(self):
56 return self.GetStepName(self.key)
57
58 @ndb.ComputedProperty
59 def test_name(self):
60 return self.GetTestName(self.key)
61
62 @ndb.ComputedProperty
63 def git_hash(self):
64 return self.GetGitHash(self.key)
65
26 @staticmethod 66 @staticmethod
27 def _CreateTryJobId(master_name, builder_name, step_name, test_name, 67 def _CreateTryJobId(master_name, builder_name, step_name, test_name,
28 git_hash): # pragma: no cover 68 git_hash): # pragma: no cover
29 """Creates an ID to associate with this try job. 69 """Creates an ID to associate with this try job.
30 70
31 Args: 71 Args:
32 master_name (str): The name of the master the flake was detected on. 72 master_name (str): The name of the master the flake was detected on.
33 builder_name (str): the name of the builder the flake was detected on. 73 builder_name (str): the name of the builder the flake was detected on.
34 step_name (str): The name of the step the flake was detected on. 74 step_name (str): The name of the step the flake was detected on.
35 test_name (str): The original name of the test that flaked. This will be 75 test_name (str): The original name of the test that flaked. This will be
(...skipping 21 matching lines...) Expand all
57 key=FlakeTryJob._CreateKey(master_name, builder_name, step_name, 97 key=FlakeTryJob._CreateKey(master_name, builder_name, step_name,
58 test_name, git_hash)) 98 test_name, git_hash))
59 flake_try_job.flake_results = flake_try_job.flake_results or [] 99 flake_try_job.flake_results = flake_try_job.flake_results or []
60 flake_try_job.try_job_ids = flake_try_job.try_job_ids or [] 100 flake_try_job.try_job_ids = flake_try_job.try_job_ids or []
61 return flake_try_job 101 return flake_try_job
62 102
63 @staticmethod 103 @staticmethod
64 def Get(master_name, builder_name, step_name, test_name, git_hash): 104 def Get(master_name, builder_name, step_name, test_name, git_hash):
65 return FlakeTryJob._CreateKey( 105 return FlakeTryJob._CreateKey(
66 master_name, builder_name, step_name, test_name, git_hash).get() 106 master_name, builder_name, step_name, test_name, git_hash).get()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698