OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 """ | 3 """ |
4 Copyright 2014 Google Inc. | 4 Copyright 2014 Google Inc. |
5 | 5 |
6 Use of this source code is governed by a BSD-style license that can be | 6 Use of this source code is governed by a BSD-style license that can be |
7 found in the LICENSE file. | 7 found in the LICENSE file. |
8 | 8 |
9 Compare results of two render_pictures runs. | 9 Compare results of two render_pictures runs. |
10 """ | 10 """ |
11 | 11 |
12 # System-level imports | 12 # System-level imports |
13 import logging | 13 import logging |
14 import os | 14 import os |
15 import re | 15 import re |
16 import sys | 16 import sys |
17 import time | 17 import time |
18 | 18 |
19 # Imports from within Skia | 19 # Imports from within Skia |
20 # | 20 # |
21 # TODO(epoger): Once we move the create_filepath_url() function out of | |
22 # download_actuals into a shared utility module, we won't need to import | |
23 # download_actuals anymore. | |
24 # | |
25 # We need to add the 'gm' directory, so that we can import gm_json.py within | 21 # We need to add the 'gm' directory, so that we can import gm_json.py within |
26 # that directory. That script allows us to parse the actual-results.json file | 22 # that directory. That script allows us to parse the actual-results.json file |
27 # written out by the GM tool. | 23 # written out by the GM tool. |
28 # Make sure that the 'gm' dir is in the PYTHONPATH, but add it at the *end* | 24 # Make sure that the 'gm' dir is in the PYTHONPATH, but add it at the *end* |
29 # so any dirs that are already in the PYTHONPATH will be preferred. | 25 # so any dirs that are already in the PYTHONPATH will be preferred. |
30 PARENT_DIRECTORY = os.path.dirname(os.path.realpath(__file__)) | 26 PARENT_DIRECTORY = os.path.dirname(os.path.realpath(__file__)) |
31 GM_DIRECTORY = os.path.dirname(PARENT_DIRECTORY) | 27 GM_DIRECTORY = os.path.dirname(PARENT_DIRECTORY) |
32 TRUNK_DIRECTORY = os.path.dirname(GM_DIRECTORY) | 28 TRUNK_DIRECTORY = os.path.dirname(GM_DIRECTORY) |
33 if GM_DIRECTORY not in sys.path: | 29 if GM_DIRECTORY not in sys.path: |
34 sys.path.append(GM_DIRECTORY) | 30 sys.path.append(GM_DIRECTORY) |
35 import download_actuals | |
36 import gm_json | 31 import gm_json |
37 import imagediffdb | 32 import imagediffdb |
38 import imagepair | 33 import imagepair |
39 import imagepairset | 34 import imagepairset |
40 import results | 35 import results |
| 36 import url_utils |
41 | 37 |
42 # URL under which all render_pictures images can be found in Google Storage. | 38 # URL under which all render_pictures images can be found in Google Storage. |
43 # TODO(epoger): Move this default value into | 39 # TODO(epoger): Move this default value into |
44 # https://skia.googlesource.com/buildbot/+/master/site_config/global_variables.j
son | 40 # https://skia.googlesource.com/buildbot/+/master/site_config/global_variables.j
son |
45 DEFAULT_IMAGE_BASE_URL = 'http://chromium-skia-gm.commondatastorage.googleapis.c
om/render_pictures/images' | 41 DEFAULT_IMAGE_BASE_URL = 'http://chromium-skia-gm.commondatastorage.googleapis.c
om/render_pictures/images' |
46 | 42 |
47 | 43 |
48 class RenderedPicturesComparisons(results.BaseComparisons): | 44 class RenderedPicturesComparisons(results.BaseComparisons): |
49 """Loads results from two different render_pictures runs into an ImagePairSet. | 45 """Loads results from two different render_pictures runs into an ImagePairSet. |
50 """ | 46 """ |
(...skipping 16 matching lines...) Expand all Loading... |
67 where to download the images from | 63 where to download the images from |
68 diff_base_url: base URL within which the client should look for diff | 64 diff_base_url: base URL within which the client should look for diff |
69 images; if not specified, defaults to a "file:///" URL representation | 65 images; if not specified, defaults to a "file:///" URL representation |
70 of generated_images_root | 66 of generated_images_root |
71 """ | 67 """ |
72 time_start = int(time.time()) | 68 time_start = int(time.time()) |
73 self._image_diff_db = imagediffdb.ImageDiffDB(generated_images_root) | 69 self._image_diff_db = imagediffdb.ImageDiffDB(generated_images_root) |
74 self._image_base_url = image_base_url | 70 self._image_base_url = image_base_url |
75 self._diff_base_url = ( | 71 self._diff_base_url = ( |
76 diff_base_url or | 72 diff_base_url or |
77 download_actuals.create_filepath_url(generated_images_root)) | 73 url_utils.create_filepath_url(generated_images_root)) |
78 self._load_result_pairs(actuals_root, subdirs) | 74 self._load_result_pairs(actuals_root, subdirs) |
79 self._timestamp = int(time.time()) | 75 self._timestamp = int(time.time()) |
80 logging.info('Results complete; took %d seconds.' % | 76 logging.info('Results complete; took %d seconds.' % |
81 (self._timestamp - time_start)) | 77 (self._timestamp - time_start)) |
82 | 78 |
83 def _load_result_pairs(self, actuals_root, subdirs): | 79 def _load_result_pairs(self, actuals_root, subdirs): |
84 """Loads all JSON files found within two subdirs in actuals_root, | 80 """Loads all JSON files found within two subdirs in actuals_root, |
85 compares across those two subdirs, and stores the summary in self._results. | 81 compares across those two subdirs, and stores the summary in self._results. |
86 | 82 |
87 Args: | 83 Args: |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 extra_columns=extra_columns_dict) | 245 extra_columns=extra_columns_dict) |
250 except (KeyError, TypeError): | 246 except (KeyError, TypeError): |
251 logging.exception( | 247 logging.exception( |
252 'got exception while creating ImagePair for' | 248 'got exception while creating ImagePair for' |
253 ' test="%s", config="%s", urlPair=("%s","%s")' % ( | 249 ' test="%s", config="%s", urlPair=("%s","%s")' % ( |
254 test, config, imageA_relative_url, imageB_relative_url)) | 250 test, config, imageA_relative_url, imageB_relative_url)) |
255 return None | 251 return None |
256 | 252 |
257 | 253 |
258 # TODO(epoger): Add main() so this can be called by vm_run_skia_try.sh | 254 # TODO(epoger): Add main() so this can be called by vm_run_skia_try.sh |
OLD | NEW |