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

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

Issue 221423003: rebaseline_server: display as much info as possible if expected/actual image is missing (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove extra import Created 6 years, 8 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
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 """
(...skipping 29 matching lines...) Expand all
40 metadata (ignore-failure, bug numbers, etc.) 40 metadata (ignore-failure, bug numbers, etc.)
41 extra_columns: optional dictionary containing more metadata (test name, 41 extra_columns: optional dictionary containing more metadata (test name,
42 builder name, etc.) 42 builder name, etc.)
43 """ 43 """
44 self.base_url = base_url 44 self.base_url = base_url
45 self.imageA_relative_url = imageA_relative_url 45 self.imageA_relative_url = imageA_relative_url
46 self.imageB_relative_url = imageB_relative_url 46 self.imageB_relative_url = imageB_relative_url
47 self.expectations_dict = expectations 47 self.expectations_dict = expectations
48 self.extra_columns_dict = extra_columns 48 self.extra_columns_dict = extra_columns
49 if not imageA_relative_url or not imageB_relative_url: 49 if not imageA_relative_url or not imageB_relative_url:
50 self._is_different = True
50 self.diff_record = None 51 self.diff_record = None
51 elif imageA_relative_url == imageB_relative_url: 52 elif imageA_relative_url == imageB_relative_url:
53 self._is_different = False
52 self.diff_record = None 54 self.diff_record = None
53 else: 55 else:
54 # TODO(epoger): Rather than blocking until image_diff_db can read in 56 # TODO(epoger): Rather than blocking until image_diff_db can read in
55 # the image pair and generate diffs, it would be better to do it 57 # the image pair and generate diffs, it would be better to do it
56 # asynchronously: tell image_diff_db to download a bunch of file pairs, 58 # asynchronously: tell image_diff_db to download a bunch of file pairs,
57 # and only block later if we're still waiting for diff_records to come 59 # and only block later if we're still waiting for diff_records to come
58 # back. 60 # back.
61 self._is_different = True
59 image_diff_db.add_image_pair( 62 image_diff_db.add_image_pair(
60 expected_image_locator=imageA_relative_url, 63 expected_image_locator=imageA_relative_url,
61 expected_image_url=posixpath.join(base_url, imageA_relative_url), 64 expected_image_url=posixpath.join(base_url, imageA_relative_url),
62 actual_image_locator=imageB_relative_url, 65 actual_image_locator=imageB_relative_url,
63 actual_image_url=posixpath.join(base_url, imageB_relative_url)) 66 actual_image_url=posixpath.join(base_url, imageB_relative_url))
64 self.diff_record = image_diff_db.get_diff_record( 67 self.diff_record = image_diff_db.get_diff_record(
65 expected_image_locator=imageA_relative_url, 68 expected_image_locator=imageA_relative_url,
66 actual_image_locator=imageB_relative_url) 69 actual_image_locator=imageB_relative_url)
70 if self.diff_record and self.diff_record.get_num_pixels_differing() == 0:
71 self._is_different = False
67 72
68 def as_dict(self): 73 def as_dict(self):
69 """Returns a dictionary describing this ImagePair. 74 """Returns a dictionary describing this ImagePair.
70 75
71 Uses the KEY__* constants as keys. 76 Uses the KEY__* constants as keys.
72 """ 77 """
73 asdict = { 78 asdict = {
74 KEY__IMAGE_A_URL: self.imageA_relative_url, 79 KEY__IMAGE_A_URL: self.imageA_relative_url,
75 KEY__IMAGE_B_URL: self.imageB_relative_url, 80 KEY__IMAGE_B_URL: self.imageB_relative_url,
76 } 81 }
82 asdict[KEY__IS_DIFFERENT] = self._is_different
77 if self.expectations_dict: 83 if self.expectations_dict:
78 asdict[KEY__EXPECTATIONS_DATA] = self.expectations_dict 84 asdict[KEY__EXPECTATIONS_DATA] = self.expectations_dict
79 if self.extra_columns_dict: 85 if self.extra_columns_dict:
80 asdict[KEY__EXTRA_COLUMN_VALUES] = self.extra_columns_dict 86 asdict[KEY__EXTRA_COLUMN_VALUES] = self.extra_columns_dict
81 if self.diff_record and (self.diff_record.get_num_pixels_differing() > 0): 87 if self.diff_record and (self.diff_record.get_num_pixels_differing() > 0):
82 asdict[KEY__IS_DIFFERENT] = True
83 asdict[KEY__DIFFERENCE_DATA] = self.diff_record.as_dict() 88 asdict[KEY__DIFFERENCE_DATA] = self.diff_record.as_dict()
84 else:
85 asdict[KEY__IS_DIFFERENT] = False
86 return asdict 89 return asdict
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698