| 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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 (dict_num, num_union_dict_paths, dict_path)) | 261 (dict_num, num_union_dict_paths, dict_path)) |
| 262 | 262 |
| 263 dictA = self.get_default(setA_dicts, None, dict_path) | 263 dictA = self.get_default(setA_dicts, None, dict_path) |
| 264 self._validate_dict_version(dictA) | 264 self._validate_dict_version(dictA) |
| 265 dictA_results = self.get_default(dictA, {}, setA_section) | 265 dictA_results = self.get_default(dictA, {}, setA_section) |
| 266 | 266 |
| 267 dictB = self.get_default(setB_dicts, None, dict_path) | 267 dictB = self.get_default(setB_dicts, None, dict_path) |
| 268 self._validate_dict_version(dictB) | 268 self._validate_dict_version(dictB) |
| 269 dictB_results = self.get_default(dictB, {}, setB_section) | 269 dictB_results = self.get_default(dictB, {}, setB_section) |
| 270 | 270 |
| 271 image_A_base_url = self.get_default( |
| 272 setA_dicts, self._image_base_gs_url, dict_path, |
| 273 gm_json.JSONKEY_IMAGE_BASE_GS_URL) |
| 274 image_B_base_url = self.get_default( |
| 275 setB_dicts, self._image_base_gs_url, dict_path, |
| 276 gm_json.JSONKEY_IMAGE_BASE_GS_URL) |
| 277 |
| 271 # get the builders and render modes for each set | 278 # get the builders and render modes for each set |
| 272 builder_A = self.get_default(dictA, None, | 279 builder_A = self.get_default(dictA, None, |
| 273 gm_json.JSONKEY_DESCRIPTIONS, | 280 gm_json.JSONKEY_DESCRIPTIONS, |
| 274 gm_json.JSONKEY_DESCRIPTIONS_BUILDER) | 281 gm_json.JSONKEY_DESCRIPTIONS_BUILDER) |
| 275 render_mode_A = self.get_default(dictA, None, | 282 render_mode_A = self.get_default(dictA, None, |
| 276 gm_json.JSONKEY_DESCRIPTIONS, | 283 gm_json.JSONKEY_DESCRIPTIONS, |
| 277 gm_json.JSONKEY_DESCRIPTIONS_RENDER_MODE) | 284 gm_json.JSONKEY_DESCRIPTIONS_RENDER_MODE) |
| 278 builder_B = self.get_default(dictB, None, | 285 builder_B = self.get_default(dictB, None, |
| 279 gm_json.JSONKEY_DESCRIPTIONS, | 286 gm_json.JSONKEY_DESCRIPTIONS, |
| 280 gm_json.JSONKEY_DESCRIPTIONS_BUILDER) | 287 gm_json.JSONKEY_DESCRIPTIONS_BUILDER) |
| 281 render_mode_B = self.get_default(dictB, None, | 288 render_mode_B = self.get_default(dictB, None, |
| 282 gm_json.JSONKEY_DESCRIPTIONS, | 289 gm_json.JSONKEY_DESCRIPTIONS, |
| 283 gm_json.JSONKEY_DESCRIPTIONS_RENDER_MODE) | 290 gm_json.JSONKEY_DESCRIPTIONS_RENDER_MODE) |
| 284 | 291 |
| 285 skp_names = sorted(set(dictA_results.keys() + dictB_results.keys())) | 292 skp_names = sorted(set(dictA_results.keys() + dictB_results.keys())) |
| 286 # Just for manual testing... truncate to an arbitrary subset. | 293 # Just for manual testing... truncate to an arbitrary subset. |
| 287 if self.truncate_results: | 294 if self.truncate_results: |
| 288 skp_names = skp_names[1:3] | 295 skp_names = skp_names[1:3] |
| 289 for skp_name in skp_names: | 296 for skp_name in skp_names: |
| 290 imagepairs_for_this_skp = [] | 297 imagepairs_for_this_skp = [] |
| 291 | 298 |
| 292 whole_image_A = self.get_default( | 299 whole_image_A = self.get_default( |
| 293 dictA_results, None, | 300 dictA_results, None, |
| 294 skp_name, gm_json.JSONKEY_SOURCE_WHOLEIMAGE) | 301 skp_name, gm_json.JSONKEY_SOURCE_WHOLEIMAGE) |
| 295 whole_image_B = self.get_default( | 302 whole_image_B = self.get_default( |
| 296 dictB_results, None, | 303 dictB_results, None, |
| 297 skp_name, gm_json.JSONKEY_SOURCE_WHOLEIMAGE) | 304 skp_name, gm_json.JSONKEY_SOURCE_WHOLEIMAGE) |
| 305 |
| 298 imagepairs_for_this_skp.append(self._create_image_pair( | 306 imagepairs_for_this_skp.append(self._create_image_pair( |
| 299 image_dict_A=whole_image_A, image_dict_B=whole_image_B, | 307 image_dict_A=whole_image_A, image_dict_B=whole_image_B, |
| 308 image_A_base_url=image_A_base_url, |
| 309 image_B_base_url=image_B_base_url, |
| 300 builder_A=builder_A, render_mode_A=render_mode_A, | 310 builder_A=builder_A, render_mode_A=render_mode_A, |
| 301 builder_B=builder_B, render_mode_B=render_mode_B, | 311 builder_B=builder_B, render_mode_B=render_mode_B, |
| 302 source_json_file=dict_path, | 312 source_json_file=dict_path, |
| 303 source_skp_name=skp_name, tilenum=None)) | 313 source_skp_name=skp_name, tilenum=None)) |
| 304 | 314 |
| 305 tiled_images_A = self.get_default( | 315 tiled_images_A = self.get_default( |
| 306 dictA_results, [], | 316 dictA_results, [], |
| 307 skp_name, gm_json.JSONKEY_SOURCE_TILEDIMAGES) | 317 skp_name, gm_json.JSONKEY_SOURCE_TILEDIMAGES) |
| 308 tiled_images_B = self.get_default( | 318 tiled_images_B = self.get_default( |
| 309 dictB_results, [], | 319 dictB_results, [], |
| 310 skp_name, gm_json.JSONKEY_SOURCE_TILEDIMAGES) | 320 skp_name, gm_json.JSONKEY_SOURCE_TILEDIMAGES) |
| 311 if tiled_images_A or tiled_images_B: | 321 if tiled_images_A or tiled_images_B: |
| 312 num_tiles_A = len(tiled_images_A) | 322 num_tiles_A = len(tiled_images_A) |
| 313 num_tiles_B = len(tiled_images_B) | 323 num_tiles_B = len(tiled_images_B) |
| 314 num_tiles = max(num_tiles_A, num_tiles_B) | 324 num_tiles = max(num_tiles_A, num_tiles_B) |
| 315 for tile_num in range(num_tiles): | 325 for tile_num in range(num_tiles): |
| 316 imagepairs_for_this_skp.append(self._create_image_pair( | 326 imagepairs_for_this_skp.append(self._create_image_pair( |
| 317 image_dict_A=(tiled_images_A[tile_num] | 327 image_dict_A=(tiled_images_A[tile_num] |
| 318 if tile_num < num_tiles_A else None), | 328 if tile_num < num_tiles_A else None), |
| 319 image_dict_B=(tiled_images_B[tile_num] | 329 image_dict_B=(tiled_images_B[tile_num] |
| 320 if tile_num < num_tiles_B else None), | 330 if tile_num < num_tiles_B else None), |
| 331 image_A_base_url=image_A_base_url, |
| 332 image_B_base_url=image_B_base_url, |
| 321 builder_A=builder_A, render_mode_A=render_mode_A, | 333 builder_A=builder_A, render_mode_A=render_mode_A, |
| 322 builder_B=builder_B, render_mode_B=render_mode_B, | 334 builder_B=builder_B, render_mode_B=render_mode_B, |
| 323 source_json_file=dict_path, | 335 source_json_file=dict_path, |
| 324 source_skp_name=skp_name, tilenum=tile_num)) | 336 source_skp_name=skp_name, tilenum=tile_num)) |
| 325 | 337 |
| 326 for one_imagepair in imagepairs_for_this_skp: | 338 for one_imagepair in imagepairs_for_this_skp: |
| 327 if one_imagepair: | 339 if one_imagepair: |
| 328 all_image_pairs.add_image_pair(one_imagepair) | 340 all_image_pairs.add_image_pair(one_imagepair) |
| 329 result_type = one_imagepair.extra_columns_dict\ | 341 result_type = one_imagepair.extra_columns_dict\ |
| 330 [COLUMN__RESULT_TYPE] | 342 [COLUMN__RESULT_TYPE] |
| (...skipping 30 matching lines...) Expand all Loading... |
| 361 header = result_dict[gm_json.JSONKEY_HEADER] | 373 header = result_dict[gm_json.JSONKEY_HEADER] |
| 362 header_type = header[gm_json.JSONKEY_HEADER_TYPE] | 374 header_type = header[gm_json.JSONKEY_HEADER_TYPE] |
| 363 if header_type != expected_header_type: | 375 if header_type != expected_header_type: |
| 364 raise Exception('expected header_type "%s", but got "%s"' % ( | 376 raise Exception('expected header_type "%s", but got "%s"' % ( |
| 365 expected_header_type, header_type)) | 377 expected_header_type, header_type)) |
| 366 header_revision = header[gm_json.JSONKEY_HEADER_REVISION] | 378 header_revision = header[gm_json.JSONKEY_HEADER_REVISION] |
| 367 if header_revision != expected_header_revision: | 379 if header_revision != expected_header_revision: |
| 368 raise Exception('expected header_revision %d, but got %d' % ( | 380 raise Exception('expected header_revision %d, but got %d' % ( |
| 369 expected_header_revision, header_revision)) | 381 expected_header_revision, header_revision)) |
| 370 | 382 |
| 371 def _create_image_pair(self, image_dict_A, image_dict_B, | 383 def _create_image_pair(self, image_dict_A, image_dict_B, |
| 372 builder_A, render_mode_A, | 384 image_A_base_url, image_B_base_url, |
| 385 builder_A, render_mode_A, |
| 373 builder_B, render_mode_B, | 386 builder_B, render_mode_B, |
| 374 source_json_file, | 387 source_json_file, |
| 375 source_skp_name, tilenum): | 388 source_skp_name, tilenum): |
| 376 """Creates an ImagePair object for this pair of images. | 389 """Creates an ImagePair object for this pair of images. |
| 377 | 390 |
| 378 Args: | 391 Args: |
| 379 image_dict_A: dict with JSONKEY_IMAGE_* keys, or None if no image | 392 image_dict_A: dict with JSONKEY_IMAGE_* keys, or None if no image |
| 380 image_dict_B: dict with JSONKEY_IMAGE_* keys, or None if no image | 393 image_dict_B: dict with JSONKEY_IMAGE_* keys, or None if no image |
| 394 image_A_base_url: base URL for image A |
| 395 image_B_base_url: base URL for image B |
| 381 builder_A: builder that created image set A or None if unknow | 396 builder_A: builder that created image set A or None if unknow |
| 382 render_mode_A: render mode used to generate image set A or None if | 397 render_mode_A: render mode used to generate image set A or None if |
| 383 unknown. | 398 unknown. |
| 384 builder_B: builder that created image set A or None if unknow | 399 builder_B: builder that created image set A or None if unknow |
| 385 render_mode_B: render mode used to generate image set A or None if | 400 render_mode_B: render mode used to generate image set A or None if |
| 386 unknown. | 401 unknown. |
| 387 source_json_file: string; relative path of the JSON file where this | 402 source_json_file: string; relative path of the JSON file where this |
| 388 result came from, within setA and setB. | 403 result came from, within setA and setB. |
| 389 source_skp_name: string; name of the source SKP file | 404 source_skp_name: string; name of the source SKP file |
| 390 tilenum: which tile, or None if a wholeimage | 405 tilenum: which tile, or None if a wholeimage |
| 391 | 406 |
| 392 Returns: | 407 Returns: |
| 393 An ImagePair object, or None if both image_dict_A and image_dict_B are | 408 An ImagePair object, or None if both image_dict_A and image_dict_B are |
| 394 None. | 409 None. |
| 395 """ | 410 """ |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 if tilenum == None: | 444 if tilenum == None: |
| 430 extra_columns_dict[COLUMN__TILED_OR_WHOLE] = COLUMN__TILED_OR_WHOLE__WHOLE | 445 extra_columns_dict[COLUMN__TILED_OR_WHOLE] = COLUMN__TILED_OR_WHOLE__WHOLE |
| 431 extra_columns_dict[COLUMN__TILENUM] = 'N/A' | 446 extra_columns_dict[COLUMN__TILENUM] = 'N/A' |
| 432 else: | 447 else: |
| 433 extra_columns_dict[COLUMN__TILED_OR_WHOLE] = COLUMN__TILED_OR_WHOLE__TILED | 448 extra_columns_dict[COLUMN__TILED_OR_WHOLE] = COLUMN__TILED_OR_WHOLE__TILED |
| 434 extra_columns_dict[COLUMN__TILENUM] = str(tilenum) | 449 extra_columns_dict[COLUMN__TILENUM] = str(tilenum) |
| 435 | 450 |
| 436 try: | 451 try: |
| 437 return imagepair.ImagePair( | 452 return imagepair.ImagePair( |
| 438 image_diff_db=self._image_diff_db, | 453 image_diff_db=self._image_diff_db, |
| 439 base_url=self._image_base_gs_url, | 454 imageA_base_url=image_A_base_url, |
| 455 imageB_base_url=image_B_base_url, |
| 440 imageA_relative_url=imageA_relative_url, | 456 imageA_relative_url=imageA_relative_url, |
| 441 imageB_relative_url=imageB_relative_url, | 457 imageB_relative_url=imageB_relative_url, |
| 442 extra_columns=extra_columns_dict, | 458 extra_columns=extra_columns_dict, |
| 443 source_json_file=source_json_file, | 459 source_json_file=source_json_file, |
| 444 download_all_images=self._download_all_images) | 460 download_all_images=self._download_all_images) |
| 445 except (KeyError, TypeError): | 461 except (KeyError, TypeError): |
| 446 logging.exception( | 462 logging.exception( |
| 447 'got exception while creating ImagePair for' | 463 'got exception while creating ImagePair for' |
| 448 ' urlPair=("%s","%s"), source_skp_name="%s", tilenum="%s"' % ( | 464 ' urlPair=("%s","%s"), source_skp_name="%s", tilenum="%s"' % ( |
| 449 imageA_relative_url, imageB_relative_url, source_skp_name, | 465 imageA_relative_url, imageB_relative_url, source_skp_name, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 479 source_dir: path to source dir (GS URL, local filepath, or a special | 495 source_dir: path to source dir (GS URL, local filepath, or a special |
| 480 "repo:" URL type that points at a file within our Skia checkout; | 496 "repo:" URL type that points at a file within our Skia checkout; |
| 481 only the "repo:" URL type will have a commit hash. | 497 only the "repo:" URL type will have a commit hash. |
| 482 """ | 498 """ |
| 483 if source_dir.lower().startswith(REPO_URL_PREFIX): | 499 if source_dir.lower().startswith(REPO_URL_PREFIX): |
| 484 repo_dir = os.path.join(REPO_BASEPATH, source_dir[len(REPO_URL_PREFIX):]) | 500 repo_dir = os.path.join(REPO_BASEPATH, source_dir[len(REPO_URL_PREFIX):]) |
| 485 return subprocess.check_output( | 501 return subprocess.check_output( |
| 486 args=[git_utils.GIT, 'rev-parse', 'HEAD'], cwd=repo_dir).strip() | 502 args=[git_utils.GIT, 'rev-parse', 'HEAD'], cwd=repo_dir).strip() |
| 487 else: | 503 else: |
| 488 return None | 504 return None |
| OLD | NEW |