OLD | NEW |
---|---|
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 """ |
11 | 11 |
12 # System-level imports | 12 # System-level imports |
13 import argparse | 13 import argparse |
14 import fnmatch | 14 import fnmatch |
15 import json | |
16 import logging | 15 import logging |
17 import os | 16 import os |
18 import re | |
19 import sys | |
20 import time | 17 import time |
21 | 18 |
19 # Must fix up PYTHONPATH before importing from within Skia | |
20 # pylint: disable=W0611 | |
21 import fix_pythonpath | |
22 # pylint: enable=W0611 | |
23 | |
22 # Imports from within Skia | 24 # Imports from within Skia |
23 import fix_pythonpath # must do this first | |
24 from pyutils import url_utils | 25 from pyutils import url_utils |
26 import column | |
25 import gm_json | 27 import gm_json |
26 import imagediffdb | 28 import imagediffdb |
27 import imagepair | 29 import imagepair |
28 import imagepairset | 30 import imagepairset |
29 import results | 31 import results |
30 | 32 |
31 EXPECTATION_FIELDS_PASSED_THRU_VERBATIM = [ | 33 EXPECTATION_FIELDS_PASSED_THRU_VERBATIM = [ |
32 results.KEY__EXPECTATIONS__BUGS, | 34 results.KEY__EXPECTATIONS__BUGS, |
33 results.KEY__EXPECTATIONS__IGNOREFAILURE, | 35 results.KEY__EXPECTATIONS__IGNOREFAILURE, |
34 results.KEY__EXPECTATIONS__REVIEWED, | 36 results.KEY__EXPECTATIONS__REVIEWED, |
35 ] | 37 ] |
38 FREEFORM_COLUMN_IDS = [results.KEY__EXTRACOLUMNS__BUILDER, | |
rmistry
2014/07/09 12:00:07
Nit: Create this list like the one above and below
epoger
2014/07/09 13:17:49
Done.
| |
39 results.KEY__EXTRACOLUMNS__TEST] | |
40 ORDERED_COLUMN_IDS = [ | |
41 results.KEY__EXTRACOLUMNS__RESULT_TYPE, | |
42 results.KEY__EXTRACOLUMNS__BUILDER, | |
43 results.KEY__EXTRACOLUMNS__TEST, | |
44 results.KEY__EXTRACOLUMNS__CONFIG, | |
45 ] | |
46 | |
36 TRUNK_DIRECTORY = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) | 47 TRUNK_DIRECTORY = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) |
37 DEFAULT_EXPECTATIONS_DIR = os.path.join(TRUNK_DIRECTORY, 'expectations', 'gm') | 48 DEFAULT_EXPECTATIONS_DIR = os.path.join(TRUNK_DIRECTORY, 'expectations', 'gm') |
38 DEFAULT_IGNORE_FAILURES_FILE = 'ignored-tests.txt' | 49 DEFAULT_IGNORE_FAILURES_FILE = 'ignored-tests.txt' |
39 | 50 |
40 IMAGEPAIR_SET_DESCRIPTIONS = ('expected image', 'actual image') | 51 IMAGEPAIR_SET_DESCRIPTIONS = ('expected image', 'actual image') |
41 | 52 |
42 | 53 |
43 class ExpectationComparisons(results.BaseComparisons): | 54 class ExpectationComparisons(results.BaseComparisons): |
44 """Loads actual and expected GM results into an ImagePairSet. | 55 """Loads actual and expected GM results into an ImagePairSet. |
45 | 56 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 pattern: which files to write within root (fnmatch-style pattern) | 175 pattern: which files to write within root (fnmatch-style pattern) |
165 | 176 |
166 Raises: | 177 Raises: |
167 IOError if root does not refer to an existing directory | 178 IOError if root does not refer to an existing directory |
168 KeyError if the set of per-builder dictionaries written out was | 179 KeyError if the set of per-builder dictionaries written out was |
169 different than expected | 180 different than expected |
170 """ | 181 """ |
171 if not os.path.isdir(root): | 182 if not os.path.isdir(root): |
172 raise IOError('no directory found at path %s' % root) | 183 raise IOError('no directory found at path %s' % root) |
173 actual_builders_written = [] | 184 actual_builders_written = [] |
174 for dirpath, dirnames, filenames in os.walk(root): | 185 for dirpath, _, filenames in os.walk(root): |
175 for matching_filename in fnmatch.filter(filenames, pattern): | 186 for matching_filename in fnmatch.filter(filenames, pattern): |
176 builder = os.path.basename(dirpath) | 187 builder = os.path.basename(dirpath) |
177 per_builder_dict = meta_dict.get(builder) | 188 per_builder_dict = meta_dict.get(builder) |
178 if per_builder_dict is not None: | 189 if per_builder_dict is not None: |
179 fullpath = os.path.join(dirpath, matching_filename) | 190 fullpath = os.path.join(dirpath, matching_filename) |
180 gm_json.WriteToFile(per_builder_dict, fullpath) | 191 gm_json.WriteToFile(per_builder_dict, fullpath) |
181 actual_builders_written.append(builder) | 192 actual_builders_written.append(builder) |
182 | 193 |
183 # Check: did we write out the set of per-builder dictionaries we | 194 # Check: did we write out the set of per-builder dictionaries we |
184 # expected to? | 195 # expected to? |
(...skipping 19 matching lines...) Expand all Loading... | |
204 expected_builder_dicts = self._read_builder_dicts_from_root( | 215 expected_builder_dicts = self._read_builder_dicts_from_root( |
205 self._expected_root) | 216 self._expected_root) |
206 | 217 |
207 all_image_pairs = imagepairset.ImagePairSet( | 218 all_image_pairs = imagepairset.ImagePairSet( |
208 descriptions=IMAGEPAIR_SET_DESCRIPTIONS, | 219 descriptions=IMAGEPAIR_SET_DESCRIPTIONS, |
209 diff_base_url=self._diff_base_url) | 220 diff_base_url=self._diff_base_url) |
210 failing_image_pairs = imagepairset.ImagePairSet( | 221 failing_image_pairs = imagepairset.ImagePairSet( |
211 descriptions=IMAGEPAIR_SET_DESCRIPTIONS, | 222 descriptions=IMAGEPAIR_SET_DESCRIPTIONS, |
212 diff_base_url=self._diff_base_url) | 223 diff_base_url=self._diff_base_url) |
213 | 224 |
225 # Override settings for columns that should be filtered using freeform text. | |
226 for column_id in FREEFORM_COLUMN_IDS: | |
227 factory = column.ColumnHeaderFactory( | |
228 header_text=column_id, use_freeform_filter=True) | |
229 all_image_pairs.set_column_header_factory( | |
230 column_id=column_id, column_header_factory=factory) | |
231 failing_image_pairs.set_column_header_factory( | |
232 column_id=column_id, column_header_factory=factory) | |
233 | |
214 all_image_pairs.ensure_extra_column_values_in_summary( | 234 all_image_pairs.ensure_extra_column_values_in_summary( |
215 column_id=results.KEY__EXTRACOLUMNS__RESULT_TYPE, values=[ | 235 column_id=results.KEY__EXTRACOLUMNS__RESULT_TYPE, values=[ |
216 results.KEY__RESULT_TYPE__FAILED, | 236 results.KEY__RESULT_TYPE__FAILED, |
217 results.KEY__RESULT_TYPE__FAILUREIGNORED, | 237 results.KEY__RESULT_TYPE__FAILUREIGNORED, |
218 results.KEY__RESULT_TYPE__NOCOMPARISON, | 238 results.KEY__RESULT_TYPE__NOCOMPARISON, |
219 results.KEY__RESULT_TYPE__SUCCEEDED, | 239 results.KEY__RESULT_TYPE__SUCCEEDED, |
220 ]) | 240 ]) |
221 failing_image_pairs.ensure_extra_column_values_in_summary( | 241 failing_image_pairs.ensure_extra_column_values_in_summary( |
222 column_id=results.KEY__EXTRACOLUMNS__RESULT_TYPE, values=[ | 242 column_id=results.KEY__EXTRACOLUMNS__RESULT_TYPE, values=[ |
223 results.KEY__RESULT_TYPE__FAILED, | 243 results.KEY__RESULT_TYPE__FAILED, |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
332 imageA_relative_url=expected_image_relative_url, | 352 imageA_relative_url=expected_image_relative_url, |
333 imageB_relative_url=actual_image_relative_url, | 353 imageB_relative_url=actual_image_relative_url, |
334 expectations=expectations_dict, | 354 expectations=expectations_dict, |
335 extra_columns=extra_columns_dict) | 355 extra_columns=extra_columns_dict) |
336 all_image_pairs.add_image_pair(image_pair) | 356 all_image_pairs.add_image_pair(image_pair) |
337 if updated_result_type != results.KEY__RESULT_TYPE__SUCCEEDED: | 357 if updated_result_type != results.KEY__RESULT_TYPE__SUCCEEDED: |
338 failing_image_pairs.add_image_pair(image_pair) | 358 failing_image_pairs.add_image_pair(image_pair) |
339 except Exception: | 359 except Exception: |
340 logging.exception('got exception while creating new ImagePair') | 360 logging.exception('got exception while creating new ImagePair') |
341 | 361 |
362 # pylint: disable=W0201 | |
342 self._results = { | 363 self._results = { |
343 results.KEY__HEADER__RESULTS_ALL: all_image_pairs.as_dict(), | 364 results.KEY__HEADER__RESULTS_ALL: all_image_pairs.as_dict( |
344 results.KEY__HEADER__RESULTS_FAILURES: failing_image_pairs.as_dict(), | 365 column_ids_in_order = ORDERED_COLUMN_IDS), |
rmistry
2014/07/09 12:00:07
I am surprised pylint did not complain about the e
epoger
2014/07/09 13:17:49
I think pylint was waiting to see what you would s
| |
366 results.KEY__HEADER__RESULTS_FAILURES: failing_image_pairs.as_dict( | |
367 column_ids_in_order = ORDERED_COLUMN_IDS), | |
345 } | 368 } |
346 | 369 |
347 | 370 |
348 def main(): | 371 def main(): |
349 logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', | 372 logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', |
350 datefmt='%m/%d/%Y %H:%M:%S', | 373 datefmt='%m/%d/%Y %H:%M:%S', |
351 level=logging.INFO) | 374 level=logging.INFO) |
352 parser = argparse.ArgumentParser() | 375 parser = argparse.ArgumentParser() |
353 parser.add_argument( | 376 parser.add_argument( |
354 '--actuals', default=results.DEFAULT_ACTUALS_DIR, | 377 '--actuals', default=results.DEFAULT_ACTUALS_DIR, |
(...skipping 27 matching lines...) Expand all Loading... | |
382 expected_root=args.expectations, | 405 expected_root=args.expectations, |
383 ignore_failures_file=args.ignore_failures_file, | 406 ignore_failures_file=args.ignore_failures_file, |
384 generated_images_root=args.workdir) | 407 generated_images_root=args.workdir) |
385 gm_json.WriteToFile( | 408 gm_json.WriteToFile( |
386 results_obj.get_packaged_results_of_type(results_type=args.results), | 409 results_obj.get_packaged_results_of_type(results_type=args.results), |
387 args.outfile) | 410 args.outfile) |
388 | 411 |
389 | 412 |
390 if __name__ == '__main__': | 413 if __name__ == '__main__': |
391 main() | 414 main() |
OLD | NEW |