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

Side by Side Diff: infra/bots/recipe_modules/skia/resources/upload_bench_results.py

Issue 2175373002: Move Skia recipes from build repo (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address more comments Created 4 years, 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """ Upload benchmark performance data results. """
7
8 import gzip
9 import os
10 import os.path
11 import re
12 import subprocess
13 import sys
14 import tempfile
15
16 from common.skia import builder_name_schema
17 from common.skia import global_constants
18 from datetime import datetime
19
20
21 def _UploadJSONResults(builder_name, build_number, dest_gsbase, gs_subdir,
22 full_json_path, gzipped=True, gsutil_path='gsutil',
23 issue_number=None):
24 now = datetime.utcnow()
25 gs_json_path = '/'.join((str(now.year).zfill(4), str(now.month).zfill(2),
26 str(now.day).zfill(2), str(now.hour).zfill(2)))
27 gs_dir = '/'.join((gs_subdir, gs_json_path, builder_name))
28 if builder_name_schema.IsTrybot(builder_name):
29 if not issue_number:
30 raise Exception('issue_number build property is missing!')
31 gs_dir = '/'.join(('trybot', gs_dir, build_number, issue_number))
32 full_path_to_upload = full_json_path
33 file_to_upload = os.path.basename(full_path_to_upload)
34 http_header = ['Content-Type:application/json']
35 if gzipped:
36 http_header.append('Content-Encoding:gzip')
37 gzipped_file = os.path.join(tempfile.gettempdir(), file_to_upload)
38 # Apply gzip.
39 with open(full_path_to_upload, 'rb') as f_in:
40 with gzip.open(gzipped_file, 'wb') as f_out:
41 f_out.writelines(f_in)
42 full_path_to_upload = gzipped_file
43 cmd = ['python', gsutil_path]
44 for header in http_header:
45 cmd.extend(['-h', header])
46 cmd.extend(['cp', '-a', 'public-read', full_path_to_upload,
47 '/'.join((dest_gsbase, gs_dir, file_to_upload))])
48 print ' '.join(cmd)
49 subprocess.check_call(cmd)
50
51
52 def main(builder_name, build_number, perf_data_dir, got_revision, gsutil_path,
53 issue_number=None):
54 """Uploads gzipped nanobench JSON data."""
55 # Find the nanobench JSON
56 file_list = os.listdir(perf_data_dir)
57 RE_FILE_SEARCH = re.compile(
58 'nanobench_({})_[0-9]+\.json'.format(got_revision))
59 nanobench_name = None
60
61 for file_name in file_list:
62 if RE_FILE_SEARCH.search(file_name):
63 nanobench_name = file_name
64 break
65
66 if nanobench_name:
67 dest_gsbase = 'gs://' + global_constants.GS_GM_BUCKET
68 nanobench_json_file = os.path.join(perf_data_dir,
69 nanobench_name)
70 _UploadJSONResults(builder_name, build_number, dest_gsbase, 'nano-json-v1',
71 nanobench_json_file, gsutil_path=gsutil_path,
72 issue_number=issue_number)
73
74
75 if __name__ == '__main__':
76 main(*sys.argv[1:])
77
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698