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

Refactor network module - prepare it for easier sub-module testing #1191

Merged
merged 122 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from 99 commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
6afc982
fix shadow name config
MehmedGIT Feb 13, 2024
1126c4d
remove unnecessary params
MehmedGIT Feb 13, 2024
1b2bf19
refine exceptions
MehmedGIT Feb 13, 2024
6f798e4
refine imports
MehmedGIT Feb 13, 2024
3aee09e
remove unnecessary code
MehmedGIT Feb 13, 2024
30809fb
fix processor server
MehmedGIT Feb 13, 2024
4084129
move expand pages
MehmedGIT Feb 13, 2024
ef9264f
simplify verifications
MehmedGIT Feb 13, 2024
e382ca5
improve server cache formatting
MehmedGIT Feb 13, 2024
1cba489
refactor workflow endpoint
MehmedGIT Feb 14, 2024
2147c29
fileGrp -> file_group
MehmedGIT Feb 15, 2024
377464d
simplify run workflow method
MehmedGIT Feb 15, 2024
ca22496
http exception wrapper
MehmedGIT Feb 15, 2024
c48fe0c
greatly refactor deployer, agents, services
MehmedGIT Feb 16, 2024
41c92d3
further refactor, fix broken hosts
MehmedGIT Feb 17, 2024
b822f03
change deployer location
MehmedGIT Feb 17, 2024
75784d1
fix weird spacing in messages
MehmedGIT Feb 17, 2024
80ff855
get rid of extra RMQ connection
MehmedGIT Feb 17, 2024
4871aa2
improve config parsing
MehmedGIT Feb 17, 2024
cb48505
refactor deployer mets server
MehmedGIT Feb 17, 2024
ecb9afe
get rid of leftovers
MehmedGIT Feb 17, 2024
e4e9bfc
fix broken connections
MehmedGIT Feb 17, 2024
60399c5
fix typo
MehmedGIT Feb 17, 2024
55654f8
fix circular imports, move to constants
MehmedGIT Feb 17, 2024
bc1f007
revert some changes
MehmedGIT Feb 17, 2024
fdd34be
fix typing
MehmedGIT Feb 17, 2024
57c2568
add extra filter catcher
MehmedGIT Feb 17, 2024
b3c609a
update validators
MehmedGIT Feb 17, 2024
f4b7b69
more verbose error print
MehmedGIT Feb 17, 2024
28f359e
fix typing
MehmedGIT Feb 17, 2024
fb38c56
update the example schema
MehmedGIT Feb 17, 2024
588b017
increase DB timeout
MehmedGIT Feb 17, 2024
540f4d7
fix the weird bug
MehmedGIT Feb 17, 2024
0f37387
simplify ocrd tool method
MehmedGIT Feb 19, 2024
a65629f
reorder and group endpoints
MehmedGIT Feb 19, 2024
85eccbd
refine processing server methods
MehmedGIT Feb 19, 2024
d717c2a
logging.py -> logging_utils.py
MehmedGIT Feb 19, 2024
dee8c78
enum for ServerApiTags
MehmedGIT Feb 19, 2024
fe8b05f
improve wf error message
MehmedGIT Feb 19, 2024
4dfd729
refine log file formatter
MehmedGIT Feb 19, 2024
59e14b1
resolve most of the warnings
MehmedGIT Feb 19, 2024
0cb258e
another portion of improvements
MehmedGIT Feb 19, 2024
63b2d03
group integration tests
MehmedGIT Feb 20, 2024
2acfe69
add first module tests
MehmedGIT Feb 20, 2024
178031e
run module tests in ci cd
MehmedGIT Feb 20, 2024
922a548
adapt name of the workflow
MehmedGIT Feb 20, 2024
f28bfd0
ign integration tests in module tests
MehmedGIT Feb 20, 2024
a64b690
improve output
MehmedGIT Feb 23, 2024
7ffd9ac
fix logging dirs
MehmedGIT Feb 23, 2024
2d64613
adapt tests
MehmedGIT Feb 23, 2024
8fe9fa4
add module tests for page caching
MehmedGIT Mar 5, 2024
d041471
add first requests cache test
MehmedGIT Mar 5, 2024
3dc8bc7
fix list typo
MehmedGIT Mar 5, 2024
9c2fc34
test cached requests
MehmedGIT Mar 6, 2024
96e6c87
add processing request cache tests
MehmedGIT Mar 12, 2024
c813719
extend Makefile help
MehmedGIT Mar 12, 2024
36bd0f5
fix missing index
MehmedGIT Mar 12, 2024
1a30090
add fixtures to conftest
MehmedGIT Mar 12, 2024
7c2c4f8
fix: workspace_key -> path_to_mets
MehmedGIT Mar 12, 2024
afee8cc
reduce code: add jobs list fixture
MehmedGIT Mar 12, 2024
050279f
fix test typo
MehmedGIT Mar 12, 2024
a4a58a6
transform: fixture to method
MehmedGIT Mar 12, 2024
831c4cd
append models without db
MehmedGIT Mar 12, 2024
a7edb36
change fixture scope
MehmedGIT Mar 12, 2024
c6788c9
fix duplicate id errors
MehmedGIT Mar 12, 2024
47708af
move: fixture to method
MehmedGIT Mar 12, 2024
e827f96
fix all async tests
MehmedGIT Mar 12, 2024
60078bf
fix test: remove succeeded from cache
MehmedGIT Mar 12, 2024
f391567
add tests for process helpers
MehmedGIT Mar 13, 2024
cc936d9
add param validator tests
MehmedGIT Mar 13, 2024
458b167
add processing worker test
MehmedGIT Mar 13, 2024
fdf359a
order integration tests
MehmedGIT Mar 13, 2024
7405357
fix the weird buggit status!
MehmedGIT Mar 13, 2024
b7b916e
build assets for network module tests
MehmedGIT Mar 14, 2024
30d486e
temporarily disable macos
MehmedGIT Mar 14, 2024
9ad8e04
remove duplication - create queue
MehmedGIT Mar 14, 2024
90e8770
reduce amount of lines used
MehmedGIT Mar 14, 2024
a5b055d
refine server cache lines
MehmedGIT Mar 14, 2024
d2e4650
improve runtime_data
MehmedGIT Mar 14, 2024
a114f5c
fix resolve server url
MehmedGIT Mar 14, 2024
1c01f3a
transfer resolve url responsibility
MehmedGIT Mar 14, 2024
5cc209d
improve deployer: find matching
MehmedGIT Mar 14, 2024
5df3b6c
refine integration tests
MehmedGIT Mar 14, 2024
cabd739
disable local checks for PS integration
MehmedGIT Mar 14, 2024
828003a
fix ocrd result message validator
MehmedGIT Mar 14, 2024
7e076d6
makefile: fail when on cicd
MehmedGIT Mar 14, 2024
027326c
add bash lib processor test
MehmedGIT Mar 14, 2024
7e1ab83
fix result message: state -> status
MehmedGIT Mar 14, 2024
8e72d3f
remove '' instead of None in worker
MehmedGIT Mar 14, 2024
bfa4a10
+x mode to bashlib cp processor
MehmedGIT Mar 14, 2024
05567ab
disable module bashlib test
MehmedGIT Mar 14, 2024
baa5ca1
return '' instead of None
MehmedGIT Mar 14, 2024
102b3c1
fix: state -> status
MehmedGIT Mar 14, 2024
9d8a264
fix: status -> state everywhere
MehmedGIT Mar 14, 2024
09c9e59
fix test: status -> state
MehmedGIT Mar 14, 2024
3bc692c
more missed: status -> state
MehmedGIT Mar 14, 2024
e54adfb
fix result message
MehmedGIT Mar 14, 2024
299bb2b
fix result message schema
MehmedGIT Mar 14, 2024
da4f607
Change renamend ocrd env-variable in readme too
joschrew Mar 25, 2024
8a137e8
add missed call in processor server
MehmedGIT Mar 26, 2024
0d3def2
fix spacing
MehmedGIT Mar 26, 2024
0345829
Update README.md
MehmedGIT Mar 26, 2024
911724b
Update src/ocrd_network/constants.py
MehmedGIT Mar 26, 2024
61c7ad8
move rmq uri pattern to const
MehmedGIT Mar 26, 2024
81939bc
make coverage: omit generateDS code
kba Feb 15, 2024
e9f5800
ocrd_mets: type hints
bertsky Feb 23, 2024
459127a
ocrd_mets: forgot import Tuple
bertsky Feb 23, 2024
b1b8fbf
ocrd_mets.py: cannot use defined class in type hints
bertsky Feb 23, 2024
afb25f0
ocrd_mets.py: forgot Any
bertsky Feb 23, 2024
4169579
test_ocrd_mets.py: also test empty for_fileIds list
bertsky Feb 23, 2024
f563757
ocrd_mets.py: fix get_physical_pages_for
bertsky Feb 23, 2024
76293a9
get_physical_pages_for: if for_fileIds is empty list, return empty list
bertsky Feb 23, 2024
0041ada
OcrdMets.set_physical_page_for_file: fix cached case
bertsky Mar 1, 2024
e9b23ac
OcrdMets: simplify
bertsky Mar 1, 2024
a3720e0
:package: v2.63.1
kba Mar 5, 2024
da4fb66
:package: v2.63.2
kba Mar 5, 2024
77b0f9b
run test-logging in a temp dir to avoid "logging" package being shadowed
kba Apr 8, 2024
5a1f501
put ocrd-tool.json for bashlib_cp_processor in separate file
kba Apr 8, 2024
cfb26f1
enable bashlib test in test_modules_process_helpers
kba Apr 8, 2024
9c08d85
forgot to add the renamed ocrd-cp processor
kba Apr 8, 2024
9319743
merge master
kba Apr 8, 2024
7851f8a
network-testing: workflow_dispatch
kba Apr 8, 2024
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run ocrd network integration tests
name: ocrd network module and integration tests

