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

ocrd network client: parse parameters and overrides #1270

Merged
merged 2 commits into from
Aug 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions src/ocrd_network/cli/client.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import click
from json import dumps
from typing import Optional
from typing import List, Optional, Tuple
from ocrd.decorators.parameter_option import parameter_option, parameter_override_option
from ocrd_utils import DEFAULT_METS_BASENAME
from ocrd_utils.introspect import set_json_key_value_overrides
from ocrd_utils.str import parse_json_string_or_file
from ..client import Client


Expand Down Expand Up @@ -111,8 +113,8 @@ def send_processing_job_request(
input_file_grp: str,
output_file_grp: Optional[str],
page_id: Optional[str],
parameter: Optional[dict],
parameter_override: Optional[dict],
parameter: List[str],
parameter_override: List[Tuple[str, str]],
result_queue_name: Optional[str],
callback_url: Optional[str],
# TODO: This is temporally available to toggle
Expand All @@ -133,13 +135,7 @@ def send_processing_job_request(
req_params["output_file_grps"] = output_file_grp.split(',')
if page_id:
req_params["page_id"] = page_id
if parameter:
if parameter == ['{}']:
req_params["parameters"] = {}
else:
req_params["parameters"] = parameter
if parameter_override:
req_params["parameters"] = parameter_override
req_params["parameters"] = set_json_key_value_overrides(parse_json_string_or_file(*parameter), *parameter_override)
if result_queue_name:
req_params["result_queue_name"] = result_queue_name
if callback_url:
Expand Down