Example #1
0
    def run_task(self, result_id, runjob_id, *args, **kwargs):
        runjob = RunJob.objects.get(pk=runjob_id)

        if runjob.needs_input:
            if runjob.status == RunJobStatus.RUN_ONCE_WAITING:
                self.retry(args=[result_id, runjob_id], *args, countdown=10, **kwargs)

            else:
                # This is the first time the job is running.
                taskutil.set_running(runjob)
                page_path = runjob.page.compat_file_path

                self._create_temp_neon_directory(runjob)
                mei_path = taskutil.get_input_path(runjob, result_id)
                shutil.copy(mei_path, live_mei_path(runjob))
                shutil.copy(live_mei_path(runjob), backup_mei_path(runjob))

                page_image = Image.open(page_path)
                page_image.save(compressed_image_path(runjob), quality=40)

                taskutil.set_run_once_waiting(runjob)
                self.retry(args=[result_id, runjob_id], *args, countdown=10, **kwargs)

        else:
            taskutil.set_running(runjob)
            result = taskutil.init_result(runjob)
            taskutil.save_result(result, live_mei_path(runjob))
            return str(result.uuid)
Example #2
0
    def run_task(self, result_id, runjob_id, *args, **kwargs):
        runjob = RunJob.objects.get(pk=runjob_id)
        taskutil.set_running(runjob)
        xml_filepath = taskutil.get_input_path(runjob, result_id)   # Trouble
        settings = taskutil.get_settings(runjob)

        segmented_image_path = self._get_segmented_image_path(runjob.workflow_run,
                                                              settings['segmented_image_source'],
                                                              runjob.page)
        page_order = runjob.page.page_order

        mei_document = self.process_image(segmented_image_path, xml_filepath, settings, page_order)
        result = self.save_result(runjob, mei_document)
        return str(result.uuid)
Example #3
0
    def run_task(self, result_id, runjob_id, *args, **kwargs):
        runjob = RunJob.objects.get(pk=runjob_id)
        taskutil.set_running(runjob)
        xml_filepath = taskutil.get_input_path(runjob, result_id)  # Trouble
        settings = taskutil.get_settings(runjob)

        segmented_image_path = self._get_segmented_image_path(
            runjob.workflow_run, settings['segmented_image_source'],
            runjob.page)
        page_order = runjob.page.page_order

        mei_document = self.process_image(segmented_image_path, xml_filepath,
                                          settings, page_order)
        result = self.save_result(runjob, mei_document)
        return str(result.uuid)