How to use the ocrd.task_sequence.ProcessorTask 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_parse_no_in(self):
        task = ProcessorTask.parse('sample-processor')
        with self.assertRaisesRegex(Exception, 'must have input file group'):
            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 / ocrd / ocrd / cli / validate.py View on Github external
def validate_process(tasks, workspace):
    '''
    Validate a sequence of tasks passable to 'ocrd process'
    '''
    if workspace:
        _inform_of_result(validate_tasks([ProcessorTask.parse(t) for t in tasks], Workspace(Resolver(), directory=workspace)))
    else:
        for t in [ProcessorTask.parse(t) for t in tasks]:
            _inform_of_result(t.validate())
github OCR-D / core / ocrd / ocrd / cli / validate.py View on Github external
def validate_process(tasks, workspace):
    '''
    Validate a sequence of tasks passable to 'ocrd process'
    '''
    if workspace:
        _inform_of_result(validate_tasks([ProcessorTask.parse(t) for t in tasks], Workspace(Resolver(), directory=workspace)))
    else:
        for t in [ProcessorTask.parse(t) for t in tasks]:
            _inform_of_result(t.validate())