Example #1
0
def validate_downloaded_archives(subtask_id: str, archives_list: Iterable[str],
                                 scene_file: str) -> None:
    # If archive is broken, it means that Provider must have intentionally uploaded damaged zip file.
    # In such case verification end with MISMATCH result.
    package_files_list = []  # type: List[str]
    try:
        # If any file which is supposed to be unpacked from archives already exists, finish with error and raise exception.
        for package_file_path in archives_list:
            package_files_list += get_files_list_from_archive(
                generate_verifier_storage_file_path(package_file_path))
    except zipfile.BadZipFile:
        raise VerificationMismatch(subtask_id)

    already_existing_files = set(os.listdir(
        settings.VERIFIER_STORAGE_PATH)).intersection(package_files_list)
    if already_existing_files:
        # This should not happen normally as the directory is cleaned before
        raise VerificationError(
            f'Files:<{", ".join(already_existing_files)}> already exist.',
            ErrorCode.VERIFIER_UNPACKING_ARCHIVE_FAILED,
            subtask_id,
        )

    # Similarly, it is Provider's responsibility to upload scene file.
    # If it is missing, verification end with MISMATCH result.
    if scene_file not in package_files_list:
        raise VerificationMismatch(subtask_id)
Example #2
0
def compare_minimum_ssim_with_results(ssim_list: List[float], subtask_id: str) -> None:
    # Compare SSIM with VERIFIER_MIN_SSIM.
    if settings.VERIFIER_MIN_SSIM < min(ssim_list):
        verification_result.delay(
            subtask_id,
            VerificationResult.MATCH.name,
        )
        return
    else:
        raise VerificationMismatch(subtask_id=subtask_id)
Example #3
0
def ensure_enough_result_files_provided(frames: List[int],
                                        result_files_list: List[str],
                                        subtask_id: str) -> None:
    if len(frames) > len(result_files_list):
        raise VerificationMismatch(subtask_id=subtask_id)

    elif len(frames) < len(result_files_list):
        log(
            logger,
            f'There is more result files than frames to render',
            subtask_id=subtask_id,
            logging_level=LoggingLevel.WARNING,
        )
Example #4
0
def compare_all_rendered_images_with_user_results_files(parsed_files_to_compare: FramesToParsedFilePaths, subtask_id: str) -> List[float]:
    ssim_list = []
    for (result_file, blender_output_file_name) in parsed_files_to_compare.values():
        image_1, image_2 = load_images(
            blender_output_file_name,
            result_file,
            subtask_id
        )
        if not are_image_sizes_and_color_channels_equal(image_1, image_2):
            log_string_message(
                logger,
                f'Blender verification failed. Sizes in pixels of images are not equal. SUBTASK_ID: {subtask_id}.'
                f'VerificationResult: {VerificationResult.MISMATCH.name}'
            )
            raise VerificationMismatch(subtask_id=subtask_id)

        ssim_list.append(compare_images(image_1, image_2, subtask_id))
    return ssim_list
Example #5
0
def ensure_frames_have_related_files_to_compare(
        frames: List[int], parsed_files_to_compare: FramesToParsedFilePaths,
        subtask_id: str) -> None:
    if len(frames) != len(parsed_files_to_compare):
        raise VerificationMismatch(subtask_id=subtask_id)
Example #6
0
def ensure_enough_result_files_provided(frames: List[int], result_files_list: List[str], subtask_id: str) -> None:
    if len(frames) > len(result_files_list):
        raise VerificationMismatch(subtask_id=subtask_id)

    elif len(frames) < len(result_files_list):
        logger.warning(f'There is more result files than frames to render')