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

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

Issue 379563005: rebaseline_server: cache results in long-running ImageDiffDB instance (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Ravi comment Created 6 years, 5 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 | « no previous file | gm/rebaseline_server/compare_to_expectations_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 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 class ExpectationComparisons(results.BaseComparisons): 56 class ExpectationComparisons(results.BaseComparisons):
57 """Loads actual and expected GM results into an ImagePairSet. 57 """Loads actual and expected GM results into an ImagePairSet.
58 58
59 Loads actual and expected results from all builders, except for those skipped 59 Loads actual and expected results from all builders, except for those skipped
60 by _ignore_builder(). 60 by _ignore_builder().
61 61
62 Once this object has been constructed, the results (in self._results[]) 62 Once this object has been constructed, the results (in self._results[])
63 are immutable. If you want to update the results based on updated JSON 63 are immutable. If you want to update the results based on updated JSON
64 file contents, you will need to create a new ExpectationComparisons object.""" 64 file contents, you will need to create a new ExpectationComparisons object."""
65 65
66 def __init__(self, actuals_root=results.DEFAULT_ACTUALS_DIR, 66 def __init__(self, image_diff_db, actuals_root=results.DEFAULT_ACTUALS_DIR,
67 expected_root=DEFAULT_EXPECTATIONS_DIR, 67 expected_root=DEFAULT_EXPECTATIONS_DIR,
68 ignore_failures_file=DEFAULT_IGNORE_FAILURES_FILE, 68 ignore_failures_file=DEFAULT_IGNORE_FAILURES_FILE,
69 generated_images_root=results.DEFAULT_GENERATED_IMAGES_ROOT,
70 diff_base_url=None, builder_regex_list=None): 69 diff_base_url=None, builder_regex_list=None):
71 """ 70 """
72 Args: 71 Args:
72 image_diff_db: instance of ImageDiffDB we use to cache the image diffs
73 actuals_root: root directory containing all actual-results.json files 73 actuals_root: root directory containing all actual-results.json files
74 expected_root: root directory containing all expected-results.json files 74 expected_root: root directory containing all expected-results.json files
75 ignore_failures_file: if a file with this name is found within 75 ignore_failures_file: if a file with this name is found within
76 expected_root, ignore failures for any tests listed in the file 76 expected_root, ignore failures for any tests listed in the file
77 generated_images_root: directory within which to create all pixel diffs;
78 if this directory does not yet exist, it will be created
79 diff_base_url: base URL within which the client should look for diff 77 diff_base_url: base URL within which the client should look for diff
80 images; if not specified, defaults to a "file:///" URL representation 78 images; if not specified, defaults to a "file:///" URL representation
81 of generated_images_root 79 of image_diff_db's storage_root
82 builder_regex_list: List of regular expressions specifying which builders 80 builder_regex_list: List of regular expressions specifying which builders
83 we will process. If None, process all builders. 81 we will process. If None, process all builders.
84 """ 82 """
85 time_start = int(time.time()) 83 time_start = int(time.time())
86 if builder_regex_list != None: 84 if builder_regex_list != None:
87 self.set_match_builders_pattern_list(builder_regex_list) 85 self.set_match_builders_pattern_list(builder_regex_list)
88 self._image_diff_db = imagediffdb.ImageDiffDB(generated_images_root) 86 self._image_diff_db = image_diff_db
89 self._diff_base_url = ( 87 self._diff_base_url = (
90 diff_base_url or 88 diff_base_url or
91 url_utils.create_filepath_url(generated_images_root)) 89 url_utils.create_filepath_url(image_diff_db.storage_root))
92 self._actuals_root = actuals_root 90 self._actuals_root = actuals_root
93 self._expected_root = expected_root 91 self._expected_root = expected_root
94 self._ignore_failures_on_these_tests = [] 92 self._ignore_failures_on_these_tests = []
95 if ignore_failures_file: 93 if ignore_failures_file:
96 self._ignore_failures_on_these_tests = ( 94 self._ignore_failures_on_these_tests = (
97 ExpectationComparisons._read_noncomment_lines( 95 ExpectationComparisons._read_noncomment_lines(
98 os.path.join(expected_root, ignore_failures_file))) 96 os.path.join(expected_root, ignore_failures_file)))
99 self._load_actual_and_expected() 97 self._load_actual_and_expected()
100 self._timestamp = int(time.time()) 98 self._timestamp = int(time.time())
101 logging.info('Results complete; took %d seconds.' % 99 logging.info('Results complete; took %d seconds.' %
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 '--results', default=results.KEY__HEADER__RESULTS_FAILURES, 393 '--results', default=results.KEY__HEADER__RESULTS_FAILURES,
396 help='Which result types to include. Defaults to \'%(default)s\'; ' 394 help='Which result types to include. Defaults to \'%(default)s\'; '
397 'must be one of ' + 395 'must be one of ' +
398 str([results.KEY__HEADER__RESULTS_FAILURES, 396 str([results.KEY__HEADER__RESULTS_FAILURES,
399 results.KEY__HEADER__RESULTS_ALL])) 397 results.KEY__HEADER__RESULTS_ALL]))
400 parser.add_argument( 398 parser.add_argument(
401 '--workdir', default=results.DEFAULT_GENERATED_IMAGES_ROOT, 399 '--workdir', default=results.DEFAULT_GENERATED_IMAGES_ROOT,
402 help='Directory within which to download images and generate diffs; ' 400 help='Directory within which to download images and generate diffs; '
403 'defaults to \'%(default)s\' .') 401 'defaults to \'%(default)s\' .')
404 args = parser.parse_args() 402 args = parser.parse_args()
403 image_diff_db = imagediffdb.ImageDiffDB(storage_root=args.workdir)
405 results_obj = ExpectationComparisons( 404 results_obj = ExpectationComparisons(
405 image_diff_db=image_diff_db,
406 actuals_root=args.actuals, 406 actuals_root=args.actuals,
407 expected_root=args.expectations, 407 expected_root=args.expectations,
408 ignore_failures_file=args.ignore_failures_file, 408 ignore_failures_file=args.ignore_failures_file)
409 generated_images_root=args.workdir)
410 gm_json.WriteToFile( 409 gm_json.WriteToFile(
411 results_obj.get_packaged_results_of_type(results_type=args.results), 410 results_obj.get_packaged_results_of_type(results_type=args.results),
412 args.outfile) 411 args.outfile)
413 412
414 413
415 if __name__ == '__main__': 414 if __name__ == '__main__':
416 main() 415 main()
OLDNEW
« no previous file with comments | « no previous file | gm/rebaseline_server/compare_to_expectations_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698