Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REST API wrapper for the processor #884

Closed
wants to merge 62 commits into from
Closed

Conversation

tdoan2010
Copy link
Contributor

@tdoan2010 tdoan2010 commented Jul 5, 2022

Description

This pull request provides the REST API wrapper for the processor. Instead of "one-shot mode", the processor now can be started as a server. There are 2 ways to start the processor:

1. Use processor name. This is the recommended way to start the Pythonic processor as a server.

# Syntax
<processor-name> --address=IP:PORT:MONGO_URL

# Example
$ ocrd-dummy --address=0.0.0.0:80:mongodb://localhost:27017

2. Use ocrd tool. This approach is for non-Python processor.

# Syntax
ocrd processing-server <processor-name> --address=IP:PORT:MONGO_URL

# Example
$ ocrd processing-server ocrd-dummy --address=0.0.0.0:80:mongodb://localhost:27017

Options

  1. processor-name: executable name of the processor
  2. --address: it has 3 parts, separated by colon, IP:PORT:MONGO_URL, where
    1. IP: the IP address that the server should listen on.
    2. PORT: the port that the server should listen on.
    3. MONGO_URL: the full connection string to a running Mongo database instance.

@tdoan2010 tdoan2010 requested review from kba and bertsky July 5, 2022 13:50
ocrd/ocrd/cli/server.py Outdated Show resolved Hide resolved
ocrd/ocrd/cli/server.py Outdated Show resolved Hide resolved
ocrd/ocrd/cli/server.py Outdated Show resolved Hide resolved
ocrd/ocrd/decorators/__init__.py Outdated Show resolved Hide resolved
ocrd/ocrd/decorators/__init__.py Outdated Show resolved Hide resolved
ocrd/ocrd/processor/helpers.py Outdated Show resolved Hide resolved
ocrd/ocrd/processor/helpers.py Outdated Show resolved Hide resolved
ocrd/ocrd/processor/helpers.py Outdated Show resolved Hide resolved
path: str
description: Optional[str] = None
input_file_grps: List[str]
output_file_grps: Optional[List[str]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is output_file_grp optional but input_file_grps is not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a case when a processor can run without input file groups?

ocrd/ocrd/server/models/job.py Show resolved Hide resolved
@joschrew
Copy link
Contributor

joschrew commented Nov 9, 2022

Hi, I am/was not able to call a processing server running for ocrd-olena-binarize (a bashlib processor). I think it is because of a bug in the processing server in helpers.py in function run_cli_from_api. In line 196 and 197, run_cli is called with mets_url=''`` which should be changed to mets_url=workspace.mets_target` or at least that resolved my problem.
To reproduce I did nothing special, just run the server as described and call it as described.

@tdoan2010
Copy link
Contributor Author

@joschrew thank you for your comment. I pushed the fix as you suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants