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

Unified Diff: slave/skia_slave_scripts/upload_bench_results.py

Issue 311433002: Revert of Adds uploading picture benchmark JSON data (Closed) Base URL: https://skia.googlesource.com/buildbot.git@master
Patch Set: Created 6 years, 7 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 | « slave/skia_slave_scripts/run_bench.py ('k') | slave/skia_slave_scripts/utils/sync_bucket_subdir.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: slave/skia_slave_scripts/upload_bench_results.py
diff --git a/slave/skia_slave_scripts/upload_bench_results.py b/slave/skia_slave_scripts/upload_bench_results.py
index 02297a03116a28e9a18e8ca74c17ef06a986567e..94d52058a4aeda7207bb2ca8ef23d8c2f241a5c8 100755
--- a/slave/skia_slave_scripts/upload_bench_results.py
+++ b/slave/skia_slave_scripts/upload_bench_results.py
@@ -8,8 +8,6 @@
from build_step import BuildStep
from utils import sync_bucket_subdir
-import builder_name_schema
-
import json
import os
import os.path
@@ -17,39 +15,6 @@
import re
import sys
from datetime import datetime
-
-
-# Modified from Skia repo code, roughly line 108 down of
-# bench/check_regressions.py
-def ReadExpectations(filename):
- """Reads expectations data from file.
-
- It returns a dictionary containing tuples of the lower, upper, and expected
- bounds, using the testname and configuration concatenated together as the
- key."""
- expectations = {}
- unstripped_keys = []
- for expectation in open(filename).readlines():
- elements = expectation.strip().split(',')
- if not elements[0] or elements[0].startswith('#'):
- continue
- if len(elements) != 5:
- raise Exception("Invalid expectation line format: %s" %
- expectation)
- # [<Bench_BmpConfig_TimeType>,<Platform-Alg>]
- bench_entry = elements[0] + ',' + elements[1]
- if bench_entry in unstripped_keys:
- raise Exception("Dup entries for bench expectation %s" %
- bench_entry)
- unstripped_keys.append(bench_entry) # Using this in case multiple lines
- # share everything except for the
- # algorithm and/or platform
- entry = elements[0]
- # [<Bench_BmpConfig_TimeType>] -> (LB, UB, EXPECTED)
- expectations[entry] = (float(elements[-2]),
- float(elements[-1]),
- float(elements[-3]))
- return expectations
class UploadBenchResults(BuildStep):
@@ -77,108 +42,30 @@
dest_gsbase=dest_gsbase,
subdir=self._GetBucketSubdir(),
do_upload=True,
- exclude_json=True,
do_download=False)
+ # Find and open JSON file to add in additional fields, then upload.
+ json_file_name = None
file_list = os.listdir(self._GetPerfDataDir())
- expectations = {}
-
- path_to_bench_expectations = os.path.join(
- 'expectations',
- 'bench',
- 'bench_expectations_%s.txt' % builder_name_schema.GetWaterfallBot(
- self._builder_name))
- try:
- expectations = ReadExpectations(path_to_bench_expectations)
- except IOError:
- print "Unable to open expectations file"
-
- re_file_extract = re.compile(r'(^.*)\.skp.*$')
- json_total = {}
- pictures_timestamp = ''
- for file_name in file_list:
- # Find bench picture files, splice in expectation data
- if not re.search('^bench_{}_data_skp_(.*)_([0-9]*)\.json$'.format(
- self._got_revision), file_name):
- continue
- json_pictures_data = {}
- if not pictures_timestamp:
- pictures_timestamp = file_name.split('_')[-1].split('.json')[0]
- full_file_name = os.path.join(self._GetPerfDataDir(), file_name)
- with open(full_file_name) as json_pictures:
- print 'Loading file {}'.format(file_name)
- json_pictures_data = json.load(json_pictures)
-
- if json_total:
- json_total['benches'].extend(json_pictures_data['benches'])
- else:
- json_total = json_pictures_data
-
- # Now add expectations to all keys
- for bench in json_total['benches']:
- for tileSet in bench['tileSets']:
- search_for_name = re_file_extract.search(bench['name'])
- if not search_for_name:
- print 'Invalid bench name: {}'.format(bench['name'])
- continue
- key = '_'.join([
- search_for_name.group(1)+'.skp',
- tileSet['name'],
- ''])
- if key in expectations.keys():
- (lower, upper, expected) = expectations[key]
- tileSet['lower'] = lower
- tileSet['upper'] = upper
- tileSet['expected'] = expected
- else:
- print "Unable to find key: {}".format(key)
-
- json_total['commitHash'] = self._got_revision
- json_total['machine'] = self._builder_name
-
- json_write_name = 'skpbench_{}_{}.json'.format(self._got_revision,
- pictures_timestamp)
- full_json_write_name = os.path.join(self._GetPerfDataDir(), json_write_name)
- with open(full_json_write_name, 'w') as json_picture_write:
- json.dump(json_total, json_picture_write)
-
- now = datetime.utcnow()
- gs_json_path = '/'.join((str(now.year).zfill(4), str(now.month).zfill(2),
- str(now.day).zfill(2), str(now.hour).zfill(2)))
- gs_dir = 'pics-json/{}/{}'.format(gs_json_path, self._builder_name)
- sync_bucket_subdir.SyncBucketSubdir(
- directory=self._GetPerfDataDir(),
- dest_gsbase=dest_gsbase,
- subdir=gs_dir,
- # TODO(kelvinly): Set up some way to configure this,
- # rather than hard coding it
- do_upload=True,
- do_download=False,
- exclude_json=False,
- filenames_filter=
- 'skpbench_({})_[0-9]+\.json'.format(self._got_revision))
-
- # Find and open the bench JSON file to add in additional fields, then upload.
- microbench_json_file = None
-
for file_name in file_list:
if re.search('microbench_({})_[0-9]+\.json'.format(self._got_revision),
file_name):
- microbench_json_file = os.path.join(self._GetPerfDataDir(), file_name)
+ json_file_name = os.path.join(self._GetPerfDataDir(), file_name)
break
- if microbench_json_file:
+ if json_file_name:
json_data = {}
- with open(microbench_json_file) as json_file:
+ with open(json_file_name) as json_file:
json_data = json.load(json_file)
json_data['machine'] = self._builder_name
json_data['commitHash'] = self._got_revision
- with open(microbench_json_file, 'w') as json_file:
+ with open(json_file_name, 'w') as json_file:
json.dump(json_data, json_file)
+ now = datetime.utcnow()
gs_json_path = '/'.join((str(now.year).zfill(4), str(now.month).zfill(2),
str(now.day).zfill(2), str(now.hour).zfill(2)))
gs_dir = 'stats-json/{}/{}'.format(gs_json_path, self._builder_name)
@@ -190,7 +77,6 @@
# rather than hard coding it
do_upload=True,
do_download=False,
- exclude_json=False,
filenames_filter=
'microbench_({})_[0-9]+\.json'.format(self._got_revision))
« no previous file with comments | « slave/skia_slave_scripts/run_bench.py ('k') | slave/skia_slave_scripts/utils/sync_bucket_subdir.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698