on:
push:
Expand Down Expand Up @@ -49,10 +49,12 @@ jobs:
run: |
brew install docker docker-compose
colima start
- name: Test network integration with pytest
- name: Run network modules tests with pytest
run: make network-module-test
- name: Run network integration tests with pytest
run: |
if [[ "${{ matrix.os }}" == "macos"* ]];then
make integration-test DOCKER_COMPOSE=docker-compose
make network-integration-test-cicd DOCKER_COMPOSE=docker-compose
else
make integration-test
make network-integration-test-cicd
fi
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
os:
- ubuntu-22.04
- ubuntu-20.04
- macos-latest
# - macos-latest

steps:
- uses: actions/checkout@v3
Expand Down
18 changes: 16 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ help:
@echo " docker Build docker image"
@echo " docker-cuda Build docker image for GPU / CUDA"
@echo " pypi Build wheels and source dist and twine upload them"
@echo " ocrd network tests"
@echo " network-module-test Run all ocrd_network module tests"
@echo " network-integration-test Run all ocrd_network integration tests (docker and docker compose required)"
@echo ""
@echo " Variables"
@echo ""
Expand Down Expand Up @@ -219,10 +222,21 @@ test: assets
$(TESTDIR)
cd ocrd_utils ; $(PYTHON) -m pytest --continue-on-collection-errors -k TestLogging -k TestDecorators $(TESTDIR)

