How to use the ocrd.task_sequence.ProcessorTask.parse function in ocrd

To help you get started, we’ve selected a few ocrd examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OCR-D / core / tests / test_task_sequence.py View on Github external
def test_422(self):
        """
        # OCR-D/core#422
        """
        resolver = Resolver()
        with TemporaryDirectory() as tempdir:
            workspace = resolver.workspace_from_url(assets.path_to('kant_aufklaerung_1784/data/mets.xml'), dst_dir=tempdir)
            validate_tasks([ProcessorTask.parse(x) for x in [
                "sample-processor -I OCR-D-IMG       -O OCR-D-SEG-BLOCK",
                "sample-processor -I OCR-D-SEG-BLOCK -O OCR-D-SEG-LINE",
                "sample-processor -I OCR-D-SEG-LINE  -O OCR-D-SEG-WORD",
                "sample-processor -I OCR-D-SEG-WORD  -O OCR-D-OCR-TESS",
            ]], workspace)
github OCR-D / core / tests / test_task_sequence.py View on Github external
def test_parse_unknown(self):
        with self.assertRaisesRegex(Exception, 'Failed parsing task description'):
            ProcessorTask.parse('sample-processor -x wrong wrong wrong')
github OCR-D / core / tests / test_task_sequence.py View on Github external
def test_required_param(self):
        task = ProcessorTask.parse('sample-processor-required-param -I IN -O OUT')
        with self.assertRaisesRegex(Exception, "'param1' is a required property"):
            task.validate()
github OCR-D / core / tests / test_task_sequence.py View on Github external
def test_fail_validate_executable(self):
        task = ProcessorTask.parse('no-such-processor -I IN')
        with self.assertRaisesRegex(Exception, 'Executable not found in '):
            task.validate()
github OCR-D / core / tests / test_task_sequence.py View on Github external
def test_validate_sequence(self):
        resolver = Resolver()
        with TemporaryDirectory() as tempdir:
            workspace = resolver.workspace_from_url(assets.path_to('kant_aufklaerung_1784/data/mets.xml'), dst_dir=tempdir)
            params_path = Path(tempdir, 'params.json')
            params_path.write_text('{"param1": true}')

            with self.assertRaisesRegex(Exception, "Input file group not contained in METS or produced by previous steps: FOO'"):
                validate_tasks([ProcessorTask.parse(x) for x in [
                    'sample-processor-required-param -I OCR-D-IMG -O OUT1 -p %s' % params_path,
                    'sample-processor-required-param -I FOO -O OUT2 -p %s' % params_path
                ]], workspace)

            with self.assertRaisesRegex(Exception, "Input fileGrp.@USE='IN'. not in METS!"):
                validate_tasks([ProcessorTask.parse(x) for x in [
                    'sample-processor-required-param -I IN -O OUT1 -p %s' % params_path,
                ]], workspace)
github OCR-D / core / tests / test_task_sequence.py View on Github external
def test_parse_parameter_none(self):
        task_str = 'sample-processor -I IN -O OUT1,OUT2'
        task = ProcessorTask.parse(task_str)
        self.assertEqual(task.parameter_path, None)
        self.assertEqual(str(task), task_str)
github OCR-D / core / tests / test_task_sequence.py View on Github external
def test_parse_ok(self):
        task_str = 'sample-processor -I IN -O OUT -p /path/to/param.json'
        task = ProcessorTask.parse(task_str)
        self.assertEqual(task.executable, 'ocrd-sample-processor')
        self.assertEqual(task.input_file_grps, ['IN'])
        self.assertEqual(task.output_file_grps, ['OUT'])
        self.assertEqual(task.parameter_path, '/path/to/param.json')
        self.assertEqual(str(task), task_str)