| 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 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 FREEFORM_COLUMN_IDS = [ | 48 FREEFORM_COLUMN_IDS = [ |
| 49 COLUMN__TILENUM, | 49 COLUMN__TILENUM, |
| 50 ] | 50 ] |
| 51 ORDERED_COLUMN_IDS = [ | 51 ORDERED_COLUMN_IDS = [ |
| 52 COLUMN__RESULT_TYPE, | 52 COLUMN__RESULT_TYPE, |
| 53 COLUMN__SOURCE_SKP, | 53 COLUMN__SOURCE_SKP, |
| 54 COLUMN__TILED_OR_WHOLE, | 54 COLUMN__TILED_OR_WHOLE, |
| 55 COLUMN__TILENUM, | 55 COLUMN__TILENUM, |
| 56 ] | 56 ] |
| 57 | 57 |
| 58 # A special "repo:" URL type that we use to refer to Skia repo contents. |
| 59 # (Useful for comparing against expectations files we store in our repo.) |
| 60 REPO_URL_PREFIX = 'repo:' |
| 61 REPO_BASEPATH = os.path.abspath(os.path.join( |
| 62 os.path.dirname(os.path.abspath(__file__)), os.pardir, os.pardir)) |
| 63 |
| 58 | 64 |
| 59 class RenderedPicturesComparisons(results.BaseComparisons): | 65 class RenderedPicturesComparisons(results.BaseComparisons): |
| 60 """Loads results from multiple render_pictures runs into an ImagePairSet. | 66 """Loads results from multiple render_pictures runs into an ImagePairSet. |
| 61 """ | 67 """ |
| 62 | 68 |
| 63 def __init__(self, setA_dirs, setB_dirs, image_diff_db, | 69 def __init__(self, setA_dirs, setB_dirs, image_diff_db, |
| 64 image_base_gs_url=DEFAULT_IMAGE_BASE_GS_URL, | 70 image_base_gs_url=DEFAULT_IMAGE_BASE_GS_URL, |
| 65 diff_base_url=None, setA_label='setA', | 71 diff_base_url=None, setA_label='setA', |
| 66 setB_label='setB', gs=None, | 72 setB_label='setB', gs=None, |
| 67 truncate_results=False): | 73 truncate_results=False): |
| 68 """ | 74 """ |
| 69 Args: | 75 Args: |
| 70 setA_dirs: list of root directories to copy all JSON summaries from, | 76 setA_dirs: list of root directories to copy all JSON summaries from, |
| 71 and to use as setA within the comparisons | 77 and to use as setA within the comparisons. These directories may be |
| 78 gs:// URLs, special "repo:" URLs, or local filepaths. |
| 72 setB_dirs: list of root directories to copy all JSON summaries from, | 79 setB_dirs: list of root directories to copy all JSON summaries from, |
| 73 and to use as setB within the comparisons | 80 and to use as setB within the comparisons. These directories may be |
| 81 gs:// URLs, special "repo:" URLs, or local filepaths. |
| 74 image_diff_db: ImageDiffDB instance | 82 image_diff_db: ImageDiffDB instance |
| 75 image_base_gs_url: "gs://" URL pointing at the Google Storage bucket/dir | 83 image_base_gs_url: "gs://" URL pointing at the Google Storage bucket/dir |
| 76 under which all render_pictures result images can | 84 under which all render_pictures result images can |
| 77 be found; this will be used to read images for comparison within | 85 be found; this will be used to read images for comparison within |
| 78 this code, and included in the ImagePairSet (as an HTTP URL) so its | 86 this code, and included in the ImagePairSet (as an HTTP URL) so its |
| 79 consumers know where to download the images from | 87 consumers know where to download the images from |
| 80 diff_base_url: base URL within which the client should look for diff | 88 diff_base_url: base URL within which the client should look for diff |
| 81 images; if not specified, defaults to a "file:///" URL representation | 89 images; if not specified, defaults to a "file:///" URL representation |
| 82 of image_diff_db's storage_root | 90 of image_diff_db's storage_root |
| 83 setA_label: description to use for results in setA | 91 setA_label: description to use for results in setA |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 'got exception while creating ImagePair for' | 326 'got exception while creating ImagePair for' |
| 319 ' urlPair=("%s","%s"), source_skp_name="%s", tilenum="%s"' % ( | 327 ' urlPair=("%s","%s"), source_skp_name="%s", tilenum="%s"' % ( |
| 320 imageA_relative_url, imageB_relative_url, source_skp_name, | 328 imageA_relative_url, imageB_relative_url, source_skp_name, |
| 321 tilenum)) | 329 tilenum)) |
| 322 return None | 330 return None |
| 323 | 331 |
| 324 def _copy_dir_contents(self, source_dir, dest_dir): | 332 def _copy_dir_contents(self, source_dir, dest_dir): |
| 325 """Copy all contents of source_dir into dest_dir, recursing into subdirs. | 333 """Copy all contents of source_dir into dest_dir, recursing into subdirs. |
| 326 | 334 |
| 327 Args: | 335 Args: |
| 328 source_dir: path to source dir (GS URL or local filepath) | 336 source_dir: path to source dir (GS URL, local filepath, or a special |
| 337 "repo:" URL type that points at a file within our Skia checkout) |
| 329 dest_dir: path to destination dir (local filepath) | 338 dest_dir: path to destination dir (local filepath) |
| 330 | 339 |
| 331 The copy operates as a "merge with overwrite": any files in source_dir will | 340 The copy operates as a "merge with overwrite": any files in source_dir will |
| 332 be "overlaid" on top of the existing content in dest_dir. Existing files | 341 be "overlaid" on top of the existing content in dest_dir. Existing files |
| 333 with the same names will be overwritten. | 342 with the same names will be overwritten. |
| 334 """ | 343 """ |
| 335 if gs_utils.GSUtils.is_gs_url(source_dir): | 344 if gs_utils.GSUtils.is_gs_url(source_dir): |
| 336 (bucket, path) = gs_utils.GSUtils.split_gs_url(source_dir) | 345 (bucket, path) = gs_utils.GSUtils.split_gs_url(source_dir) |
| 337 self._gs.download_dir_contents(source_bucket=bucket, source_dir=path, | 346 self._gs.download_dir_contents(source_bucket=bucket, source_dir=path, |
| 338 dest_dir=dest_dir) | 347 dest_dir=dest_dir) |
| 348 elif source_dir.lower().startswith(REPO_URL_PREFIX): |
| 349 repo_dir = os.path.join(REPO_BASEPATH, source_dir[len(REPO_URL_PREFIX):]) |
| 350 shutil.copytree(repo_dir, dest_dir) |
| 339 else: | 351 else: |
| 340 shutil.copytree(source_dir, dest_dir) | 352 shutil.copytree(source_dir, dest_dir) |
| OLD | NEW |