| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 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 | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 """Uploads the results of render_skps.py.""" | |
| 7 | |
| 8 import contextlib | |
| 9 import os | |
| 10 import sys | |
| 11 import urllib | |
| 12 | |
| 13 from build_step import BuildStep | |
| 14 from utils import gs_utils | |
| 15 import skia_vars | |
| 16 | |
| 17 URL_FORMATTER = ( | |
| 18 'http://skia-tree-status.appspot.com/redirect/rebaseline-server/' | |
| 19 '{directive}setADir={actuals_summary_dir}&setBDir={actuals_summary_dir}&' | |
| 20 'setASection=expected-results&setBSection=actual-results') | |
| 21 | |
| 22 | |
| 23 class UploadRenderedSKPs(BuildStep): | |
| 24 | |
| 25 def __init__(self, attempts=3, **kwargs): | |
| 26 super(UploadRenderedSKPs, self).__init__( | |
| 27 attempts=attempts, **kwargs) | |
| 28 self._gs_images_bucket = skia_vars.GetGlobalVariable('skp_images_bucket') | |
| 29 self._gs_summaries_bucket = skia_vars.GetGlobalVariable( | |
| 30 'skp_summaries_bucket') | |
| 31 | |
| 32 def _Run(self): | |
| 33 gs = gs_utils.GSUtils() | |
| 34 | |
| 35 # Upload any new image files to Google Storage. | |
| 36 # We use checksum-based filenames, so any files which have already been | |
| 37 # uploaded don't need to be uploaded again. | |
| 38 src_dir = os.path.abspath(self.playback_actual_images_dir) | |
| 39 dest_bucket = self._gs_images_bucket | |
| 40 if os.listdir(src_dir): | |
| 41 print 'Uploading image files from %s to gs://%s/' % ( | |
| 42 src_dir, dest_bucket) | |
| 43 gs.upload_dir_contents( | |
| 44 source_dir=src_dir, dest_bucket=dest_bucket, dest_dir=None, | |
| 45 upload_if=gs.UploadIf.IF_NEW, | |
| 46 predefined_acl=gs.PLAYBACK_CANNED_ACL, | |
| 47 fine_grained_acl_list=gs.PLAYBACK_FINEGRAINED_ACL_LIST) | |
| 48 else: | |
| 49 print ('Skipping upload to Google Storage, because no image files in %s' % | |
| 50 src_dir) | |
| 51 | |
| 52 # Upload image summaries (checksums) to Google Storage. | |
| 53 # | |
| 54 # It's important to only upload each summary file if it has changed, | |
| 55 # because we use the history of the file in Google Storage to tell us | |
| 56 # when any of the results changed. | |
| 57 src_dir = os.path.abspath(self.playback_actual_summaries_dir) | |
| 58 dest_bucket = self._gs_summaries_bucket | |
| 59 builder_name = self._builder_name | |
| 60 if os.listdir(src_dir): | |
| 61 print ('Uploading image summaries from %s to gs://%s/%s' % ( | |
| 62 src_dir, dest_bucket, builder_name)) | |
| 63 gs.upload_dir_contents( | |
| 64 source_dir=src_dir, dest_bucket=dest_bucket, dest_dir=builder_name, | |
| 65 upload_if=gs.UploadIf.IF_MODIFIED, | |
| 66 predefined_acl=gs.PLAYBACK_CANNED_ACL, | |
| 67 fine_grained_acl_list=gs.PLAYBACK_FINEGRAINED_ACL_LIST) | |
| 68 # Tell rebaseline_server to prefetch latest SKP results. | |
| 69 prefetch_url = rebaseline_server_url( | |
| 70 directive='prefetch/', builder_name=builder_name) | |
| 71 print ('Triggering prefetch URL %s' % prefetch_url) | |
| 72 with contextlib.closing(urllib.urlopen(prefetch_url)): | |
| 73 pass | |
| 74 else: | |
| 75 print ('Skipping upload to Google Storage, because no image summaries ' | |
| 76 'in %s' % src_dir) | |
| 77 | |
| 78 | |
| 79 def rebaseline_server_url(directive, builder_name): | |
| 80 """Returns the URL for results from this builder on rebaseline_server. | |
| 81 | |
| 82 Args: | |
| 83 directive: part of the URL, indicating whether to generate a 'prefetch' | |
| 84 URL, a 'live-loader' URL, or a link to live-view.html | |
| 85 builder_name: name of this builder | |
| 86 """ | |
| 87 bucket = skia_vars.GetGlobalVariable('skp_summaries_bucket') | |
| 88 return URL_FORMATTER.format( | |
| 89 directive=directive, | |
| 90 actuals_summary_dir=urllib.quote( | |
| 91 'gs://%s/%s' % (bucket, builder_name), safe='')) | |
| 92 | |
| 93 | |
| 94 if '__main__' == __name__: | |
| 95 sys.exit(BuildStep.RunBuildStep(UploadRenderedSKPs)) | |
| OLD | NEW |