| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 google.appengine.ext import ndb | 5 from google.appengine.ext import ndb |
| 6 | 6 |
| 7 from common import time_util | 7 from common import time_util |
| 8 from common.waterfall import failure_type |
| 9 from model import analysis_approach_type |
| 8 from model.wf_suspected_cl import WfSuspectedCL | 10 from model.wf_suspected_cl import WfSuspectedCL |
| 9 from waterfall import build_util | 11 from waterfall import build_util |
| 10 | 12 |
| 11 | 13 |
| 12 def GetCLInfo(cl_info_str): | 14 def GetCLInfo(cl_info_str): |
| 13 """Gets CL's repo_name and revision.""" | 15 """Gets CL's repo_name and revision.""" |
| 14 return cl_info_str.split('/') | 16 return cl_info_str.split('/') |
| 15 | 17 |
| 16 | 18 |
| 17 def _GetsStatusFromSameFailure(builds, failures): | 19 def _GetsStatusFromSameFailure(builds, failures): |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 'failures': failures, | 52 'failures': failures, |
| 51 'status': _GetsStatusFromSameFailure(suspected_cl.builds, failures), | 53 'status': _GetsStatusFromSameFailure(suspected_cl.builds, failures), |
| 52 'top_score': top_score | 54 'top_score': top_score |
| 53 } | 55 } |
| 54 else: | 56 else: |
| 55 build = suspected_cl.builds[build_key] | 57 build = suspected_cl.builds[build_key] |
| 56 if approach not in build['approaches']: | 58 if approach not in build['approaches']: |
| 57 build['approaches'].append(approach) | 59 build['approaches'].append(approach) |
| 58 | 60 |
| 59 suspected_cl.put() | 61 suspected_cl.put() |
| 62 |
| 63 def _RoundConfidentToInteger(confidence): |
| 64 return round(confidence * 100) |
| 65 |
| 66 |
| 67 def GetSuspectedCLConfidenceScore(confidences, cl_build): |
| 68 |
| 69 if not confidences or not cl_build: |
| 70 return None |
| 71 |
| 72 if cl_build['failure_type'] == failure_type.COMPILE: |
| 73 if cl_build['approaches'] == [ |
| 74 analysis_approach_type.HEURISTIC, analysis_approach_type.TRY_JOB]: |
| 75 return _RoundConfidentToInteger( |
| 76 confidences.compile_heuristic_try_job.confidence) |
| 77 elif cl_build['approaches'] == [analysis_approach_type.TRY_JOB]: |
| 78 return _RoundConfidentToInteger( |
| 79 confidences.compile_try_job.confidence) |
| 80 elif (cl_build['approaches'] == [analysis_approach_type.HEURISTIC] and |
| 81 cl_build['top_score']): |
| 82 for confidences_info in confidences.compile_heuristic: |
| 83 if confidences_info.score == cl_build['top_score']: |
| 84 return _RoundConfidentToInteger(confidences_info.confidence) |
| 85 return None |
| 86 else: |
| 87 if cl_build['approaches'] == [ |
| 88 analysis_approach_type.HEURISTIC, analysis_approach_type.TRY_JOB]: |
| 89 return _RoundConfidentToInteger( |
| 90 confidences.test_heuristic_try_job.confidence) |
| 91 elif cl_build['approaches'] == [analysis_approach_type.TRY_JOB]: |
| 92 return _RoundConfidentToInteger(confidences.test_try_job.confidence) |
| 93 elif (cl_build['approaches'] == [analysis_approach_type.HEURISTIC] and |
| 94 cl_build['top_score']): |
| 95 for confidences_info in confidences.test_heuristic: |
| 96 if confidences_info.score == cl_build['top_score']: |
| 97 return _RoundConfidentToInteger(confidences_info.confidence) |
| 98 return None |
| OLD | NEW |