ocrd_network.processing_server module

class ocrd_network.processing_server.ProcessingServer(config_path: str, host: str, port: int)[source]

Bases: FastAPI

FastAPI app to make ocr-d processor calls

The Processing-Server receives calls conforming to the ocr-d webapi regarding the processing part. It can run ocrd-processors and provides endpoints to discover processors and watch the job status. The Processing-Server does not execute the processors itself but starts up a queue and a database to delegate the calls to processing workers. They are started by the Processing-Server and the communication goes through the queue.

start() None[source]

deploy agents (db, queue, workers) and start the processing server with uvicorn

async on_startup()[source]
async on_shutdown() None[source]
  • hosts and pids should be stored somewhere

  • ensure queue is empty or processor is not currently running

  • connect to hosts and kill pids

async stop_deployed_agents() None[source]
connect_publisher(enable_acks: bool = True) None[source]
create_message_queues() None[source]

Create the message queues based on the occurrence of workers.name in the config file.

static create_processing_message(job: DBProcessorJob) OcrdProcessingMessage[source]
check_if_queue_exists(processor_name)[source]
query_ocrd_tool_json_from_server(processor_name)[source]
async push_processor_job(processor_name: str, data: PYJobInput) PYJobOutput[source]
async push_to_processing_queue(processor_name: str, processing_message: OcrdProcessingMessage)[source]
async push_to_processor_server(processor_name: str, processor_server_url: str, job_input: PYJobInput) PYJobOutput[source]
async get_processor_job(processor_name: str, job_id: str) PYJobOutput[source]
async get_processor_job_log(processor_name: str, job_id: str) FileResponse[source]
async remove_from_request_cache(result_message: PYResultMessage)[source]
async get_processor_info(processor_name) Dict[source]

Return a processor’s ocrd-tool.json

async list_processors() List[str][source]
async task_sequence_to_processing_jobs(tasks: List[ProcessorTask], mets_path: str, page_id: str, agent_type: str = 'worker') List[PYJobOutput][source]
async run_workflow(workflow: UploadFile, mets_path: str, agent_type: str = 'worker', page_id: str | None = None, page_wise: bool = False, workflow_callback_url: str | None = None) PYWorkflowJobOutput[source]
async get_workflow_info(workflow_job_id) Dict[source]

Return list of a workflow’s processor jobs