Index: scripts/slave/recipe_modules/auto_bisect/bisect_results_json.py |
diff --git a/scripts/slave/recipe_modules/auto_bisect/bisect_results_json.py b/scripts/slave/recipe_modules/auto_bisect/bisect_results_json.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..12c4d6376478afcac90e21c95ab2281d9467bb7d |
--- /dev/null |
+++ b/scripts/slave/recipe_modules/auto_bisect/bisect_results_json.py |
@@ -0,0 +1,88 @@ |
+# Copyright 2015 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+# Note: The Perf Dashboard will display these data. Any changes here should |
+# be updated on Perf Dashboard as well. |
+ |
+_FAILED_INITIAL_CONFIDENCE_ABORT_REASON = ( |
+ 'The metric values for the initial "good" and "bad" revisions ' |
+ 'do not represent a clear regression.') |
+ |
+_DIRECTION_OF_IMPROVEMENT_ABORT_REASON = ( |
+ 'The metric values for the initial "good" and "bad" revisions match the ' |
+ 'expected direction of improvement. Thus, likely represent an improvement ' |
+ 'and not a regression.') |
+ |
+ |
+def get(bisector): |
qyearsley
2016/01/11 22:49:43
What do you think about making this a method of Bi
RobertoCN
2016/01/12 20:47:29
+1
chrisphan
2016/01/14 00:53:26
Done.
|
+ """Returns the results as a jsonable object.""" |
+ config = bisector.bisect_config |
+ results_confidence = 0 |
+ if bisector.culprit: |
+ results_confidence = bisector.api.m.math_utils.confidence_score( |
+ bisector.lkgr.values, bisector.fkbr.values) |
+ |
+ if bisector.failed: |
+ status = 'failed' |
+ elif bisector.bisect_over: |
+ status = 'completed' |
+ else: |
+ status = 'started' |
+ |
+ fail_reason = None |
+ if bisector.failed_initial_confidence: |
+ fail_reason = _FAILED_INITIAL_CONFIDENCE_ABORT_REASON |
+ elif bisector.failed_direction: |
+ fail_reason = _DIRECTION_OF_IMPROVEMENT_ABORT_REASON |
+ return { |
+ 'try_job_id': config.get('try_job_id'), |
+ 'bug_id': config.get('bug_id'), |
+ 'status': status, |
+ 'buildbot_log_url': '', # TODO(chrisphan) Get this. |
+ 'bisect_bot': bisector.get_perf_tester_name(), |
+ 'command': config['command'], |
+ 'metric': config['metric'], |
+ 'change': bisector.relative_change, |
+ 'score': results_confidence, |
+ 'good_revision': bisector.good_rev.commit_hash, |
+ 'bad_revision': bisector.bad_rev.commit_hash, |
+ 'warnings': bisector.warnings, |
+ 'fail_reason': fail_reason, |
+ 'culprit_data': _culprit_data(bisector), |
+ 'revision_data': _revision_data(bisector) |
+ } |
+ |
qyearsley
2016/01/11 22:49:43
Nit: two spaces between top-level functions
chrisphan
2016/01/14 00:53:26
Done.
|
+def _culprit_data(bisector): |
+ culprit = bisector.culprit |
+ api = bisector.api |
+ if not culprit: |
+ return None |
+ culprit_cl_hash = culprit.deps_revision or culprit.commit_hash |
+ culprit_info = api.query_revision_info( |
+ culprit_cl_hash, culprit.depot_name) |
+ |
+ return { |
+ 'subject': culprit_info['subject'], |
+ 'author': culprit_info['author'], |
+ 'email': culprit_info['email'], |
+ 'cl_date': culprit_info['date'], |
+ 'commit_info': culprit_info['body'], |
+ 'revisions_links': [], |
+ 'cl': culprit.deps_revision or culprit.commit_hash |
+ } |
+ |
+def _revision_data(bisector): |
+ revision_rows = [] |
+ for r in bisector.revisions: |
+ if r.tested or r.aborted: |
+ revision_rows.append({ |
+ 'depot_name': r.depot_name, |
+ 'deps_revision': r.deps_revision, |
+ 'commit_pos': r.commit_pos, |
+ 'mean_value': r.mean_value, |
+ 'std_dev': r.std_dev, |
+ 'values': r.values, |
+ 'result': 'good' if r.good else 'bad' if r.bad else 'unknown', |
+ }) |
+ return revision_rows |