OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 | 6 |
7 """rebase.py: standalone script to batch update bench expectations. | 7 """rebase.py: standalone script to batch update bench expectations. |
8 | 8 |
9 Requires gsutil to access gs://chromium-skia-gm and Rietveld credentials. | 9 Requires gsutil to access gs://chromium-skia-gm and Rietveld credentials. |
10 | 10 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 out, err = proc.communicate() | 77 out, err = proc.communicate() |
78 if err: | 78 if err: |
79 clean_dir(gs_dir) | 79 clean_dir(gs_dir) |
80 return False | 80 return False |
81 files = 0 | 81 files = 0 |
82 for f in os.listdir(os.path.join(gs_dir, p)): | 82 for f in os.listdir(os.path.join(gs_dir, p)): |
83 if filter_file(f): | 83 if filter_file(f): |
84 os.remove(os.path.join(gs_dir, p, f)) | 84 os.remove(os.path.join(gs_dir, p, f)) |
85 else: | 85 else: |
86 files += 1 | 86 files += 1 |
87 if files == 4: | 87 if files: |
88 return True | 88 return True |
89 return False | 89 return False |
90 | 90 |
91 def calc_expectations(p, h, gs_dir, exp_dir, repo_dir): | 91 def calc_expectations(p, h, gs_dir, exp_dir, repo_dir): |
92 exp_filename = 'bench_expectations_%s.txt' % p | 92 exp_filename = 'bench_expectations_%s.txt' % p |
93 proc = subprocess.Popen(['python', 'skia/bench/gen_bench_expectations.py', | 93 proc = subprocess.Popen(['python', 'skia/bench/gen_bench_expectations.py', |
94 '-r', h, '-b', p, '-d', os.path.join(gs_dir, p), '-o', | 94 '-r', h, '-b', p, '-d', os.path.join(gs_dir, p), '-o', |
95 os.path.join(exp_dir, exp_filename)], | 95 os.path.join(exp_dir, exp_filename)], |
96 stdout=subprocess.PIPE) | 96 stdout=subprocess.PIPE) |
97 out, err = proc.communicate() | 97 out, err = proc.communicate() |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 ts_str = '%s' % time.time() | 213 ts_str = '%s' % time.time() |
214 gs_dir = os.path.join(d, 'gs' + ts_str) | 214 gs_dir = os.path.join(d, 'gs' + ts_str) |
215 exp_dir = os.path.join(d, 'exp' + ts_str) | 215 exp_dir = os.path.join(d, 'exp' + ts_str) |
216 clean_dir(gs_dir) | 216 clean_dir(gs_dir) |
217 clean_dir(exp_dir) | 217 clean_dir(exp_dir) |
218 for p in PLATFORMS: | 218 for p in PLATFORMS: |
219 clean_dir(os.path.join(gs_dir, p)) | 219 clean_dir(os.path.join(gs_dir, p)) |
220 hash_to_use = '' | 220 hash_to_use = '' |
221 for h in reversed(hashes): | 221 for h in reversed(hashes): |
222 li = get_gs_filelist(p, h) | 222 li = get_gs_filelist(p, h) |
223 if len(li) != 4: # no or partial data | 223 if not len(li): # no data |
224 continue | 224 continue |
225 if download_gs_files(p, h, gs_dir): | 225 if download_gs_files(p, h, gs_dir): |
226 print 'Copied %s/%s' % (p, h) | 226 print 'Copied %s/%s' % (p, h) |
227 hash_to_use = h | 227 hash_to_use = h |
228 break | 228 break |
229 else: | 229 else: |
230 print 'DOWNLOAD BENCH FAILED %s/%s' % (p, h) | 230 print 'DOWNLOAD BENCH FAILED %s/%s' % (p, h) |
231 break | 231 break |
232 if hash_to_use: | 232 if hash_to_use: |
233 if calc_expectations(p, h, gs_dir, exp_dir, repo_dir): | 233 if calc_expectations(p, h, gs_dir, exp_dir, repo_dir): |
234 update_li.append('bench_expectations_%s.txt' % p) | 234 update_li.append('bench_expectations_%s.txt' % p) |
235 if not update_li: | 235 if not update_li: |
236 print 'No bench data to update after %s!' % args.githash | 236 print 'No bench data to update after %s!' % args.githash |
237 elif not git_commit_expectations( | 237 elif not git_commit_expectations( |
238 repo_dir, exp_dir, update_li, args.githash[:7], commit): | 238 repo_dir, exp_dir, update_li, args.githash[:7], commit): |
239 print 'ERROR uploading expectations using git.' | 239 print 'ERROR uploading expectations using git.' |
240 elif not commit: | 240 elif not commit: |
241 print 'CL created. Please take a look at the link above.' | 241 print 'CL created. Please take a look at the link above.' |
242 else: | 242 else: |
243 print 'New bench baselines should be in CQ now.' | 243 print 'New bench baselines should be in CQ now.' |
244 delete_dirs([gs_dir, exp_dir]) | 244 delete_dirs([gs_dir, exp_dir]) |
245 | 245 |
246 | 246 |
247 if __name__ == "__main__": | 247 if __name__ == "__main__": |
248 main() | 248 main() |
OLD | NEW |