Skip to content

Commit

Permalink
add: check processing job log file
Browse files Browse the repository at this point in the history
  • Loading branch information
MehmedGIT committed Aug 13, 2024
1 parent 4d85970 commit bb3007d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/ocrd_network/cli/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, '
Expand Down
4 changes: 4 additions & 0 deletions src/ocrd_network/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)

Expand Down
6 changes: 6 additions & 0 deletions src/ocrd_network/client_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"})
Expand Down

0 comments on commit bb3007d

Please sign in to comment.