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

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

Issue 232103002: rebaseline_server: allow user to specify which builders to process (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: expose to command line 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 2013 Google Inc. 4 Copyright 2013 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 Repackage expected/actual GM results as needed by our HTML rebaseline viewer. 9 Repackage expected/actual GM results as needed by our HTML rebaseline viewer.
10 """ 10 """
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 Loads actual and expected results from all builders, except for those skipped 58 Loads actual and expected results from all builders, except for those skipped
59 by _ignore_builder(). 59 by _ignore_builder().
60 60
61 Once this object has been constructed, the results (in self._results[]) 61 Once this object has been constructed, the results (in self._results[])
62 are immutable. If you want to update the results based on updated JSON 62 are immutable. If you want to update the results based on updated JSON
63 file contents, you will need to create a new ExpectationComparisons object.""" 63 file contents, you will need to create a new ExpectationComparisons object."""
64 64
65 def __init__(self, actuals_root=results.DEFAULT_ACTUALS_DIR, 65 def __init__(self, actuals_root=results.DEFAULT_ACTUALS_DIR,
66 expected_root=DEFAULT_EXPECTATIONS_DIR, 66 expected_root=DEFAULT_EXPECTATIONS_DIR,
67 generated_images_root=results.DEFAULT_GENERATED_IMAGES_ROOT, 67 generated_images_root=results.DEFAULT_GENERATED_IMAGES_ROOT,
68 diff_base_url=None): 68 diff_base_url=None, builder_regex_list=None):
69 """ 69 """
70 Args: 70 Args:
71 actuals_root: root directory containing all actual-results.json files 71 actuals_root: root directory containing all actual-results.json files
72 expected_root: root directory containing all expected-results.json files 72 expected_root: root directory containing all expected-results.json files
73 generated_images_root: directory within which to create all pixel diffs; 73 generated_images_root: directory within which to create all pixel diffs;
74 if this directory does not yet exist, it will be created 74 if this directory does not yet exist, it will be created
75 diff_base_url: base URL within which the client should look for diff 75 diff_base_url: base URL within which the client should look for diff
76 images; if not specified, defaults to a "file:///" URL representation 76 images; if not specified, defaults to a "file:///" URL representation
77 of generated_images_root 77 of generated_images_root
78 builder_regex_list: List of regular expressions specifying which builders
79 we will process. If None, process all builders.
78 """ 80 """
79 time_start = int(time.time()) 81 time_start = int(time.time())
82 if builder_regex_list != None:
83 self.set_match_builders_pattern_list(builder_regex_list)
80 self._image_diff_db = imagediffdb.ImageDiffDB(generated_images_root) 84 self._image_diff_db = imagediffdb.ImageDiffDB(generated_images_root)
81 self._diff_base_url = ( 85 self._diff_base_url = (
82 diff_base_url or 86 diff_base_url or
83 download_actuals.create_filepath_url(generated_images_root)) 87 download_actuals.create_filepath_url(generated_images_root))
84 self._actuals_root = actuals_root 88 self._actuals_root = actuals_root
85 self._expected_root = expected_root 89 self._expected_root = expected_root
86 self._load_actual_and_expected() 90 self._load_actual_and_expected()
87 self._timestamp = int(time.time()) 91 self._timestamp = int(time.time())
88 logging.info('Results complete; took %d seconds.' % 92 logging.info('Results complete; took %d seconds.' %
89 (self._timestamp - time_start)) 93 (self._timestamp - time_start))
(...skipping 20 matching lines...) Expand all
110 results.KEY__EXTRACOLUMN__BUILDER: 'Test-Mac10.6-MacMini4.1-GeFor ce320M-x86-Debug', 114 results.KEY__EXTRACOLUMN__BUILDER: 'Test-Mac10.6-MacMini4.1-GeFor ce320M-x86-Debug',
111 results.KEY__EXTRACOLUMN__CONFIG: '8888', 115 results.KEY__EXTRACOLUMN__CONFIG: '8888',
112 results.KEY__EXTRACOLUMN__TEST: 'bigmatrix', 116 results.KEY__EXTRACOLUMN__TEST: 'bigmatrix',
113 }, 117 },
114 results.KEY__NEW_IMAGE_URL: 'bitmap-64bitMD5/bigmatrix/108944080240 79689926.png', 118 results.KEY__NEW_IMAGE_URL: 'bitmap-64bitMD5/bigmatrix/108944080240 79689926.png',
115 }, 119 },
116 ... 120 ...
117 ] 121 ]
118 122
119 """ 123 """
120 expected_builder_dicts = ExpectationComparisons._read_dicts_from_root( 124 expected_builder_dicts = self._read_dicts_from_root(self._expected_root)
121 self._expected_root)
122 for mod in modifications: 125 for mod in modifications:
123 image_name = results.IMAGE_FILENAME_FORMATTER % ( 126 image_name = results.IMAGE_FILENAME_FORMATTER % (
124 mod[imagepair.KEY__EXTRA_COLUMN_VALUES] 127 mod[imagepair.KEY__EXTRA_COLUMN_VALUES]
125 [results.KEY__EXTRACOLUMN__TEST], 128 [results.KEY__EXTRACOLUMN__TEST],
126 mod[imagepair.KEY__EXTRA_COLUMN_VALUES] 129 mod[imagepair.KEY__EXTRA_COLUMN_VALUES]
127 [results.KEY__EXTRACOLUMN__CONFIG]) 130 [results.KEY__EXTRACOLUMN__CONFIG])
128 _, hash_type, hash_digest = gm_json.SplitGmRelativeUrl( 131 _, hash_type, hash_digest = gm_json.SplitGmRelativeUrl(
129 mod[results.KEY__NEW_IMAGE_URL]) 132 mod[results.KEY__NEW_IMAGE_URL])
130 allowed_digests = [[hash_type, int(hash_digest)]] 133 allowed_digests = [[hash_type, int(hash_digest)]]
131 new_expectations = { 134 new_expectations = {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 IOError if root does not refer to an existing directory 170 IOError if root does not refer to an existing directory
168 KeyError if the set of per-builder dictionaries written out was 171 KeyError if the set of per-builder dictionaries written out was
169 different than expected 172 different than expected
170 """ 173 """
171 if not os.path.isdir(root): 174 if not os.path.isdir(root):
172 raise IOError('no directory found at path %s' % root) 175 raise IOError('no directory found at path %s' % root)
173 actual_builders_written = [] 176 actual_builders_written = []
174 for dirpath, dirnames, filenames in os.walk(root): 177 for dirpath, dirnames, filenames in os.walk(root):
175 for matching_filename in fnmatch.filter(filenames, pattern): 178 for matching_filename in fnmatch.filter(filenames, pattern):
176 builder = os.path.basename(dirpath) 179 builder = os.path.basename(dirpath)
177 if ExpectationComparisons._ignore_builder(builder):
178 continue
179 per_builder_dict = meta_dict.get(builder) 180 per_builder_dict = meta_dict.get(builder)
180 if per_builder_dict is not None: 181 if per_builder_dict is not None:
181 fullpath = os.path.join(dirpath, matching_filename) 182 fullpath = os.path.join(dirpath, matching_filename)
182 gm_json.WriteToFile(per_builder_dict, fullpath) 183 gm_json.WriteToFile(per_builder_dict, fullpath)
183 actual_builders_written.append(builder) 184 actual_builders_written.append(builder)
184 185
185 # Check: did we write out the set of per-builder dictionaries we 186 # Check: did we write out the set of per-builder dictionaries we
186 # expected to? 187 # expected to?
187 expected_builders_written = sorted(meta_dict.keys()) 188 expected_builders_written = sorted(meta_dict.keys())
188 actual_builders_written.sort() 189 actual_builders_written.sort()
189 if expected_builders_written != actual_builders_written: 190 if expected_builders_written != actual_builders_written:
190 raise KeyError( 191 raise KeyError(
191 'expected to write dicts for builders %s, but actually wrote them ' 192 'expected to write dicts for builders %s, but actually wrote them '
192 'for builders %s' % ( 193 'for builders %s' % (
193 expected_builders_written, actual_builders_written)) 194 expected_builders_written, actual_builders_written))
194 195
195 def _load_actual_and_expected(self): 196 def _load_actual_and_expected(self):
196 """Loads the results of all tests, across all builders (based on the 197 """Loads the results of all tests, across all builders (based on the
197 files within self._actuals_root and self._expected_root), 198 files within self._actuals_root and self._expected_root),
198 and stores them in self._results. 199 and stores them in self._results.
199 """ 200 """
200 logging.info('Reading actual-results JSON files from %s...' % 201 logging.info('Reading actual-results JSON files from %s...' %
201 self._actuals_root) 202 self._actuals_root)
202 actual_builder_dicts = ExpectationComparisons._read_dicts_from_root( 203 actual_builder_dicts = self._read_dicts_from_root(self._actuals_root)
203 self._actuals_root)
204 logging.info('Reading expected-results JSON files from %s...' % 204 logging.info('Reading expected-results JSON files from %s...' %
205 self._expected_root) 205 self._expected_root)
206 expected_builder_dicts = ExpectationComparisons._read_dicts_from_root( 206 expected_builder_dicts = self._read_dicts_from_root(self._expected_root)
207 self._expected_root)
208 207
209 all_image_pairs = imagepairset.ImagePairSet( 208 all_image_pairs = imagepairset.ImagePairSet(
210 descriptions=IMAGEPAIR_SET_DESCRIPTIONS, 209 descriptions=IMAGEPAIR_SET_DESCRIPTIONS,
211 diff_base_url=self._diff_base_url) 210 diff_base_url=self._diff_base_url)
212 failing_image_pairs = imagepairset.ImagePairSet( 211 failing_image_pairs = imagepairset.ImagePairSet(
213 descriptions=IMAGEPAIR_SET_DESCRIPTIONS, 212 descriptions=IMAGEPAIR_SET_DESCRIPTIONS,
214 diff_base_url=self._diff_base_url) 213 diff_base_url=self._diff_base_url)
215 214
216 all_image_pairs.ensure_extra_column_values_in_summary( 215 all_image_pairs.ensure_extra_column_values_in_summary(
217 column_id=results.KEY__EXTRACOLUMN__RESULT_TYPE, values=[ 216 column_id=results.KEY__EXTRACOLUMN__RESULT_TYPE, values=[
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 results_obj = ExpectationComparisons(actuals_root=args.actuals, 366 results_obj = ExpectationComparisons(actuals_root=args.actuals,
368 expected_root=args.expectations, 367 expected_root=args.expectations,
369 generated_images_root=args.workdir) 368 generated_images_root=args.workdir)
370 gm_json.WriteToFile( 369 gm_json.WriteToFile(
371 results_obj.get_packaged_results_of_type(results_type=args.results), 370 results_obj.get_packaged_results_of_type(results_type=args.results),
372 args.outfile) 371 args.outfile)
373 372
374 373
375 if __name__ == '__main__': 374 if __name__ == '__main__':
376 main() 375 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698