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

Unified Diff: appengine/findit/waterfall/suspected_cl_util.py

Issue 2425853005: [Findit] Modify Findit API to return more information to Sheriff-O-Matic. (Closed)
Patch Set: rebase 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 | « appengine/findit/waterfall/build_util.py ('k') | appengine/findit/waterfall/test/suspected_cl_util_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/waterfall/suspected_cl_util.py
diff --git a/appengine/findit/waterfall/suspected_cl_util.py b/appengine/findit/waterfall/suspected_cl_util.py
index 719eb354e445e01f507664bb7d3b522654c05c49..28b2786d10d19910c27d430667cd58f96c8e5864 100644
--- a/appengine/findit/waterfall/suspected_cl_util.py
+++ b/appengine/findit/waterfall/suspected_cl_util.py
@@ -5,6 +5,8 @@
from google.appengine.ext import ndb
from common import time_util
+from common.waterfall import failure_type
+from model import analysis_approach_type
from model.wf_suspected_cl import WfSuspectedCL
from waterfall import build_util
@@ -57,3 +59,40 @@ def UpdateSuspectedCL(
build['approaches'].append(approach)
suspected_cl.put()
+
+def _RoundConfidentToInteger(confidence):
+ return round(confidence * 100)
+
+
+def GetSuspectedCLConfidenceScore(confidences, cl_build):
+
+ if not confidences or not cl_build:
+ return None
+
+ if cl_build['failure_type'] == failure_type.COMPILE:
+ if cl_build['approaches'] == [
+ analysis_approach_type.HEURISTIC, analysis_approach_type.TRY_JOB]:
+ return _RoundConfidentToInteger(
+ confidences.compile_heuristic_try_job.confidence)
+ elif cl_build['approaches'] == [analysis_approach_type.TRY_JOB]:
+ return _RoundConfidentToInteger(
+ confidences.compile_try_job.confidence)
+ elif (cl_build['approaches'] == [analysis_approach_type.HEURISTIC] and
+ cl_build['top_score']):
+ for confidences_info in confidences.compile_heuristic:
+ if confidences_info.score == cl_build['top_score']:
+ return _RoundConfidentToInteger(confidences_info.confidence)
+ return None
+ else:
+ if cl_build['approaches'] == [
+ analysis_approach_type.HEURISTIC, analysis_approach_type.TRY_JOB]:
+ return _RoundConfidentToInteger(
+ confidences.test_heuristic_try_job.confidence)
+ elif cl_build['approaches'] == [analysis_approach_type.TRY_JOB]:
+ return _RoundConfidentToInteger(confidences.test_try_job.confidence)
+ elif (cl_build['approaches'] == [analysis_approach_type.HEURISTIC] and
+ cl_build['top_score']):
+ for confidences_info in confidences.test_heuristic:
+ if confidences_info.score == cl_build['top_score']:
+ return _RoundConfidentToInteger(confidences_info.confidence)
+ return None
« no previous file with comments | « appengine/findit/waterfall/build_util.py ('k') | appengine/findit/waterfall/test/suspected_cl_util_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698