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

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

Issue 235923002: rebaseline_server: multithreaded loading/diffing of images (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 ImagePairSet class; see its docstring below. 9 ImagePairSet class; see its docstring below.
10 """ 10 """
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 """ 43 """
44 Args: 44 Args:
45 diff_base_url: base URL indicating where diff images can be loaded from 45 diff_base_url: base URL indicating where diff images can be loaded from
46 descriptions: a (string, string) tuple describing the two image sets. 46 descriptions: a (string, string) tuple describing the two image sets.
47 If not specified, DEFAULT_DESCRIPTIONS will be used. 47 If not specified, DEFAULT_DESCRIPTIONS will be used.
48 """ 48 """
49 self._column_header_factories = {} 49 self._column_header_factories = {}
50 self._descriptions = descriptions or DEFAULT_DESCRIPTIONS 50 self._descriptions = descriptions or DEFAULT_DESCRIPTIONS
51 self._extra_column_tallies = {} # maps column_id -> values 51 self._extra_column_tallies = {} # maps column_id -> values
52 # -> instances_per_value 52 # -> instances_per_value
53 self._image_pair_dicts = [] 53 self._image_pairs = []
54 self._image_base_url = None 54 self._image_base_url = None
55 self._diff_base_url = diff_base_url 55 self._diff_base_url = diff_base_url
56 56
57 def add_image_pair(self, image_pair): 57 def add_image_pair(self, image_pair):
58 """Adds an ImagePair; this may be repeated any number of times.""" 58 """Adds an ImagePair; this may be repeated any number of times."""
59 # Special handling when we add the first ImagePair... 59 # Special handling when we add the first ImagePair...
60 if not self._image_pair_dicts: 60 if not self._image_pairs:
61 self._image_base_url = image_pair.base_url 61 self._image_base_url = image_pair.base_url
62 62
63 if image_pair.base_url != self._image_base_url: 63 if image_pair.base_url != self._image_base_url:
64 raise Exception('added ImagePair with base_url "%s" instead of "%s"' % ( 64 raise Exception('added ImagePair with base_url "%s" instead of "%s"' % (
65 image_pair.base_url, self._image_base_url)) 65 image_pair.base_url, self._image_base_url))
66 self._image_pair_dicts.append(image_pair.as_dict()) 66 self._image_pairs.append(image_pair)
67 extra_columns_dict = image_pair.extra_columns_dict 67 extra_columns_dict = image_pair.extra_columns_dict
68 if extra_columns_dict: 68 if extra_columns_dict:
69 for column_id, value in extra_columns_dict.iteritems(): 69 for column_id, value in extra_columns_dict.iteritems():
70 self._add_extra_column_value_to_summary(column_id, value) 70 self._add_extra_column_value_to_summary(column_id, value)
71 71
72 def set_column_header_factory(self, column_id, column_header_factory): 72 def set_column_header_factory(self, column_id, column_header_factory):
73 """Overrides the default settings for one of the extraColumn headers. 73 """Overrides the default settings for one of the extraColumn headers.
74 74
75 Args: 75 Args:
76 column_id: string; unique ID of this column (must match a key within 76 column_id: string; unique ID of this column (must match a key within
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 def as_dict(self): 136 def as_dict(self):
137 """Returns a dictionary describing this package of ImagePairs. 137 """Returns a dictionary describing this package of ImagePairs.
138 138
139 Uses the KEY__* constants as keys. 139 Uses the KEY__* constants as keys.
140 """ 140 """
141 key_description = KEY__IMAGESETS__FIELD__DESCRIPTION 141 key_description = KEY__IMAGESETS__FIELD__DESCRIPTION
142 key_base_url = KEY__IMAGESETS__FIELD__BASE_URL 142 key_base_url = KEY__IMAGESETS__FIELD__BASE_URL
143 return { 143 return {
144 KEY__EXTRACOLUMNHEADERS: self._column_headers_as_dict(), 144 KEY__EXTRACOLUMNHEADERS: self._column_headers_as_dict(),
145 KEY__IMAGEPAIRS: self._image_pair_dicts, 145 KEY__IMAGEPAIRS: [pair.as_dict() for pair in self._image_pairs],
146 KEY__IMAGESETS: { 146 KEY__IMAGESETS: {
147 KEY__IMAGESETS__SET__IMAGE_A: { 147 KEY__IMAGESETS__SET__IMAGE_A: {
148 key_description: self._descriptions[0], 148 key_description: self._descriptions[0],
149 key_base_url: self._image_base_url, 149 key_base_url: self._image_base_url,
150 }, 150 },
151 KEY__IMAGESETS__SET__IMAGE_B: { 151 KEY__IMAGESETS__SET__IMAGE_B: {
152 key_description: self._descriptions[1], 152 key_description: self._descriptions[1],
153 key_base_url: self._image_base_url, 153 key_base_url: self._image_base_url,
154 }, 154 },
155 KEY__IMAGESETS__SET__DIFFS: { 155 KEY__IMAGESETS__SET__DIFFS: {
156 key_description: 'color difference per channel', 156 key_description: 'color difference per channel',
157 key_base_url: posixpath.join( 157 key_base_url: posixpath.join(
158 self._diff_base_url, 'diffs'), 158 self._diff_base_url, 'diffs'),
159 }, 159 },
160 KEY__IMAGESETS__SET__WHITEDIFFS: { 160 KEY__IMAGESETS__SET__WHITEDIFFS: {
161 key_description: 'differing pixels in white', 161 key_description: 'differing pixels in white',
162 key_base_url: posixpath.join( 162 key_base_url: posixpath.join(
163 self._diff_base_url, 'whitediffs'), 163 self._diff_base_url, 'whitediffs'),
164 }, 164 },
165 }, 165 },
166 } 166 }
OLDNEW
« gm/rebaseline_server/imagediffdb.py ('K') | « gm/rebaseline_server/imagepair.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698