diff --git a/src/ocrd_network/cli/client.py b/src/ocrd_network/cli/client.py index ee6c29fc3b..38eb959a07 100644 --- a/src/ocrd_network/cli/client.py +++ b/src/ocrd_network/cli/client.py @@ -59,6 +59,20 @@ def processing_cli(): pass +@processing_cli.command('check-log') +@click.option('--address', + help='The address of the Processing Server. If not provided, ' + 'the "OCRD_NETWORK_SERVER_ADDR_PROCESSING" env variable is used by default') +@click.option('-j', '--processing-job-id', required=True) +def check_processing_job_status(address: Optional[str], processing_job_id: str): + """ + Check the log of a previously submitted processing job. + """ + client = Client(server_addr_processing=address) + response = client.check_job_log(job_id=processing_job_id) + print(response._content.decode(encoding='utf-8')) + + @processing_cli.command('check-status') @click.option('--address', help='The address of the Processing Server. If not provided, ' diff --git a/src/ocrd_network/client.py b/src/ocrd_network/client.py index b3872f1aaf..793d6ead89 100644 --- a/src/ocrd_network/client.py +++ b/src/ocrd_network/client.py @@ -2,6 +2,7 @@ from .client_utils import ( get_ps_deployed_processors, get_ps_deployed_processor_ocrd_tool, + get_ps_processing_job_log, get_ps_processing_job_status, get_ps_workflow_job_status, poll_job_status_till_timeout_fail_or_success, @@ -35,6 +36,9 @@ def check_deployed_processor_ocrd_tool(self, processor_name: str): return get_ps_deployed_processor_ocrd_tool( ps_server_host=self.server_addr_processing, processor_name=processor_name) + def check_job_log(self, job_id: str): + return get_ps_processing_job_log(self.server_addr_processing, processing_job_id=job_id) + def check_job_status(self, job_id: str): return get_ps_processing_job_status(self.server_addr_processing, processing_job_id=job_id) diff --git a/src/ocrd_network/client_utils.py b/src/ocrd_network/client_utils.py index 2dc2805aa0..9b924c16a4 100644 --- a/src/ocrd_network/client_utils.py +++ b/src/ocrd_network/client_utils.py @@ -41,6 +41,12 @@ def get_ps_deployed_processor_ocrd_tool(ps_server_host: str, processor_name: str return response.json() +def get_ps_processing_job_log(ps_server_host: str, processing_job_id: str): + request_url = f"{ps_server_host}/processor/log/{processing_job_id}" + response = request_get(url=request_url, headers={"accept": "application/json; charset=utf-8"}) + return response + + def get_ps_processing_job_status(ps_server_host: str, processing_job_id: str) -> str: request_url = f"{ps_server_host}/processor/job/{processing_job_id}" response = request_get(url=request_url, headers={"accept": "application/json; charset=utf-8"})