Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: gm/rebaseline_server/imagepair.py

Issue 178253010: rebaseline_server: use new intermediate JSON format (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: incorporate Ravi's suggestions Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gm/rebaseline_server/imagediffdb.py ('k') | gm/rebaseline_server/imagepair_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 ImagePair class (see class docstring for details) 9 ImagePair class (see class docstring for details)
10 """ 10 """
11 11
12 import posixpath 12 import posixpath
13 13
14 # Keys used within ImagePair dictionary representations. 14 # Keys used within ImagePair dictionary representations.
15 # NOTE: Keep these in sync with static/constants.js
15 KEY__DIFFERENCE_DATA = 'differenceData' 16 KEY__DIFFERENCE_DATA = 'differenceData'
16 KEY__EXPECTATIONS_DATA = 'expectations' 17 KEY__EXPECTATIONS_DATA = 'expectations'
17 KEY__EXTRA_COLUMN_VALUES = 'extraColumns' 18 KEY__EXTRA_COLUMN_VALUES = 'extraColumns'
18 KEY__IMAGE_A_URL = 'imageAUrl' 19 KEY__IMAGE_A_URL = 'imageAUrl'
19 KEY__IMAGE_B_URL = 'imageBUrl' 20 KEY__IMAGE_B_URL = 'imageBUrl'
20 KEY__IS_DIFFERENT = 'isDifferent' 21 KEY__IS_DIFFERENT = 'isDifferent'
21 22
22 23
23 class ImagePair(object): 24 class ImagePair(object):
24 """Describes a pair of images, pixel difference info, and optional metadata. 25 """Describes a pair of images, pixel difference info, and optional metadata.
25 """ 26 """
26 27
27 def __init__(self, image_diff_db, 28 def __init__(self, image_diff_db,
28 base_url, imageA_relative_url, imageB_relative_url, 29 base_url, imageA_relative_url, imageB_relative_url,
29 expectations=None, extra_columns=None): 30 expectations=None, extra_columns=None):
30 """ 31 """
31 Args: 32 Args:
32 image_diff_db: ImageDiffDB instance we use to generate/store image diffs 33 image_diff_db: ImageDiffDB instance we use to generate/store image diffs
33 base_url: base of all image URLs 34 base_url: base of all image URLs
34 imageA_relative_url: URL pointing at an image, relative to base_url 35 imageA_relative_url: string; URL pointing at an image, relative to
35 imageB_relative_url: URL pointing at an image, relative to base_url 36 base_url; or None, if this image is missing
37 imageB_relative_url: string; URL pointing at an image, relative to
38 base_url; or None, if this image is missing
36 expectations: optional dictionary containing expectations-specific 39 expectations: optional dictionary containing expectations-specific
37 metadata (ignore-failure, bug numbers, etc.) 40 metadata (ignore-failure, bug numbers, etc.)
38 extra_columns: optional dictionary containing more metadata (test name, 41 extra_columns: optional dictionary containing more metadata (test name,
39 builder name, etc.) 42 builder name, etc.)
40 """ 43 """
41 self.base_url = base_url 44 self.base_url = base_url
42 self.imageA_relative_url = imageA_relative_url 45 self.imageA_relative_url = imageA_relative_url
43 self.imageB_relative_url = imageB_relative_url 46 self.imageB_relative_url = imageB_relative_url
44 self.expectations_dict = expectations 47 self.expectations_dict = expectations
45 self.extra_columns_dict = extra_columns 48 self.extra_columns_dict = extra_columns
46 if imageA_relative_url == imageB_relative_url: 49 if not imageA_relative_url or not imageB_relative_url:
50 self.diff_record = None
51 elif imageA_relative_url == imageB_relative_url:
47 self.diff_record = None 52 self.diff_record = None
48 else: 53 else:
49 # TODO(epoger): Rather than blocking until image_diff_db can read in 54 # TODO(epoger): Rather than blocking until image_diff_db can read in
50 # the image pair and generate diffs, it would be better to do it 55 # the image pair and generate diffs, it would be better to do it
51 # asynchronously: tell image_diff_db to download a bunch of file pairs, 56 # asynchronously: tell image_diff_db to download a bunch of file pairs,
52 # and only block later if we're still waiting for diff_records to come 57 # and only block later if we're still waiting for diff_records to come
53 # back. 58 # back.
54 image_diff_db.add_image_pair( 59 image_diff_db.add_image_pair(
55 expected_image_locator=imageA_relative_url, 60 expected_image_locator=imageA_relative_url,
56 expected_image_url=posixpath.join(base_url, imageA_relative_url), 61 expected_image_url=posixpath.join(base_url, imageA_relative_url),
(...skipping 15 matching lines...) Expand all
72 if self.expectations_dict: 77 if self.expectations_dict:
73 asdict[KEY__EXPECTATIONS_DATA] = self.expectations_dict 78 asdict[KEY__EXPECTATIONS_DATA] = self.expectations_dict
74 if self.extra_columns_dict: 79 if self.extra_columns_dict:
75 asdict[KEY__EXTRA_COLUMN_VALUES] = self.extra_columns_dict 80 asdict[KEY__EXTRA_COLUMN_VALUES] = self.extra_columns_dict
76 if self.diff_record and (self.diff_record.get_num_pixels_differing() > 0): 81 if self.diff_record and (self.diff_record.get_num_pixels_differing() > 0):
77 asdict[KEY__IS_DIFFERENT] = True 82 asdict[KEY__IS_DIFFERENT] = True
78 asdict[KEY__DIFFERENCE_DATA] = self.diff_record.as_dict() 83 asdict[KEY__DIFFERENCE_DATA] = self.diff_record.as_dict()
79 else: 84 else:
80 asdict[KEY__IS_DIFFERENT] = False 85 asdict[KEY__IS_DIFFERENT] = False
81 return asdict 86 return asdict
OLDNEW
« no previous file with comments | « gm/rebaseline_server/imagediffdb.py ('k') | gm/rebaseline_server/imagepair_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698