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

Unified Diff: appengine/findit/handlers/build_failure.py

Issue 2398903002: [Findit] Display confidence score on result page. (Closed)
Patch Set: . Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | appengine/findit/handlers/test/build_failure_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/handlers/build_failure.py
diff --git a/appengine/findit/handlers/build_failure.py b/appengine/findit/handlers/build_failure.py
index 75aad8b9356af94f4a08d11ff13e6ed267649c37..77bd7543a5888fcbaacc7a25f0438334abd7cb6c 100644
--- a/appengine/findit/handlers/build_failure.py
+++ b/appengine/findit/handlers/build_failure.py
@@ -15,7 +15,9 @@ from common.waterfall import failure_type
from handlers import handlers_util
from handlers import result_status
from handlers.result_status import NO_TRY_JOB_REASON_MAP
+from model import analysis_approach_type
from model import analysis_status
+from model.suspected_cl_confidence import SuspectedCLConfidence
from model import result_status as analysis_result_status
from model import suspected_cl_status
from model.base_build_model import BaseBuildModel
@@ -329,6 +331,43 @@ def _PopulateHeuristicDataForCompileFailure(analysis, data):
data['suspected_cls_by_heuristic'] = compile_failure['suspected_cls']
+def _PercentFormat(float_number):
+ if not float_number or not isinstance(float_number, float):
+ return None
+ return '%d%%' % (round(float_number * 100))
+
+
+def _GetConfidenceScore(confidence, cl_build):
+
+ if not confidence:
+ return None
+
+ if cl_build['failure_type'] == failure_type.COMPILE:
+ if cl_build['approaches'] == [
+ analysis_approach_type.HEURISTIC, analysis_approach_type.TRY_JOB]:
+ return _PercentFormat(confidence.compile_heuristic_try_job.confidence)
+ elif cl_build['approaches'] == [analysis_approach_type.TRY_JOB]:
+ return _PercentFormat(confidence.compile_try_job.confidence)
+ elif (cl_build['approaches'] == [analysis_approach_type.HEURISTIC] and
+ cl_build['top_score']):
+ for confidence_info in confidence.compile_heuristic:
+ if confidence_info.score == cl_build['top_score']:
+ return _PercentFormat(confidence_info.confidence)
+ return None
+ else:
+ if cl_build['approaches'] == [
+ analysis_approach_type.HEURISTIC, analysis_approach_type.TRY_JOB]:
+ return _PercentFormat(confidence.test_heuristic_try_job.confidence)
+ elif cl_build['approaches'] == [analysis_approach_type.TRY_JOB]:
+ return _PercentFormat(confidence.test_try_job.confidence)
+ elif (cl_build['approaches'] == [analysis_approach_type.HEURISTIC] and
+ cl_build['top_score']):
+ for confidence_info in confidence.test_heuristic:
+ if confidence_info.score == cl_build['top_score']:
+ return _PercentFormat(confidence_info.confidence)
+ return None
+
+
def _GetAllSuspectedCLsAndCheckStatus(
master_name, builder_name, build_number, analysis):
build_key = BaseBuildModel.CreateBuildId(
@@ -337,8 +376,12 @@ def _GetAllSuspectedCLsAndCheckStatus(
if not suspected_cls:
return []
+ cl_confidences = SuspectedCLConfidence.Get()
+
for cl in suspected_cls:
cl['status'] = _ANALYSIS_CL_STATUS_MAP.get(analysis.result_status, None)
+ cl['confidence'] = None
+
suspected_cl = WfSuspectedCL.Get(cl['repo_name'], cl['revision'])
if not suspected_cl:
continue
@@ -346,6 +389,7 @@ def _GetAllSuspectedCLsAndCheckStatus(
build = suspected_cl.builds.get(build_key)
if build:
cl['status'] = build['status']
+ cl['confidence'] = _GetConfidenceScore(cl_confidences, build)
return suspected_cls
« no previous file with comments | « no previous file | appengine/findit/handlers/test/build_failure_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698