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

Side by Side Diff: appengine/findit/waterfall/identify_culprit_pipeline.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: Created 4 years, 4 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 from datetime import datetime 5 from datetime import datetime
6 6
7 from google.appengine.ext import ndb
8
7 from common.pipeline_wrapper import BasePipeline 9 from common.pipeline_wrapper import BasePipeline
10 from model import analysis_approach_type
11 from model import analysis_status
8 from model import result_status 12 from model import result_status
9 from model import analysis_status
10 from model.wf_analysis import WfAnalysis 13 from model.wf_analysis import WfAnalysis
14 from model.wf_suspected_cl import WfSuspectedCL
11 from waterfall import build_failure_analysis 15 from waterfall import build_failure_analysis
12 16
13 17
14 def _GetResultAnalysisStatus(analysis_result): 18 def _GetResultAnalysisStatus(analysis_result):
15 """Returns the status of the analysis result. 19 """Returns the status of the analysis result.
16 20
17 We can decide the status based on: 21 We can decide the status based on:
18 1. whether we found any suspected CL(s). 22 1. whether we found any suspected CL(s).
19 2. whether we have triaged the failure. 23 2. whether we have triaged the failure.
20 3. whether our analysis result is the same as triaged result. 24 3. whether our analysis result is the same as triaged result.
21 """ 25 """
22 # Now we can only set the status based on if we found any suspected CL(s). 26 # Now we can only set the status based on if we found any suspected CL(s).
23 # TODO: Add logic to decide the status after comparing with culprit CL(s). 27 # TODO: Add logic to decide the status after comparing with culprit CL(s).
24 if not analysis_result or not analysis_result['failures']: 28 if not analysis_result or not analysis_result['failures']:
25 return None 29 return None
26 30
27 for failure in analysis_result['failures']: 31 for failure in analysis_result['failures']:
28 if failure['suspected_cls']: 32 if failure['suspected_cls']:
29 return result_status.FOUND_UNTRIAGED 33 return result_status.FOUND_UNTRIAGED
30 34
31 return result_status.NOT_FOUND_UNTRIAGED 35 return result_status.NOT_FOUND_UNTRIAGED
32 36
33 37
38 @ndb.transactional
39 def _SaveSuspectedCL(
40 build_info, failure_type, repo_name, revision, commit_position):
41
42 suspected_cl = WfSuspectedCL.Get(repo_name, revision)
lijeffrey 2016/08/10 08:12:38 how about suspected_cl = WfSuspectedCL.Get(...) or
chanli 2016/08/11 23:39:35 Done.
43
44 if not suspected_cl:
45 suspected_cl = WfSuspectedCL.Create(repo_name, revision, commit_position)
46
47 if suspected_cl.approach is None:
48 suspected_cl.approach = analysis_approach_type.HEURISTIC
49 elif suspected_cl.approach == analysis_approach_type.TRY_JOB:
50 suspected_cl.approach = analysis_approach_type.BOTH
lijeffrey 2016/08/10 08:12:38 this seems not right, can you guarantee both heuri
chanli 2016/08/11 23:39:36 This update is for a heuristic result and if suspe
51
52 suspected_cl.failure_type = suspected_cl.failure_type or failure_type
53
54 if build_info not in suspected_cl.builds:
55 suspected_cl.builds.append(build_info)
56
57 suspected_cl.put()
58
34 def _GetSuspectedCLs(analysis_result): 59 def _GetSuspectedCLs(analysis_result):
35 """Returns the suspected CLs we found in analysis.""" 60 """Returns the suspected CLs we found in analysis."""
36 suspected_cls = [] 61 suspected_cls = []
37 if not analysis_result or not analysis_result['failures']: 62 if not analysis_result or not analysis_result['failures']:
38 return suspected_cls 63 return suspected_cls
39 64
40 for failure in analysis_result['failures']: 65 for failure in analysis_result['failures']:
41 for suspected_cl in failure['suspected_cls']: 66 for suspected_cl in failure['suspected_cls']:
42 cl_info = { 67 cl_info = {
43 'repo_name': suspected_cl['repo_name'], 68 'repo_name': suspected_cl['repo_name'],
(...skipping 30 matching lines...) Expand all
74 failure_info, change_logs, deps_info, signals) 99 failure_info, change_logs, deps_info, signals)
75 analysis = WfAnalysis.Get(master_name, builder_name, build_number) 100 analysis = WfAnalysis.Get(master_name, builder_name, build_number)
76 analysis.build_completed = build_completed 101 analysis.build_completed = build_completed
77 analysis.result = analysis_result 102 analysis.result = analysis_result
78 analysis.status = analysis_status.COMPLETED 103 analysis.status = analysis_status.COMPLETED
79 analysis.result_status = _GetResultAnalysisStatus(analysis_result) 104 analysis.result_status = _GetResultAnalysisStatus(analysis_result)
80 analysis.suspected_cls = _GetSuspectedCLs(analysis_result) 105 analysis.suspected_cls = _GetSuspectedCLs(analysis_result)
81 analysis.end_time = datetime.utcnow() 106 analysis.end_time = datetime.utcnow()
82 analysis.put() 107 analysis.put()
83 108
109 # Creates and/or updates WfSuspectedCL entities for suspected cls.
110 for suspected_cl in analysis.suspected_cls:
111 _SaveSuspectedCL(
112 [master_name, builder_name, build_number],
113 failure_info['failure_type'], suspected_cl['repo_name'],
114 suspected_cl['revision'], suspected_cl['commit_position'])
84 return analysis_result 115 return analysis_result
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698