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

Side by Side Diff: appengine/findit/waterfall/suspected_cl_util.py

Issue 2230103002: [Findit] Pipeline change to save suspected cls to data store. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@0808-resubmit-suspected_cl_model
Patch Set: Add todos and make sure analysis.suspected_cls have consistent format. Created 4 years, 3 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
(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 from google.appengine.ext import ndb
6
7 from model import analysis_approach_type
8 from model.wf_suspected_cl import WfSuspectedCL
9
10 def _GetsStatusFromSameFailure(builds, failures):
11 for build in builds.values():
12 if build['status'] is not None and build['failures'] == failures:
13 return build['status']
14 return None
15
16
17 def _ModifyApproach(current_approach, new_approach):
Sharu Jiang 2016/09/19 23:17:54 Is it possible that new_approach is None? if not t
chanli 2016/09/21 22:04:25 Done.
18 if (current_approach == analysis_approach_type.BOTH or
19 current_approach == new_approach):
20 return current_approach
21
22 if not current_approach:
23 return new_approach
24
25 # current_approach and new_approach are different.
26 return analysis_approach_type.BOTH
27
28
29 @ndb.transactional
30 def UpdateSuspectedCL(
31 repo_name, revision, commit_position,
32 approach, master_name, builder_name, build_number, failure_type,
33 failures, top_score):
34
35 suspected_cl = (
36 WfSuspectedCL.Get(repo_name, revision) or
37 WfSuspectedCL.Create(repo_name, revision, commit_position))
38
39 # HEURISTIC: 1; TRY_JOB: 2; BOTH: 3.
40 suspected_cl.approach = _ModifyApproach(suspected_cl.approach, approach)
41 suspected_cl.failure_type = suspected_cl.failure_type or failure_type
42
43 build_key = '%s/%s/%d' %(master_name, builder_name, build_number)
44 if build_key not in suspected_cl.builds:
45 build = {
46 'approach': approach,
47 'failure_type': failure_type,
48 'failures': failures,
49 'status': _GetsStatusFromSameFailure(suspected_cl.builds, failures),
50 'top_score': top_score
51 }
52 suspected_cl.builds[build_key] = build
53 else:
54 build = suspected_cl.builds[build_key]
55 build['approach'] = _ModifyApproach(build['approach'], approach)
56
57 suspected_cl.put()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698