Chromium Code Reviews| Index: gm/rebaseline_server/download_actuals.py |
| diff --git a/gm/rebaseline_server/download_actuals.py b/gm/rebaseline_server/download_actuals.py |
| index c11f1914b2abd4f70cf56a1196e9936725751111..fcbf746949783bf1637482d9e0aafce4496e3c94 100755 |
| --- a/gm/rebaseline_server/download_actuals.py |
| +++ b/gm/rebaseline_server/download_actuals.py |
| @@ -10,10 +10,13 @@ Download actual GM results for a particular builder. |
| """ |
| # System-level imports |
| +import httplib |
| +import logging |
| import optparse |
| import os |
| import posixpath |
| import re |
| +import traceback |
| import urllib2 |
| # Must fix up PYTHONPATH before importing from within Skia |
| @@ -96,6 +99,85 @@ def get_builders_list(summaries_bucket=GM_SUMMARIES_BUCKET): |
| dirs, _ = gs_utils.GSUtils().list_bucket_contents(bucket=GM_SUMMARIES_BUCKET) |
| return dirs |
| +def get_rietveld_actuals(issue, json_filename): |
| + """ Returns the actuals for the given rietveld issue's tryjobs. |
| + {non_try_builder:string -> [ bucket:string, path:string, generation:string ]} |
| + |
| + e.g. |
| + {'Test-Android-Xoom-Tegra2-Arm7-Release': ( |
| + 'chromium-skia-gm-summaries', |
| + 'Test-Android-Xoom-Tegra2-Arm7-Release-Trybot/actual-results.json', |
| + '1415041165535000')} |
| + """ |
| + result = dict() |
| + json_filename_re = re.compile('^Created: gs://([^/]+)/((?:[^/]+/)+%s)#(\d+)$' |
| + % re.escape(json_filename), re.MULTILINE) |
| + codereview_api_url = 'https://codereview.chromium.org/api' |
| + upload_gm_results_step_url = '/steps/Upload GM Results/logs/stdio' |
| + |
| + logging.info('Fetching issue %s ...' % (issue,)) |
| + json_issue_url = '%s/%s' % (codereview_api_url, issue) |
| + json_issue_data = urllib2.urlopen(json_issue_url).read() |
| + issue_dict = gm_json.LoadFromString(json_issue_data) |
| + |
| + patchsets = issue_dict.get("patchsets", []) |
| + patchset = patchsets[-1] |
| + if not patchset: |
| + logging.warning('No patchsets for rietveld issue %s.' % (issue,)) |
| + return result |
| + |
| + logging.info('Fetching issue %s patch %s...' % (issue, patchset)) |
| + json_patchset_url = '%s/%s/%s' % (codereview_api_url, issue, patchset) |
| + json_patchset_data = urllib2.urlopen(json_patchset_url).read() |
| + patchset_dict = gm_json.LoadFromString(json_patchset_data) |
| + |
| + # try_job_results is ordered reverse chronologically |
| + try_job_results = patchset_dict.get('try_job_results', []) |
| + for try_job_result in try_job_results: |
| + builder = try_job_result.get('builder', '<bad builder>') |
| + non_try_builder = builder |
|
rmistry
2014/11/05 13:39:16
Seems confusing to switch non_try_builder's value
bungeman-skia
2014/11/07 22:56:52
Done.
|
| + if non_try_builder.endswith('-Trybot'): |
| + non_try_builder = non_try_builder[:-len('-Trybot')] |
| + if non_try_builder in result: |
| + continue |
| + |
| + logging.info('Fetching issue %s patch %s try %s...' % |
| + (issue, patchset, builder)) |
| + build_url = try_job_result.get('url', '<bad url>') |
| + gm_upload_output_url = build_url + urllib2.quote(upload_gm_results_step_url) |
| + logging.info('Fetching %s ...' % (gm_upload_output_url,)) |
| + |
| + # Tryjobs might not produce the step, but don't let that fail everything. |
| + gm_upload_output = None |
| + try: |
| + gm_upload_output = urllib2.urlopen(gm_upload_output_url).read() |
| + except urllib2.HTTPError, e: |
| + logging.warning('HTTPError: ' + str(e.code)) |
| + except urllib2.URLError, e: |
| + logging.warning('URLError: ' + str(e.reason)) |
| + except httplib.HTTPException, e: |
| + logging.warning('HTTPException') |
| + except Exception: |
| + logging.warning('generic exception: ' + traceback.format_exc()) |
|
rmistry
2014/11/05 13:39:16
traceback.format_exc() returns None so this will p
bungeman-skia
2014/11/07 22:56:53
Done.
|
| + if not gm_upload_output: |
| + logging.warning('Could not fetch %s .' % (gm_upload_output_url,)) |
| + continue |
| + |
| + json_filename_match = json_filename_re.search(gm_upload_output) |
| + if json_filename_match: |
| + logging.info('Found issue %s patch %s try %s result gs://%s/%s#%s .' % |
| + (issue, patchset, non_try_builder, |
| + json_filename_match.group(1), |
| + json_filename_match.group(2), |
| + json_filename_match.group(3))) |
| + result[non_try_builder] = [json_filename_match.group(1), |
| + json_filename_match.group(2), |
| + json_filename_match.group(3)] |
| + else: |
| + logging.warning('Did not find %s for issue %s patch %s try %s.' % |
| + (json_filename, issue, patchset, builder)) |
| + |
| + return result |
| def main(): |
| parser = optparse.OptionParser() |