aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/rebaseline_server/imagepair.py
diff options
context:
space:
mode:
authorGravatar epoger <epoger@google.com>2014-08-06 10:56:50 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-08-06 10:56:51 -0700
commit3facc7c87d9f81c352c9d37b1b46340b9e745578 (patch)
treed178c42e98eff678b46c663bfbd18003e19f81f9 /gm/rebaseline_server/imagepair.py
parent3b4d077fba1ad037536db198608a940c47d91888 (diff)
rebaseline_server: add "prefetch" directive that just warms the cache without awaiting results
This will allow the buildbots to warn the production rebaseline_server: "I just generated some new results; here's a comparison that a human might ask for soon. Download whatever images and generate whatever diffs you would need to provide those results." BUG=skia:1942 NOTREECHECKS=true NOTRY=true R=rmistry@google.com Author: epoger@google.com Review URL: https://codereview.chromium.org/443013002
Diffstat (limited to 'gm/rebaseline_server/imagepair.py')
-rw-r--r--gm/rebaseline_server/imagepair.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/gm/rebaseline_server/imagepair.py b/gm/rebaseline_server/imagepair.py
index 12d6718857..d9c4cb82b9 100644
--- a/gm/rebaseline_server/imagepair.py
+++ b/gm/rebaseline_server/imagepair.py
@@ -32,7 +32,8 @@ class ImagePair(object):
def __init__(self, image_diff_db,
base_url, imageA_relative_url, imageB_relative_url,
- expectations=None, extra_columns=None):
+ expectations=None, extra_columns=None,
+ download_all_images=False):
"""
Args:
image_diff_db: ImageDiffDB instance we use to generate/store image diffs
@@ -45,6 +46,9 @@ class ImagePair(object):
metadata (ignore-failure, bug numbers, etc.)
extra_columns: optional dictionary containing more metadata (test name,
builder name, etc.)
+ download_all_images: if True, download any images associated with this
+ image pair, even if we don't need them to generate diffs
+ (imageA == imageB, or one of them is missing)
"""
self._image_diff_db = image_diff_db
self.base_url = base_url
@@ -63,11 +67,13 @@ class ImagePair(object):
# Later on, we will call image_diff_db.get_diff_record() to find it.
self._is_different = True
self._diff_record = _DIFF_RECORD_STILL_LOADING
+
+ if self._diff_record != None or download_all_images:
image_diff_db.add_image_pair(
expected_image_locator=imageA_relative_url,
- expected_image_url=posixpath.join(base_url, imageA_relative_url),
+ expected_image_url=self.posixpath_join(base_url, imageA_relative_url),
actual_image_locator=imageB_relative_url,
- actual_image_url=posixpath.join(base_url, imageB_relative_url))
+ actual_image_url=self.posixpath_join(base_url, imageB_relative_url))
def as_dict(self):
"""Returns a dictionary describing this ImagePair.
@@ -97,3 +103,14 @@ class ImagePair(object):
if self._diff_record != None:
asdict[KEY__IMAGEPAIRS__DIFFERENCES] = self._diff_record.as_dict()
return asdict
+
+ @staticmethod
+ def posixpath_join(*args):
+ """Wrapper around posixpath.join().
+
+ Returns posixpath.join(*args), or None if any arg is None.
+ """
+ for arg in args:
+ if arg == None:
+ return None
+ return posixpath.join(*args)