Skip to content

Commit

Permalink
Merge remote-tracking branch 'github/cli-decorator-import-network'
Browse files Browse the repository at this point in the history
  • Loading branch information
kba committed Oct 10, 2024
2 parents e5cdbe9 + cb8d787 commit 539f5d7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/ocrd/decorators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
redirect_stderr_and_stdout_to_file,
)
from ocrd_validators import WorkspaceValidator
from ocrd_network import ProcessingWorker, ProcessorServer, AgentType

from ..resolver import Resolver
from ..processor.base import ResourceNotFoundError, run_processor
Expand All @@ -23,8 +22,6 @@
from .ocrd_cli_options import ocrd_cli_options
from .mets_find_options import mets_find_options

SUBCOMMANDS = [AgentType.PROCESSING_WORKER, AgentType.PROCESSOR_SERVER]


def ocrd_cli_wrap_processor(
processorClass,
Expand Down Expand Up @@ -66,11 +63,9 @@ def ocrd_cli_wrap_processor(
list_resources=list_resources
)
sys.exit()
if subcommand:
if subcommand or address or queue or database:
# Used for checking/starting network agents for the WebAPI architecture
check_and_run_network_agent(processorClass, subcommand, address, database, queue)
elif address or queue or database:
raise ValueError(f"Subcommand options --address --queue and --database are only valid for subcommands: {SUBCOMMANDS}")

initLogging()

Expand Down Expand Up @@ -164,6 +159,11 @@ def goexit():
def check_and_run_network_agent(ProcessorClass, subcommand: str, address: str, database: str, queue: str):
"""
"""
from ocrd_network import ProcessingWorker, ProcessorServer, AgentType
SUBCOMMANDS = [AgentType.PROCESSING_WORKER, AgentType.PROCESSOR_SERVER]

if not subcommand:
raise ValueError(f"Subcommand options --address --queue and --database are only valid for subcommands: {SUBCOMMANDS}")
if subcommand not in SUBCOMMANDS:
raise ValueError(f"SUBCOMMAND can only be one of {SUBCOMMANDS}")

Expand Down

0 comments on commit 539f5d7

Please sign in to comment.