| OLD | NEW |
| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 # Column descriptors, and display preferences for them. | 45 # Column descriptors, and display preferences for them. |
| 46 COLUMN__RESULT_TYPE = results.KEY__EXTRACOLUMNS__RESULT_TYPE | 46 COLUMN__RESULT_TYPE = results.KEY__EXTRACOLUMNS__RESULT_TYPE |
| 47 COLUMN__SOURCE_SKP = 'sourceSkpFile' | 47 COLUMN__SOURCE_SKP = 'sourceSkpFile' |
| 48 COLUMN__TILED_OR_WHOLE = 'tiledOrWhole' | 48 COLUMN__TILED_OR_WHOLE = 'tiledOrWhole' |
| 49 COLUMN__TILENUM = 'tilenum' | 49 COLUMN__TILENUM = 'tilenum' |
| 50 COLUMN__BUILDER_A = 'builderA' | 50 COLUMN__BUILDER_A = 'builderA' |
| 51 COLUMN__RENDER_MODE_A = 'renderModeA' | 51 COLUMN__RENDER_MODE_A = 'renderModeA' |
| 52 COLUMN__BUILDER_B = 'builderB' | 52 COLUMN__BUILDER_B = 'builderB' |
| 53 COLUMN__RENDER_MODE_B = 'renderModeB' | 53 COLUMN__RENDER_MODE_B = 'renderModeB' |
| 54 # Known values for some of those columns. |
| 55 COLUMN__TILED_OR_WHOLE__TILED = 'tiled' |
| 56 COLUMN__TILED_OR_WHOLE__WHOLE = 'whole' |
| 54 | 57 |
| 55 FREEFORM_COLUMN_IDS = [ | 58 FREEFORM_COLUMN_IDS = [ |
| 56 COLUMN__SOURCE_SKP, | 59 COLUMN__SOURCE_SKP, |
| 57 COLUMN__TILENUM, | 60 COLUMN__TILENUM, |
| 58 ] | 61 ] |
| 59 ORDERED_COLUMN_IDS = [ | 62 ORDERED_COLUMN_IDS = [ |
| 60 COLUMN__RESULT_TYPE, | 63 COLUMN__RESULT_TYPE, |
| 61 COLUMN__SOURCE_SKP, | 64 COLUMN__SOURCE_SKP, |
| 62 COLUMN__TILED_OR_WHOLE, | 65 COLUMN__TILED_OR_WHOLE, |
| 63 COLUMN__TILENUM, | 66 COLUMN__TILENUM, |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 setA_section: which section (gm_json.JSONKEY_ACTUALRESULTS or | 209 setA_section: which section (gm_json.JSONKEY_ACTUALRESULTS or |
| 207 gm_json.JSONKEY_EXPECTEDRESULTS) to load from the summaries in setA | 210 gm_json.JSONKEY_EXPECTEDRESULTS) to load from the summaries in setA |
| 208 setB_section: which section (gm_json.JSONKEY_ACTUALRESULTS or | 211 setB_section: which section (gm_json.JSONKEY_ACTUALRESULTS or |
| 209 gm_json.JSONKEY_EXPECTEDRESULTS) to load from the summaries in setB | 212 gm_json.JSONKEY_EXPECTEDRESULTS) to load from the summaries in setB |
| 210 | 213 |
| 211 Returns the summary of all image diff results (or None, depending on | 214 Returns the summary of all image diff results (or None, depending on |
| 212 self._prefetch_only). | 215 self._prefetch_only). |
| 213 """ | 216 """ |
| 214 logging.info('Reading JSON image summaries from dirs %s and %s...' % ( | 217 logging.info('Reading JSON image summaries from dirs %s and %s...' % ( |
| 215 setA_root, setB_root)) | 218 setA_root, setB_root)) |
| 216 setA_dicts = self._read_dicts_from_root(setA_root) | 219 setA_dicts = self.read_dicts_from_root(setA_root) |
| 217 setB_dicts = self._read_dicts_from_root(setB_root) | 220 setB_dicts = self.read_dicts_from_root(setB_root) |
| 218 logging.info('Comparing summary dicts...') | 221 logging.info('Comparing summary dicts...') |
| 219 | 222 |
| 220 all_image_pairs = imagepairset.ImagePairSet( | 223 all_image_pairs = imagepairset.ImagePairSet( |
| 221 descriptions=(self._setA_label, self._setB_label), | 224 descriptions=(self._setA_label, self._setB_label), |
| 222 diff_base_url=self._diff_base_url) | 225 diff_base_url=self._diff_base_url) |
| 223 failing_image_pairs = imagepairset.ImagePairSet( | 226 failing_image_pairs = imagepairset.ImagePairSet( |
| 224 descriptions=(self._setA_label, self._setB_label), | 227 descriptions=(self._setA_label, self._setB_label), |
| 225 diff_base_url=self._diff_base_url) | 228 diff_base_url=self._diff_base_url) |
| 226 | 229 |
| 227 # Override settings for columns that should be filtered using freeform text. | 230 # Override settings for columns that should be filtered using freeform text. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 whole_image_A = self.get_default( | 292 whole_image_A = self.get_default( |
| 290 dictA_results, None, | 293 dictA_results, None, |
| 291 skp_name, gm_json.JSONKEY_SOURCE_WHOLEIMAGE) | 294 skp_name, gm_json.JSONKEY_SOURCE_WHOLEIMAGE) |
| 292 whole_image_B = self.get_default( | 295 whole_image_B = self.get_default( |
| 293 dictB_results, None, | 296 dictB_results, None, |
| 294 skp_name, gm_json.JSONKEY_SOURCE_WHOLEIMAGE) | 297 skp_name, gm_json.JSONKEY_SOURCE_WHOLEIMAGE) |
| 295 imagepairs_for_this_skp.append(self._create_image_pair( | 298 imagepairs_for_this_skp.append(self._create_image_pair( |
| 296 image_dict_A=whole_image_A, image_dict_B=whole_image_B, | 299 image_dict_A=whole_image_A, image_dict_B=whole_image_B, |
| 297 builder_A=builder_A, render_mode_A=render_mode_A, | 300 builder_A=builder_A, render_mode_A=render_mode_A, |
| 298 builder_B=builder_B, render_mode_B=render_mode_B, | 301 builder_B=builder_B, render_mode_B=render_mode_B, |
| 302 source_json_file=dict_path, |
| 299 source_skp_name=skp_name, tilenum=None)) | 303 source_skp_name=skp_name, tilenum=None)) |
| 300 | 304 |
| 301 tiled_images_A = self.get_default( | 305 tiled_images_A = self.get_default( |
| 302 dictA_results, [], | 306 dictA_results, [], |
| 303 skp_name, gm_json.JSONKEY_SOURCE_TILEDIMAGES) | 307 skp_name, gm_json.JSONKEY_SOURCE_TILEDIMAGES) |
| 304 tiled_images_B = self.get_default( | 308 tiled_images_B = self.get_default( |
| 305 dictB_results, [], | 309 dictB_results, [], |
| 306 skp_name, gm_json.JSONKEY_SOURCE_TILEDIMAGES) | 310 skp_name, gm_json.JSONKEY_SOURCE_TILEDIMAGES) |
| 307 if tiled_images_A or tiled_images_B: | 311 if tiled_images_A or tiled_images_B: |
| 308 num_tiles_A = len(tiled_images_A) | 312 num_tiles_A = len(tiled_images_A) |
| 309 num_tiles_B = len(tiled_images_B) | 313 num_tiles_B = len(tiled_images_B) |
| 310 num_tiles = max(num_tiles_A, num_tiles_B) | 314 num_tiles = max(num_tiles_A, num_tiles_B) |
| 311 for tile_num in range(num_tiles): | 315 for tile_num in range(num_tiles): |
| 312 imagepairs_for_this_skp.append(self._create_image_pair( | 316 imagepairs_for_this_skp.append(self._create_image_pair( |
| 313 image_dict_A=(tiled_images_A[tile_num] | 317 image_dict_A=(tiled_images_A[tile_num] |
| 314 if tile_num < num_tiles_A else None), | 318 if tile_num < num_tiles_A else None), |
| 315 image_dict_B=(tiled_images_B[tile_num] | 319 image_dict_B=(tiled_images_B[tile_num] |
| 316 if tile_num < num_tiles_B else None), | 320 if tile_num < num_tiles_B else None), |
| 317 builder_A=builder_A, render_mode_A=render_mode_A, | 321 builder_A=builder_A, render_mode_A=render_mode_A, |
| 318 builder_B=builder_B, render_mode_B=render_mode_B, | 322 builder_B=builder_B, render_mode_B=render_mode_B, |
| 323 source_json_file=dict_path, |
| 319 source_skp_name=skp_name, tilenum=tile_num)) | 324 source_skp_name=skp_name, tilenum=tile_num)) |
| 320 | 325 |
| 321 for one_imagepair in imagepairs_for_this_skp: | 326 for one_imagepair in imagepairs_for_this_skp: |
| 322 if one_imagepair: | 327 if one_imagepair: |
| 323 all_image_pairs.add_image_pair(one_imagepair) | 328 all_image_pairs.add_image_pair(one_imagepair) |
| 324 result_type = one_imagepair.extra_columns_dict\ | 329 result_type = one_imagepair.extra_columns_dict\ |
| 325 [COLUMN__RESULT_TYPE] | 330 [COLUMN__RESULT_TYPE] |
| 326 if result_type != results.KEY__RESULT_TYPE__SUCCEEDED: | 331 if result_type != results.KEY__RESULT_TYPE__SUCCEEDED: |
| 327 failing_image_pairs.add_image_pair(one_imagepair) | 332 failing_image_pairs.add_image_pair(one_imagepair) |
| 328 | 333 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 357 raise Exception('expected header_type "%s", but got "%s"' % ( | 362 raise Exception('expected header_type "%s", but got "%s"' % ( |
| 358 expected_header_type, header_type)) | 363 expected_header_type, header_type)) |
| 359 header_revision = header[gm_json.JSONKEY_HEADER_REVISION] | 364 header_revision = header[gm_json.JSONKEY_HEADER_REVISION] |
| 360 if header_revision != expected_header_revision: | 365 if header_revision != expected_header_revision: |
| 361 raise Exception('expected header_revision %d, but got %d' % ( | 366 raise Exception('expected header_revision %d, but got %d' % ( |
| 362 expected_header_revision, header_revision)) | 367 expected_header_revision, header_revision)) |
| 363 | 368 |
| 364 def _create_image_pair(self, image_dict_A, image_dict_B, | 369 def _create_image_pair(self, image_dict_A, image_dict_B, |
| 365 builder_A, render_mode_A, | 370 builder_A, render_mode_A, |
| 366 builder_B, render_mode_B, | 371 builder_B, render_mode_B, |
| 367 source_skp_name, | 372 source_json_file, |
| 368 tilenum): | 373 source_skp_name, tilenum): |
| 369 """Creates an ImagePair object for this pair of images. | 374 """Creates an ImagePair object for this pair of images. |
| 370 | 375 |
| 371 Args: | 376 Args: |
| 372 image_dict_A: dict with JSONKEY_IMAGE_* keys, or None if no image | 377 image_dict_A: dict with JSONKEY_IMAGE_* keys, or None if no image |
| 373 image_dict_B: dict with JSONKEY_IMAGE_* keys, or None if no image | 378 image_dict_B: dict with JSONKEY_IMAGE_* keys, or None if no image |
| 374 builder_A: builder that created image set A or None if unknow | 379 builder_A: builder that created image set A or None if unknow |
| 375 render_mode_A: render mode used to generate image set A or None if | 380 render_mode_A: render mode used to generate image set A or None if |
| 376 unknown. | 381 unknown. |
| 377 builder_B: builder that created image set A or None if unknow | 382 builder_B: builder that created image set A or None if unknow |
| 378 render_mode_B: render mode used to generate image set A or None if | 383 render_mode_B: render mode used to generate image set A or None if |
| 379 unknown. | 384 unknown. |
| 385 source_json_file: string; relative path of the JSON file where this |
| 386 result came from, within setA and setB. |
| 380 source_skp_name: string; name of the source SKP file | 387 source_skp_name: string; name of the source SKP file |
| 381 tilenum: which tile, or None if a wholeimage | 388 tilenum: which tile, or None if a wholeimage |
| 382 | 389 |
| 383 Returns: | 390 Returns: |
| 384 An ImagePair object, or None if both image_dict_A and image_dict_B are | 391 An ImagePair object, or None if both image_dict_A and image_dict_B are |
| 385 None. | 392 None. |
| 386 """ | 393 """ |
| 387 if (not image_dict_A) and (not image_dict_B): | 394 if (not image_dict_A) and (not image_dict_B): |
| 388 return None | 395 return None |
| 389 | 396 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 411 | 418 |
| 412 extra_columns_dict = { | 419 extra_columns_dict = { |
| 413 COLUMN__RESULT_TYPE: result_type, | 420 COLUMN__RESULT_TYPE: result_type, |
| 414 COLUMN__SOURCE_SKP: source_skp_name, | 421 COLUMN__SOURCE_SKP: source_skp_name, |
| 415 COLUMN__BUILDER_A: builder_A, | 422 COLUMN__BUILDER_A: builder_A, |
| 416 COLUMN__RENDER_MODE_A: render_mode_A, | 423 COLUMN__RENDER_MODE_A: render_mode_A, |
| 417 COLUMN__BUILDER_B: builder_B, | 424 COLUMN__BUILDER_B: builder_B, |
| 418 COLUMN__RENDER_MODE_B: render_mode_B, | 425 COLUMN__RENDER_MODE_B: render_mode_B, |
| 419 } | 426 } |
| 420 if tilenum == None: | 427 if tilenum == None: |
| 421 extra_columns_dict[COLUMN__TILED_OR_WHOLE] = 'whole' | 428 extra_columns_dict[COLUMN__TILED_OR_WHOLE] = COLUMN__TILED_OR_WHOLE__WHOLE |
| 422 extra_columns_dict[COLUMN__TILENUM] = 'N/A' | 429 extra_columns_dict[COLUMN__TILENUM] = 'N/A' |
| 423 else: | 430 else: |
| 424 extra_columns_dict[COLUMN__TILED_OR_WHOLE] = 'tiled' | 431 extra_columns_dict[COLUMN__TILED_OR_WHOLE] = COLUMN__TILED_OR_WHOLE__TILED |
| 425 extra_columns_dict[COLUMN__TILENUM] = str(tilenum) | 432 extra_columns_dict[COLUMN__TILENUM] = str(tilenum) |
| 426 | 433 |
| 427 try: | 434 try: |
| 428 return imagepair.ImagePair( | 435 return imagepair.ImagePair( |
| 429 image_diff_db=self._image_diff_db, | 436 image_diff_db=self._image_diff_db, |
| 430 base_url=self._image_base_gs_url, | 437 base_url=self._image_base_gs_url, |
| 431 imageA_relative_url=imageA_relative_url, | 438 imageA_relative_url=imageA_relative_url, |
| 432 imageB_relative_url=imageB_relative_url, | 439 imageB_relative_url=imageB_relative_url, |
| 433 extra_columns=extra_columns_dict, | 440 extra_columns=extra_columns_dict, |
| 441 source_json_file=source_json_file, |
| 434 download_all_images=self._download_all_images) | 442 download_all_images=self._download_all_images) |
| 435 except (KeyError, TypeError): | 443 except (KeyError, TypeError): |
| 436 logging.exception( | 444 logging.exception( |
| 437 'got exception while creating ImagePair for' | 445 'got exception while creating ImagePair for' |
| 438 ' urlPair=("%s","%s"), source_skp_name="%s", tilenum="%s"' % ( | 446 ' urlPair=("%s","%s"), source_skp_name="%s", tilenum="%s"' % ( |
| 439 imageA_relative_url, imageB_relative_url, source_skp_name, | 447 imageA_relative_url, imageB_relative_url, source_skp_name, |
| 440 tilenum)) | 448 tilenum)) |
| 441 return None | 449 return None |
| 442 | 450 |
| 443 def _copy_dir_contents(self, source_dir, dest_dir): | 451 def _copy_dir_contents(self, source_dir, dest_dir): |
| (...skipping 25 matching lines...) Expand all Loading... |
| 469 source_dir: path to source dir (GS URL, local filepath, or a special | 477 source_dir: path to source dir (GS URL, local filepath, or a special |
| 470 "repo:" URL type that points at a file within our Skia checkout; | 478 "repo:" URL type that points at a file within our Skia checkout; |
| 471 only the "repo:" URL type will have a commit hash. | 479 only the "repo:" URL type will have a commit hash. |
| 472 """ | 480 """ |
| 473 if source_dir.lower().startswith(REPO_URL_PREFIX): | 481 if source_dir.lower().startswith(REPO_URL_PREFIX): |
| 474 repo_dir = os.path.join(REPO_BASEPATH, source_dir[len(REPO_URL_PREFIX):]) | 482 repo_dir = os.path.join(REPO_BASEPATH, source_dir[len(REPO_URL_PREFIX):]) |
| 475 return subprocess.check_output( | 483 return subprocess.check_output( |
| 476 args=[git_utils.GIT, 'rev-parse', 'HEAD'], cwd=repo_dir).strip() | 484 args=[git_utils.GIT, 'rev-parse', 'HEAD'], cwd=repo_dir).strip() |
| 477 else: | 485 else: |
| 478 return None | 486 return None |
| OLD | NEW |