Пример #1
0
    def test_that_if_frames_are_not_grater_than_0_method_should_raise_exception(
            self):
        with self.assertRaises(FrameNumberValidationError):
            validate_frames([-1, 1])

        with self.assertRaises(FrameNumberValidationError):
            validate_frames([0, 1])
Пример #2
0
    def test_that_if_frames_is_not_a_list_of_ints_method_should_raise_exception(
            self):
        with self.assertRaises(FrameNumberValidationError):
            validate_frames({'1': 1})

        with self.assertRaises(FrameNumberValidationError):
            validate_frames((1, 2))
Пример #3
0
 def test_that_if_frames_are_not_integers_method_should_raise_exception(
         self):
     with self.assertRaises(FrameNumberValidationError):
         validate_frames(['1', '2'])
Пример #4
0
 def test_that_if_frames_are_not_one_after_the_other_method_should_pass(
         self):
     try:
         validate_frames([1, 3, 5])
     except Exception:  # pylint: disable=broad-except
         self.fail()
Пример #5
0
 def test_that_list_of_ints_is_valid(self):
     try:
         validate_frames([1, 2])
     except Exception:  # pylint: disable=broad-except
         self.fail()
Пример #6
0
def blender_verification_request(
    subtask_id: str,
    source_package_path: str,
    result_package_path: str,
    output_format: str,
    scene_file: str,
    verification_deadline: int,
    frames: List[int],
    blender_crop_script: Optional[str],
) -> None:
    log(logger,
        f'Blender verification request starts.',
        f'Source_package_path {source_package_path}',
        f'Result_package_path: {result_package_path}',
        f'Output_format: {output_format}',
        f'Scene_file: {scene_file}',
        f'Frames: {frames}',
        f'Verification_deadline: {verification_deadline}',
        f'With blender_crop_script: {bool(blender_crop_script)}',
        subtask_id=subtask_id)
    validate_frames(frames)
    assert isinstance(output_format, str)
    assert isinstance(verification_deadline, int)

    output_format = output_format.upper()
    assert output_format in BlenderSubtaskDefinition.OutputFormat.__members__.keys(
    )

    # The app creates a new instance of VerificationRequest in the database
    # and a BlenderSubtaskDefinition instance associated with it.
    (verification_request, blender_subtask_definition
     ) = store_verification_request_and_blender_subtask_definition(
         subtask_id=subtask_id,
         source_package_path=source_package_path,
         result_package_path=result_package_path,
         verification_deadline=verification_deadline,
         output_format=output_format,
         scene_file=scene_file,
         blender_crop_script=blender_crop_script,
     )

    store_frames(
        blender_subtask_definition=blender_subtask_definition,
        frame_list=frames,
    )

    # If there are already UploadReports corresponding to some files, the app links them with the VerificationRequest
    # by setting the value of the foreign key in UploadReport.
    for path in [source_package_path, result_package_path]:
        UploadReport.objects.select_for_update().filter(
            path=path,
            verification_request=None,
        ).update(verification_request=verification_request)

    # The app checks if files indicated by source_package_path
    # and result_package_path in the VerificationRequest have reports.
    if (verification_request.upload_reports.filter(
            path=verification_request.source_package_path).exists()
            and verification_request.upload_reports.filter(
                path=verification_request.result_package_path).exists()):
        log(logger,
            'All expected files have been uploaded',
            f'Result package path: {verification_request.result_package_path}'
            f'Source package path: {verification_request.source_package_path}',
            subtask_id=subtask_id)
        # If all expected files have been uploaded, the app sends upload_finished task to the work queue.
        tasks.upload_finished.delay(verification_request.subtask_id)

        verification_request.upload_finished = True
        verification_request.full_clean()
        verification_request.save()