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

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

Issue 2439553002: [Findit] Reduce redundant ndb reads by querying necessary entities ahead of time and share them amo… (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/test/findit_api_test.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 28b2786d10d19910c27d430667cd58f96c8e5864..c84b01eec256405c0e7a58211458238d5aa55d56 100644
--- a/appengine/findit/waterfall/suspected_cl_util.py
+++ b/appengine/findit/waterfall/suspected_cl_util.py
@@ -60,39 +60,82 @@ def UpdateSuspectedCL(
suspected_cl.put()
-def _RoundConfidentToInteger(confidence):
- return round(confidence * 100)
+def _RoundConfidentToInteger(confidence):
+ return int(round(confidence * 100))
-def GetSuspectedCLConfidenceScore(confidences, cl_build):
- if not confidences or not cl_build:
+def GetSuspectedCLConfidenceScore(confidences, cl_from_analyzed_build):
+ if not confidences or not cl_from_analyzed_build:
return None
- if cl_build['failure_type'] == failure_type.COMPILE:
- if cl_build['approaches'] == [
- analysis_approach_type.HEURISTIC, analysis_approach_type.TRY_JOB]:
+ if cl_from_analyzed_build['failure_type'] == failure_type.COMPILE:
+ if sorted(cl_from_analyzed_build['approaches']) == sorted([
+ 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]:
+ elif cl_from_analyzed_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']):
+ elif (cl_from_analyzed_build['approaches'] == [
+ analysis_approach_type.HEURISTIC] and
+ cl_from_analyzed_build['top_score']):
for confidences_info in confidences.compile_heuristic:
- if confidences_info.score == cl_build['top_score']:
+ if confidences_info.score == cl_from_analyzed_build['top_score']:
return _RoundConfidentToInteger(confidences_info.confidence)
return None
else:
- if cl_build['approaches'] == [
- analysis_approach_type.HEURISTIC, analysis_approach_type.TRY_JOB]:
+ if sorted(cl_from_analyzed_build['approaches']) == sorted([
+ 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]:
+ elif cl_from_analyzed_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']):
+ elif (cl_from_analyzed_build['approaches'] == [
+ analysis_approach_type.HEURISTIC] and
+ cl_from_analyzed_build['top_score']):
for confidences_info in confidences.test_heuristic:
- if confidences_info.score == cl_build['top_score']:
+ if confidences_info.score == cl_from_analyzed_build['top_score']:
return _RoundConfidentToInteger(confidences_info.confidence)
return None
+
+
+def _HasNewFailures(current_failures, new_failures):
+ """Checks if there are any new failures in the current build."""
+ if current_failures == new_failures:
+ return False
+
+ for step, tests in current_failures.iteritems():
+ if not new_failures.get(step): # New step.
+ return True
+
+ for test in tests:
+ if not test in new_failures[step]: # New test.
+ return True
+
+ return False
+
+
+def GetSuspectedCLConfidenceScoreAndApproach(
+ confidences, cl_from_analyzed_build, cl_from_first_failed_build):
+ if not confidences or not cl_from_analyzed_build:
+ return None, None
+
+ if (cl_from_first_failed_build and not _HasNewFailures(
+ cl_from_analyzed_build.get('failures'),
+ cl_from_first_failed_build.get('failures'))):
+ # For non-first-time failures, the try job result is not recorded.
+ # If there is no new failures in current build, use first failed build to
+ # make sure the confidence score is correct.
+ cl_from_analyzed_build = cl_from_first_failed_build
+
+ confidence = GetSuspectedCLConfidenceScore(
+ confidences, cl_from_analyzed_build)
+ approach = (
+ analysis_approach_type.TRY_JOB if analysis_approach_type.TRY_JOB in
+ cl_from_analyzed_build['approaches'] else
+ analysis_approach_type.HEURISTIC)
+
+ return confidence, approach
« no previous file with comments | « appengine/findit/test/findit_api_test.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