| 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 """Uploads the results of render_skps.py.""" | 6 """Uploads the results of render_skps.py.""" |
| 7 | 7 |
| 8 import contextlib | 8 import contextlib |
| 9 import os | 9 import os |
| 10 import sys | 10 import sys |
| 11 import urllib | 11 import urllib |
| 12 | 12 |
| 13 from build_step import BuildStep | 13 from build_step import BuildStep |
| 14 from utils import gs_utils | 14 from utils import gs_utils |
| 15 import skia_vars | 15 import skia_vars |
| 16 | 16 |
| 17 PREFETCH_URL_FORMATTER = ( | 17 URL_FORMATTER = ( |
| 18 'http://skia-tree-status.appspot.com/redirect/rebaseline-server/prefetch/' | 18 'http://skia-tree-status.appspot.com/redirect/rebaseline-server/' |
| 19 'setADir={set_a_dir}&setBDir={set_b_dir}') | 19 '{directive}setADir={actuals_summary_dir}&setBDir={actuals_summary_dir}&' |
| 20 'setASection=expected-results&setBSection=actual-results') |
| 20 | 21 |
| 21 | 22 |
| 22 class UploadRenderedSKPs(BuildStep): | 23 class UploadRenderedSKPs(BuildStep): |
| 23 | 24 |
| 24 def __init__(self, attempts=3, **kwargs): | 25 def __init__(self, attempts=3, **kwargs): |
| 25 super(UploadRenderedSKPs, self).__init__( | 26 super(UploadRenderedSKPs, self).__init__( |
| 26 attempts=attempts, **kwargs) | 27 attempts=attempts, **kwargs) |
| 27 self._gs_images_bucket = skia_vars.GetGlobalVariable('skp_images_bucket') | 28 self._gs_images_bucket = skia_vars.GetGlobalVariable('skp_images_bucket') |
| 28 self._gs_summaries_bucket = skia_vars.GetGlobalVariable( | 29 self._gs_summaries_bucket = skia_vars.GetGlobalVariable( |
| 29 'skp_summaries_bucket') | 30 'skp_summaries_bucket') |
| (...skipping 18 matching lines...) Expand all Loading... |
| 48 print ('Skipping upload to Google Storage, because no image files in %s' % | 49 print ('Skipping upload to Google Storage, because no image files in %s' % |
| 49 src_dir) | 50 src_dir) |
| 50 | 51 |
| 51 # Upload image summaries (checksums) to Google Storage. | 52 # Upload image summaries (checksums) to Google Storage. |
| 52 # | 53 # |
| 53 # It's important to only upload each summary file if it has changed, | 54 # It's important to only upload each summary file if it has changed, |
| 54 # because we use the history of the file in Google Storage to tell us | 55 # because we use the history of the file in Google Storage to tell us |
| 55 # when any of the results changed. | 56 # when any of the results changed. |
| 56 src_dir = os.path.abspath(self.playback_actual_summaries_dir) | 57 src_dir = os.path.abspath(self.playback_actual_summaries_dir) |
| 57 dest_bucket = self._gs_summaries_bucket | 58 dest_bucket = self._gs_summaries_bucket |
| 58 dest_dir = self._args['builder_name'] | 59 builder_name = self._args['builder_name'] |
| 59 if os.listdir(src_dir): | 60 if os.listdir(src_dir): |
| 60 print ('Uploading image summaries from %s to gs://%s/%s' % ( | 61 print ('Uploading image summaries from %s to gs://%s/%s' % ( |
| 61 src_dir, dest_bucket, dest_dir)) | 62 src_dir, dest_bucket, builder_name)) |
| 62 gs.upload_dir_contents( | 63 gs.upload_dir_contents( |
| 63 source_dir=src_dir, dest_bucket=dest_bucket, dest_dir=dest_dir, | 64 source_dir=src_dir, dest_bucket=dest_bucket, dest_dir=builder_name, |
| 64 upload_if=gs.UploadIf.IF_MODIFIED, | 65 upload_if=gs.UploadIf.IF_MODIFIED, |
| 65 predefined_acl=gs.PLAYBACK_CANNED_ACL, | 66 predefined_acl=gs.PLAYBACK_CANNED_ACL, |
| 66 fine_grained_acl_list=gs.PLAYBACK_FINEGRAINED_ACL_LIST) | 67 fine_grained_acl_list=gs.PLAYBACK_FINEGRAINED_ACL_LIST) |
| 67 # Tell rebaseline_server to prefetch latest SKP results. | 68 # Tell rebaseline_server to prefetch latest SKP results. |
| 68 prefetch_url = PREFETCH_URL_FORMATTER.format( | 69 prefetch_url = rebaseline_server_url( |
| 69 set_a_dir=urllib.quote('gs://%s/%s' % (dest_bucket, dest_dir), | 70 directive='prefetch/', builder_name=builder_name) |
| 70 safe=''), | |
| 71 set_b_dir=urllib.quote('repo:expectations/skp/%s' % dest_dir, | |
| 72 safe='')) | |
| 73 print ('Triggering prefetch URL %s' % prefetch_url) | 71 print ('Triggering prefetch URL %s' % prefetch_url) |
| 74 with contextlib.closing(urllib.urlopen(prefetch_url)): | 72 with contextlib.closing(urllib.urlopen(prefetch_url)): |
| 75 pass | 73 pass |
| 76 else: | 74 else: |
| 77 print ('Skipping upload to Google Storage, because no image summaries ' | 75 print ('Skipping upload to Google Storage, because no image summaries ' |
| 78 'in %s' % src_dir) | 76 'in %s' % src_dir) |
| 79 | 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 |
| 80 if '__main__' == __name__: | 94 if '__main__' == __name__: |
| 81 sys.exit(BuildStep.RunBuildStep(UploadRenderedSKPs)) | 95 sys.exit(BuildStep.RunBuildStep(UploadRenderedSKPs)) |
| OLD | NEW |