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

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 c811ddb014f51547e92951c29e285106377969ee..3e33f6e56e1852b3ac003adaac7acd0dda366d7e 100644
--- a/appengine/findit/handlers/build_failure.py
+++ b/appengine/findit/handlers/build_failure.py
@@ -15,8 +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 import cl_confidence
+from model.cl_confidence import CLConfidence
stgao 2016/10/06 02:17:38 Maybe SuspectConfidence instead?
chanli 2016/10/08 00:41:10 Done.
from model import result_status as analysis_result_status
from model import suspected_cl_status
from model.base_build_model import BaseBuildModel
@@ -330,6 +331,50 @@ def _PopulateHeuristicDataForCompileFailure(analysis, data):
data['suspected_cls_by_heuristic'] = compile_failure['suspected_cls']
+def _GetMostRecentConfidence(): # pragma: no cover.
+ confidences = CLConfidence.query().order(-CLConfidence.end_date).fetch(1)
stgao 2016/10/06 02:17:38 As I mentioned in the other CL, making CLConfidenc
lijeffrey 2016/10/06 14:10:33 +1 if we make CLConfidence versioned then this co
chanli 2016/10/08 00:41:10 Done.
+
+ return confidences[0] if confidences else None
+
+
+def _PercentFormat(float_number):
+ if not float_number or not isinstance(float_number, float):
+ return None
+ return '%.2f%%' % (float_number * 100)
stgao 2016/10/06 02:17:38 I guess 70% is better than 70.87%.
chanli 2016/10/08 00:41:10 Done.
+
+
+def _GetConfidence(confidence, cl_build):
lijeffrey 2016/10/06 14:10:33 nit: rename this _GetConfidencePercentage or _GetC
chanli 2016/10/08 00:41:10 Done.
+
+ 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']):
+ return _PercentFormat(
+ confidence.compile_heuristic.get(
+ str(cl_build['top_score']), {}).get('confidence'))
+ else:
+ 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']):
+ return _PercentFormat(confidence.test_heuristic.get(
+ str(cl_build['top_score']), {}).get('confidence'))
+ else: # pragma: no cover.
lijeffrey 2016/10/06 14:10:33 why is this one no cover whereas the compile one d
chanli 2016/10/08 00:41:10 Done.
+ return None
+
+
def _GetAllSuspectedCLsAndCheckStatus(
master_name, builder_name, build_number, analysis):
build_key = BaseBuildModel.CreateBuildId(
@@ -338,8 +383,12 @@ def _GetAllSuspectedCLsAndCheckStatus(
if not suspected_cls:
return []
+ cl_confidences = _GetMostRecentConfidence()
+
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
@@ -347,6 +396,7 @@ def _GetAllSuspectedCLsAndCheckStatus(
build = suspected_cl.builds.get(build_key)
if build:
cl['status'] = build['status']
+ cl['confidence'] = _GetConfidence(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