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

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

Issue 480293002: rebaseline_server: constrain setADir/setBDir to consistently refer to single directories, not lists (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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_rendered_pictures_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 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 Compare results of two render_pictures runs. 9 Compare results of two render_pictures runs.
10 10
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 gm_json.JSONKEY_ACTUALRESULTS, 78 gm_json.JSONKEY_ACTUALRESULTS,
79 gm_json.JSONKEY_EXPECTEDRESULTS, 79 gm_json.JSONKEY_EXPECTEDRESULTS,
80 ] 80 ]
81 81
82 82
83 class RenderedPicturesComparisons(results.BaseComparisons): 83 class RenderedPicturesComparisons(results.BaseComparisons):
84 """Loads results from multiple render_pictures runs into an ImagePairSet. 84 """Loads results from multiple render_pictures runs into an ImagePairSet.
85 """ 85 """
86 86
87 def __init__(self, 87 def __init__(self,
88 setA_dirs, setB_dirs, 88 setA_dir, setB_dir,
89 setA_section, setB_section, 89 setA_section, setB_section,
90 image_diff_db, 90 image_diff_db,
91 image_base_gs_url=DEFAULT_IMAGE_BASE_GS_URL, diff_base_url=None, 91 image_base_gs_url=DEFAULT_IMAGE_BASE_GS_URL, diff_base_url=None,
92 setA_label=None, setB_label=None, 92 setA_label=None, setB_label=None,
93 gs=None, truncate_results=False, prefetch_only=False, 93 gs=None, truncate_results=False, prefetch_only=False,
94 download_all_images=False): 94 download_all_images=False):
95 """Constructor: downloads images and generates diffs. 95 """Constructor: downloads images and generates diffs.
96 96
97 Once the object has been created (which may take a while), you can call its 97 Once the object has been created (which may take a while), you can call its
98 get_packaged_results_of_type() method to quickly retrieve the results... 98 get_packaged_results_of_type() method to quickly retrieve the results...
99 unless you have set prefetch_only to True, in which case we will 99 unless you have set prefetch_only to True, in which case we will
100 asynchronously warm up the ImageDiffDB cache but not fill in self._results. 100 asynchronously warm up the ImageDiffDB cache but not fill in self._results.
101 101
102 Args: 102 Args:
103 setA_dirs: list of root directories to copy all JSON summaries from, 103 setA_dir: root directory to copy all JSON summaries from, and to use as
104 and to use as setA within the comparisons. These directories may be 104 setA within the comparisons. This directory may be specified as a
105 gs:// URLs, special "repo:" URLs, or local filepaths. 105 gs:// URL, special "repo:" URL, or local filepath.
106 setB_dirs: list of root directories to copy all JSON summaries from, 106 setB_dir: root directory to copy all JSON summaries from, and to use as
107 and to use as setB within the comparisons. These directories may be 107 setB within the comparisons. This directory may be specified as a
108 gs:// URLs, special "repo:" URLs, or local filepaths. 108 gs:// URL, special "repo:" URL, or local filepath.
109 setA_section: which section within setA to examine; must be one of 109 setA_section: which section within setA to examine; must be one of
110 ALLOWED_SECTION_NAMES 110 ALLOWED_SECTION_NAMES
111 setB_section: which section within setB to examine; must be one of 111 setB_section: which section within setB to examine; must be one of
112 ALLOWED_SECTION_NAMES 112 ALLOWED_SECTION_NAMES
113 image_diff_db: ImageDiffDB instance 113 image_diff_db: ImageDiffDB instance
114 image_base_gs_url: "gs://" URL pointing at the Google Storage bucket/dir 114 image_base_gs_url: "gs://" URL pointing at the Google Storage bucket/dir
115 under which all render_pictures result images can 115 under which all render_pictures result images can
116 be found; this will be used to read images for comparison within 116 be found; this will be used to read images for comparison within
117 this code, and included in the ImagePairSet (as an HTTP URL) so its 117 this code, and included in the ImagePairSet (as an HTTP URL) so its
118 consumers know where to download the images from 118 consumers know where to download the images from
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 self._setA_label = setA_label or setA_section 152 self._setA_label = setA_label or setA_section
153 self._setB_label = setB_label or setB_section 153 self._setB_label = setB_label or setB_section
154 else: 154 else:
155 self._setA_label = setA_label or 'setA' 155 self._setA_label = setA_label or 'setA'
156 self._setB_label = setB_label or 'setB' 156 self._setB_label = setB_label or 'setB'
157 157
158 tempdir = tempfile.mkdtemp() 158 tempdir = tempfile.mkdtemp()
159 try: 159 try:
160 setA_root = os.path.join(tempdir, 'setA') 160 setA_root = os.path.join(tempdir, 'setA')
161 setB_root = os.path.join(tempdir, 'setB') 161 setB_root = os.path.join(tempdir, 'setB')
162 setA_repo_revision = None 162 # TODO(stephana): There is a potential race condition here... we copy
163 setB_repo_revision = None 163 # the contents out of the source_dir, and THEN we get the commithash
164 for source_dir in setA_dirs: 164 # of source_dir. If source_dir points at a git checkout, and that
165 self._copy_dir_contents(source_dir=source_dir, dest_dir=setA_root) 165 # checkout is updated (by a different thread/process) during this
166 # TODO(stephana): There is a potential race condition here... we copy 166 # operation, then the contents and commithash will be out of sync.
167 # the contents out of the source_dir, and THEN we get the commithash 167 self._copy_dir_contents(source_dir=setA_dir, dest_dir=setA_root)
168 # of source_dir. If source_dir points at a git checkout, and that 168 setA_repo_revision = self._get_repo_revision(source_dir=setA_dir)
169 # checkout is updated (by a different thread/process) during this 169 self._copy_dir_contents(source_dir=setB_dir, dest_dir=setB_root)
170 # operation, then the contents and commithash will be out of sync. 170 setB_repo_revision = self._get_repo_revision(source_dir=setB_dir)
171 setA_repo_revision = self._get_repo_revision(
172 source_dir=source_dir, assert_if_not=setA_repo_revision)
173 for source_dir in setB_dirs:
174 self._copy_dir_contents(source_dir=source_dir, dest_dir=setB_root)
175 setB_repo_revision = self._get_repo_revision(
176 source_dir=source_dir, assert_if_not=setB_repo_revision)
177 171
178 self._setA_descriptions = { 172 self._setA_descriptions = {
179 results.KEY__SET_DESCRIPTIONS__DIR: setA_dirs, 173 results.KEY__SET_DESCRIPTIONS__DIR: setA_dir,
180 results.KEY__SET_DESCRIPTIONS__REPO_REVISION: setA_repo_revision, 174 results.KEY__SET_DESCRIPTIONS__REPO_REVISION: setA_repo_revision,
181 results.KEY__SET_DESCRIPTIONS__SECTION: setA_section, 175 results.KEY__SET_DESCRIPTIONS__SECTION: setA_section,
182 } 176 }
183 self._setB_descriptions = { 177 self._setB_descriptions = {
184 results.KEY__SET_DESCRIPTIONS__DIR: setB_dirs, 178 results.KEY__SET_DESCRIPTIONS__DIR: setB_dir,
185 results.KEY__SET_DESCRIPTIONS__REPO_REVISION: setB_repo_revision, 179 results.KEY__SET_DESCRIPTIONS__REPO_REVISION: setB_repo_revision,
186 results.KEY__SET_DESCRIPTIONS__SECTION: setB_section, 180 results.KEY__SET_DESCRIPTIONS__SECTION: setB_section,
187 } 181 }
188 182
189 time_start = int(time.time()) 183 time_start = int(time.time())
190 self._results = self._load_result_pairs( 184 self._results = self._load_result_pairs(
191 setA_root=setA_root, setB_root=setB_root, 185 setA_root=setA_root, setB_root=setB_root,
192 setA_section=setA_section, setB_section=setB_section) 186 setA_section=setA_section, setB_section=setB_section)
193 if self._results: 187 if self._results:
194 self._timestamp = int(time.time()) 188 self._timestamp = int(time.time())
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 if gs_utils.GSUtils.is_gs_url(source_dir): 455 if gs_utils.GSUtils.is_gs_url(source_dir):
462 (bucket, path) = gs_utils.GSUtils.split_gs_url(source_dir) 456 (bucket, path) = gs_utils.GSUtils.split_gs_url(source_dir)
463 self._gs.download_dir_contents(source_bucket=bucket, source_dir=path, 457 self._gs.download_dir_contents(source_bucket=bucket, source_dir=path,
464 dest_dir=dest_dir) 458 dest_dir=dest_dir)
465 elif source_dir.lower().startswith(REPO_URL_PREFIX): 459 elif source_dir.lower().startswith(REPO_URL_PREFIX):
466 repo_dir = os.path.join(REPO_BASEPATH, source_dir[len(REPO_URL_PREFIX):]) 460 repo_dir = os.path.join(REPO_BASEPATH, source_dir[len(REPO_URL_PREFIX):])
467 shutil.copytree(repo_dir, dest_dir) 461 shutil.copytree(repo_dir, dest_dir)
468 else: 462 else:
469 shutil.copytree(source_dir, dest_dir) 463 shutil.copytree(source_dir, dest_dir)
470 464
471 def _get_repo_revision(self, source_dir, assert_if_not=None): 465 def _get_repo_revision(self, source_dir):
472 """Get the commit hash of source_dir, IF it refers to a git checkout. 466 """Get the commit hash of source_dir, IF it refers to a git checkout.
473 467
474 Args: 468 Args:
475 source_dir: path to source dir (GS URL, local filepath, or a special 469 source_dir: path to source dir (GS URL, local filepath, or a special
476 "repo:" URL type that points at a file within our Skia checkout; 470 "repo:" URL type that points at a file within our Skia checkout;
477 only the "repo:" URL type will have a commit hash. 471 only the "repo:" URL type will have a commit hash.
478 assert_if_not: if not None, raise an Exception if source_dir has a
479 commit hash and that hash is not equal to this
480 """ 472 """
481 if source_dir.lower().startswith(REPO_URL_PREFIX): 473 if source_dir.lower().startswith(REPO_URL_PREFIX):
482 repo_dir = os.path.join(REPO_BASEPATH, source_dir[len(REPO_URL_PREFIX):]) 474 repo_dir = os.path.join(REPO_BASEPATH, source_dir[len(REPO_URL_PREFIX):])
483 revision = subprocess.check_output( 475 return subprocess.check_output(
484 args=[git_utils.GIT, 'rev-parse', 'HEAD'], cwd=repo_dir).strip() 476 args=[git_utils.GIT, 'rev-parse', 'HEAD'], cwd=repo_dir).strip()
485 if assert_if_not and revision != assert_if_not:
486 raise Exception('found revision %s that did not match %s' % (
487 revision, assert_if_not))
488 return revision
489 else: 477 else:
490 return None 478 return None
OLDNEW
« no previous file with comments | « no previous file | gm/rebaseline_server/compare_rendered_pictures_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698