network-module-test: assets
$(PYTHON) \
-m pytest $(PYTEST_ARGS) -k 'test_modules_' -v --durations=10\
--ignore-glob="$(TESTDIR)/network/test_integration_*.py" \
$(TESTDIR)/network

INTEGRATION_TEST_IN_DOCKER = docker exec core_test
integration-test:
network-integration-test:
$(DOCKER_COMPOSE) --file tests/network/docker-compose.yml up -d
-$(INTEGRATION_TEST_IN_DOCKER) pytest -k 'test_integration_' -v
$(DOCKER_COMPOSE) --file tests/network/docker-compose.yml down --remove-orphans

network-integration-test-cicd:
$(DOCKER_COMPOSE) --file tests/network/docker-compose.yml up -d
-$(INTEGRATION_TEST_IN_DOCKER) pytest -k 'test_rmq or test_db or test_processing_server' -v
$(INTEGRATION_TEST_IN_DOCKER) pytest -k 'test_integration_' -v
$(DOCKER_COMPOSE) --file tests/network/docker-compose.yml down --remove-orphans

benchmark:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ A minimal [OCR-D processor](https://ocr-d.de/en/user_guide#using-the-ocr-d-proce

Almost all behaviour of the OCR-D/core software is configured via CLI options and flags, which can be listed with the `--help` flag that all CLI support.

Some parts of the software are configured via environement variables:
Some parts of the software are configured via environment variables:

* `OCRD_METS_CACHING`: If set to `true`, access to the METS file is cached, speeding in-memory search and modification.
* `OCRD_PROFILE`: This variable configures the built-in CPU and memory profiling. If empty, no profiling is done. Otherwise expected to contain any of the following tokens:
Expand All @@ -105,7 +105,7 @@ Some parts of the software are configured via environement variables:
* `OCRD_NETWORK_SERVER_ADDR_PROCESSING`: Default address of Processing Server to connect to (for `ocrd network client processing`).
* `OCRD_NETWORK_SERVER_ADDR_WORKFLOW`: Default address of Workflow Server to connect to (for `ocrd network client workflow`).
* `OCRD_NETWORK_SERVER_ADDR_WORKSPACE`: Default address of Workspace Server to connect to (for `ocrd network client workspace`).
* `OCRD_NETWORK_WORKER_QUEUE_CONNECT_ATTEMPTS`: Number of attempts for a worker to create its queue. Helpfull if the rabbitmq-server needs time to be fully started.
* `OCRD_NETWORK_RABBITMQ_CLIENT_CONNECT_ATTEMPTS`: Number of attempts for a worker to create its queue. Helpfull if the rabbitmq-server needs time to be fully started.
MehmedGIT marked this conversation as resolved.
Show resolved Hide resolved


## Packages
Expand Down
2 changes: 1 addition & 1 deletion src/ocrd/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
\b
{config.describe('OCRD_NETWORK_SERVER_ADDR_WORKSPACE')}
\b
{config.describe('OCRD_NETWORK_WORKER_QUEUE_CONNECT_ATTEMPTS')}
{config.describe('OCRD_NETWORK_RABBITMQ_CLIENT_CONNECT_ATTEMPTS')}
\b
{config.describe('OCRD_PROFILE_FILE')}
\b
Expand Down
1 change: 0 additions & 1 deletion src/ocrd/cli/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"""

import click
import logging
from ocrd_utils import initLogging
from ocrd_network.cli import (
client_cli,
Expand Down
14 changes: 8 additions & 6 deletions src/ocrd/decorators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
set_json_key_value_overrides,
)
from ocrd_validators import WorkspaceValidator
from ocrd_network import ProcessingWorker, ProcessorServer, NETWORK_AGENT_SERVER, NETWORK_AGENT_WORKER
from ocrd_network import ProcessingWorker, ProcessorServer, AgentType

from ..resolver import Resolver
from ..processor.base import run_processor
Expand All @@ -20,7 +20,7 @@
from .ocrd_cli_options import ocrd_cli_options
from .mets_find_options import mets_find_options

SUBCOMMANDS = [NETWORK_AGENT_WORKER, NETWORK_AGENT_SERVER]
SUBCOMMANDS = [AgentType.PROCESSING_WORKER, AgentType.PROCESSOR_SERVER]


def ocrd_cli_wrap_processor(
Expand Down Expand Up @@ -142,19 +142,19 @@ def check_and_run_network_agent(ProcessorClass, subcommand: str, address: str, d
if not database:
raise ValueError(f"Option '--database' is invalid for subcommand {subcommand}")

if subcommand == NETWORK_AGENT_SERVER:
if subcommand == AgentType.PROCESSOR_SERVER:
if not address:
raise ValueError(f"Option '--address' required for subcommand {subcommand}")
if queue:
raise ValueError(f"Option '--queue' invalid for subcommand {subcommand}")
if subcommand == NETWORK_AGENT_WORKER:
if subcommand == AgentType.PROCESSING_WORKER:
if address:
raise ValueError(f"Option '--address' invalid for subcommand {subcommand}")
if not queue:
raise ValueError(f"Option '--queue' required for subcommand {subcommand}")

processor = ProcessorClass(workspace=None)
if subcommand == NETWORK_AGENT_WORKER:
if subcommand == AgentType.PROCESSING_WORKER:
processing_worker = ProcessingWorker(
rabbitmq_addr=queue,
mongodb_addr=database,
Expand All @@ -166,7 +166,7 @@ def check_and_run_network_agent(ProcessorClass, subcommand: str, address: str, d
processing_worker.connect_consumer()
# Start consuming from the queue with name `processor_name`
processing_worker.start_consuming()
elif subcommand == NETWORK_AGENT_SERVER:
elif subcommand == AgentType.PROCESSOR_SERVER:
# TODO: Better validate that inside the ProcessorServer itself
host, port = address.split(':')
processor_server = ProcessorServer(
Expand All @@ -175,4 +175,6 @@ def check_and_run_network_agent(ProcessorClass, subcommand: str, address: str, d
processor_class=ProcessorClass,
)
processor_server.run_server(host=host, port=int(port))
else:
raise ValueError(f"Unknown network agent type, must be one of: {SUBCOMMANDS}")
sys.exit(0)
4 changes: 2 additions & 2 deletions src/ocrd/decorators/ocrd_cli_options.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import click
from click import option, Path, group, command, argument
from ocrd_utils import DEFAULT_METS_BASENAME
from ocrd_network import NETWORK_AGENT_SERVER, NETWORK_AGENT_WORKER
from ocrd_network import AgentType
from .parameter_option import parameter_option, parameter_override_option
from .loglevel_option import loglevel_option
from ocrd_network import (
Expand Down Expand Up @@ -57,7 +57,7 @@ def cli(mets_url):
# subcommands. So we have to work around that by creating a
# pseudo-subcommand handled in ocrd_cli_wrap_processor
argument('subcommand', nargs=1, required=False,
type=click.Choice([NETWORK_AGENT_WORKER, NETWORK_AGENT_SERVER])),
type=click.Choice([AgentType.PROCESSING_WORKER, AgentType.PROCESSOR_SERVER])),
]
for param in params:
param(f)
Expand Down
9 changes: 3 additions & 6 deletions src/ocrd_network/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from .client import Client
from .constants import NETWORK_AGENT_SERVER, NETWORK_AGENT_WORKER
from .constants import AgentType, JobState
from .processing_server import ProcessingServer
from .processing_worker import ProcessingWorker
from .processor_server import ProcessorServer
from .param_validators import (
DatabaseParamType,
ServerAddressParamType,
QueueServerParamType
)
from .param_validators import DatabaseParamType, ServerAddressParamType, QueueServerParamType
from .server_cache import CacheLockedPages, CacheProcessingRequests
8 changes: 2 additions & 6 deletions src/ocrd_network/cli/client.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import click
from typing import Optional

from ocrd_utils import DEFAULT_METS_BASENAME

from ocrd.decorators import (
parameter_option,
parameter_override_option
)
from ocrd.decorators import parameter_option
from ocrd_network import Client
from ocrd_utils import DEFAULT_METS_BASENAME


@click.group('client')
Expand Down
5 changes: 1 addition & 4 deletions src/ocrd_network/cli/processing_server.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import click
from .. import (
ProcessingServer,
ServerAddressParamType
)
from ocrd_network import ProcessingServer, ServerAddressParamType


@click.command('processing-server')
Expand Down
7 changes: 1 addition & 6 deletions src/ocrd_network/cli/processing_worker.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import click
from ocrd_utils import get_ocrd_tool_json

from .. import (
DatabaseParamType,
ProcessingWorker,
QueueServerParamType
)
from ocrd_network import DatabaseParamType, ProcessingWorker, QueueServerParamType


@click.command('processing-worker')
Expand Down
10 changes: 3 additions & 7 deletions src/ocrd_network/cli/processor_server.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import click
from .. import (
DatabaseParamType,
ProcessorServer,
ServerAddressParamType
)
from ocrd_network import DatabaseParamType, ProcessorServer, ServerAddressParamType


@click.command('processor-server')
Expand All @@ -23,12 +19,12 @@ def processor_server_cli(processor_name: str, address: str, database: str):
(standalone REST API OCR-D processor)
"""
try:
# TODO: Better validate that inside the ProcessorServer itself
# Note, the address is already validated with the type field
host, port = address.split(':')
processor_server = ProcessorServer(
mongodb_addr=database,
processor_name=processor_name,
processor_class=None, # For readability purposes assigned here
processor_class=None # For readability purposes assigned here
)
processor_server.run_server(host=host, port=int(port))
except Exception as e:
Expand Down
35 changes: 17 additions & 18 deletions src/ocrd_network/client.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,37 @@
import json
import requests
from json import dumps, loads
from requests import post as requests_post
from ocrd_utils import config, getLogger, LOG_FORMAT

from ocrd_utils import config
from .constants import NETWORK_PROTOCOLS


# TODO: This is just a conceptual implementation and first try to
# trigger further discussions on how this should look like.
class Client:
def __init__(
self,
server_addr_processing: str = config.OCRD_NETWORK_SERVER_ADDR_PROCESSING,
server_addr_workflow: str = config.OCRD_NETWORK_SERVER_ADDR_WORKFLOW,
server_addr_workspace: str = config.OCRD_NETWORK_SERVER_ADDR_WORKSPACE,
self,
server_addr_processing: str = config.OCRD_NETWORK_SERVER_ADDR_PROCESSING,
server_addr_workflow: str = config.OCRD_NETWORK_SERVER_ADDR_WORKFLOW,
server_addr_workspace: str = config.OCRD_NETWORK_SERVER_ADDR_WORKSPACE
):
self.log = getLogger(f"ocrd_network.client")
self.server_addr_processing = server_addr_processing
self.server_addr_workflow = server_addr_workflow
self.server_addr_workspace = server_addr_workspace

def send_processing_request(self, processor_name: str, req_params: dict):
verify_server_protocol(self.server_addr_processing)
req_url = f'{self.server_addr_processing}/processor/{processor_name}'
req_url = f"{self.server_addr_processing}/processor/{processor_name}"
req_headers = {"Content-Type": "application/json; charset=utf-8"}
req_json = json.loads(json.dumps(req_params))

print(f'Sending processing request to: {req_url}')
response = requests.post(url=req_url, headers=req_headers, json=req_json)
req_json = loads(dumps(req_params))
self.log.info(f"Sending processing request to: {req_url}")
self.log.debug(req_json)
response = requests_post(url=req_url, headers=req_headers, json=req_json)
return response.json()


def verify_server_protocol(address: str):
protocol_matched = False
for protocol in ['http://', 'https://']:
for protocol in NETWORK_PROTOCOLS:
if address.startswith(protocol):
protocol_matched = True
break
if not protocol_matched:
raise ValueError(f'Wrong/Missing protocol in the server address: {address}')
return
raise ValueError(f"Wrong/Missing protocol in the server address: {address}, must be one of: {NETWORK_PROTOCOLS}")
61 changes: 59 additions & 2 deletions src/ocrd_network/constants.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,59 @@
NETWORK_AGENT_SERVER = 'server'
NETWORK_AGENT_WORKER = 'worker'
from enum import Enum

DOCKER_IMAGE_MONGO_DB = "mongo"
DOCKER_IMAGE_RABBIT_MQ = "rabbitmq:3.12-management"
# These feature flags are required by default to use the newer version
DOCKER_RABBIT_MQ_FEATURES = "quorum_queue,implicit_default_bindings,classic_mirrored_queue_version"

NETWORK_PROTOCOLS = ["http://", "https://"]
OCRD_ALL_JSON_TOOLS_URL = "https://ocr-d.de/js/ocrd-all-tool.json"
SERVER_ALL_PAGES_PLACEHOLDER = "all_pages"

MehmedGIT marked this conversation as resolved.
Show resolved Hide resolved

class AgentType(str, Enum):
PROCESSING_WORKER = "worker"
PROCESSOR_SERVER = "server"


class DeployType(str, Enum):
# Deployed by the Processing Server config file
DOCKER = "docker"
NATIVE = "native"
# Deployed through a registration endpoint of the Processing Server
# TODO: That endpoint is still not implemented
EXTERNAL = "external"


# TODO: Make the states uppercase
class JobState(str, Enum):
# The processing job is cached inside the Processing Server requests cache
cached = "CACHED"
# The processing job was cancelled due to failed dependencies
cancelled = "CANCELLED"
# Processing job failed
failed = "FAILED"
# The processing job is queued inside the RabbitMQ
queued = "QUEUED"
# Processing job is currently running in a Worker or Processor Server
running = "RUNNING"
# Processing job finished successfully
success = "SUCCESS"
# Processing job has not been assigned yet
unset = "UNSET"


class NetworkLoggingDirs(str, Enum):
METS_SERVERS = "mets_servers"
PROCESSING_JOBS = "processing_jobs"
PROCESSING_SERVERS = "processing_servers"
PROCESSING_WORKERS = "processing_workers"
PROCESSOR_SERVERS = "processor_servers"


class ServerApiTags(str, Enum):
ADMIN = "admin"
DISCOVERY = "discovery"
PROCESSING = "processing"
TOOLS = "tools"
WORKFLOW = "workflow"
WORKSPACE = "workspace"
Loading
Loading