Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
edcf855
Dockerfile: Use virtual environment
stweil Mar 15, 2023
5c003fa
give up workaround for shapely-CUDA issue
Apr 1, 2023
2250550
rehash after pip upgrade
Apr 1, 2023
00a0f6f
keep gcc, no autoremove
Apr 1, 2023
410783f
docker-cuda: change base image, no multi-CUDA runtimes
Apr 1, 2023
de86e0f
reinstate workaround for shapely, but more robust
Apr 12, 2023
c1178f9
core-cuda: use CUDA 11.8, install cuDNN via pip and make available sy…
Apr 15, 2023
d3d54bf
core-cuda: install more CUDA libs via pip and ld.so.conf, simplify Do…
Apr 20, 2023
357e729
make install on py36: prefer binary OpenCV/Numpy via pip config inste…
Apr 20, 2023
2640b71
make install on py36: fix prefer-binary syntax
Apr 21, 2023
b3618a9
make install on py36: revert to prefer-binary via install
Apr 21, 2023
b713030
:package: v2.50.0
kba Apr 24, 2023
c0c153e
Merge branch 'master' of https://github.com/OCR-D/core into reduce-cuda
Apr 24, 2023
209fa21
Merge branch 'pr-1008' into reduce-cuda
Apr 27, 2023
a6cf5ff
core-cuda: use same CUDA libs as needed for Torch anyway
Apr 27, 2023
1da66f4
Fix mongodb credentials usage
joschrew May 10, 2023
8530bd9
Add skip_deployment flag for queue and database
joschrew May 10, 2023
b4e6576
Make deployer optionally skip mongo and rabbitmq
joschrew May 10, 2023
8da7868
Remove redundant rabbitmq availability check
joschrew May 11, 2023
f749c24
Correct spelling
joschrew May 15, 2023
f5e212a
docker-cuda: rewrite…
Jun 1, 2023
85a5d16
docker-cuda: improve (reduce size) again…
Jun 2, 2023
47eff22
remove out-dated processor resources
Jun 2, 2023
12e781c
Revert "Merge remote-tracking branch 'hnesk/no-more-pkg_resources' in…
Jun 2, 2023
bac1a45
make help: improve description
Jun 2, 2023
95062b0
:memo: changelog
kba Jun 7, 2023
c636f2c
:package: v2.51.0
kba Jun 7, 2023
8c7b761
docker-image: reuse local ghcr.io image instead of docker.io
bertsky Jun 7, 2023
4bfac5e
disable logging tests until properly fixed
kba Jun 7, 2023
ca5f342
test_workspace_bagger: use ocr-d.de instead of google.com for testing
kba Jun 7, 2023
3f05745
test bashlib: /usr/bin/env bash instead of /bin/bash
kba Jun 8, 2023
af38a2c
debug gh actions
kba Jun 8, 2023
c63ab4c
readme: remove dockerhub/travis badge, add GH actions badge
kba Jun 8, 2023
555dece
ci: disable upterm for gh actions
kba Jun 8, 2023
d76409e
docker-cuda: move recipe to reusable makefile target deps-cuda
Jun 8, 2023
2538979
make deps-cuda: Set MAMBA_ROOT_PREFIX to CONDA_PREFIX
kba Jun 9, 2023
79ad301
:memo: changelog
kba Jun 9, 2023
6708624
Merge pull request #1055 from bertsky/deps-cuda
kba Jun 9, 2023
821f70c
Merge branch 'master' into ocrd-network-optional-deploy
kba Jun 21, 2023
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
45 changes: 41 additions & 4 deletions ocrd_network/ocrd_network/deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
from .deployment_utils import (
create_docker_client,
DeployType,
wait_for_rabbitmq_availability
wait_for_rabbitmq_availability,
verify_mongodb_available,
verify_rabbitmq_available,
)

from .runtime_data import (
Expand Down Expand Up @@ -229,6 +231,23 @@ def deploy_rabbitmq(
remove: bool,
ports_mapping: Union[Dict, None] = None
) -> str:
if self.data_queue.skip_deployment:
self.log.debug(f"RabbitMQ is externaly managed. Skipping deployment")
verify_rabbitmq_available(
self.data_queue.address,
self.data_queue.port,
self.data_queue.vhost,
self.data_queue.username,
self.data_queue.password
)
wait_for_rabbitmq_availability(
host=self.data_queue.address,
port=int(self.data_queue.port),
vhost='/',
username=self.data_queue.username,
password=self.data_queue.password
)
Comment thread
joschrew marked this conversation as resolved.
Outdated
return self.data_queue.url
self.log.debug(f"Trying to deploy '{image}', with modes: "
f"detach='{detach}', remove='{remove}'")

Expand Down Expand Up @@ -289,6 +308,11 @@ def deploy_mongodb(
remove: bool,
ports_mapping: Union[Dict, None] = None
) -> str:
if self.data_mongo.skip_deployment:
self.log.debug('MongoDb is externaly managed. Skipping deployment')
verify_mongodb_available(self.data_mongo.url);
return self.data_mongo.url

self.log.debug(f"Trying to deploy '{image}', with modes: "
f"detach='{detach}', remove='{remove}'")

Expand All @@ -305,11 +329,20 @@ def deploy_mongodb(
ports_mapping = {
27017: self.data_mongo.port
}
if self.data_mongo.username:
environment = [
f'MONGO_INITDB_ROOT_USERNAME={self.data_mongo.username}',
f'MONGO_INITDB_ROOT_PASSWORD={self.data_mongo.password}'
]
else:
environment = []

res = client.containers.run(
image=image,
detach=detach,
remove=remove,
ports=ports_mapping
ports=ports_mapping,
environment=environment
)
if not res or not res.id:
raise RuntimeError('Failed to start MongoDB docker container on host: '
Expand All @@ -322,7 +355,9 @@ def deploy_mongodb(
return self.data_mongo.url

def kill_rabbitmq(self) -> None:
if not self.data_queue.pid:
if self.data_queue.skip_deployment:
return
elif not self.data_queue.pid:
self.log.warning('No running RabbitMQ instance found')
return
client = create_docker_client(
Expand All @@ -337,7 +372,9 @@ def kill_rabbitmq(self) -> None:
self.log.info('The RabbitMQ is stopped')

def kill_mongodb(self) -> None:
if not self.data_mongo.pid:
if self.data_mongo.skip_deployment:
return
elif not self.data_mongo.pid:
self.log.warning('No running MongoDB instance found')
return
client = create_docker_client(
Expand Down
20 changes: 20 additions & 0 deletions ocrd_network/ocrd_network/deployment_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
from docker.transport import SSHHTTPAdapter
from paramiko import AutoAddPolicy, SSHClient
from time import sleep
import re

from .rabbitmq_utils import RMQPublisher
from pymongo import MongoClient

__all__ = [
'create_docker_client',
Expand Down Expand Up @@ -104,6 +106,24 @@ def wait_for_rabbitmq_availability(
raise RuntimeError('Error waiting for queue startup: timeout exceeded')


def verify_rabbitmq_available(host: str, port: int, vhost: str, username: str,
password: str) -> None:
try:
dummy_publisher = RMQPublisher(host=host, port=port, vhost=vhost)
dummy_publisher.authenticate_and_connect(username=username, password=password)
except Exception:
raise Exception(f'Cannot connet to Rabbitmq host: {host}, port: {port}, '
f'vhost: {vhost}, username: {username}')


def verify_mongodb_available(mongo_url: str) -> None:
try:
client = MongoClient(mongo_url, serverSelectionTimeoutMS=1000.0)
client.admin.command("ismaster")
except Exception:
raise Exception(f'Cannot connet to MongoDb: {re.sub(r":[^@]+@", ":****@", mongo_url)}')


class DeployType(Enum):
""" Deploy-Type of the processing worker/processor server.
"""
Expand Down
37 changes: 28 additions & 9 deletions ocrd_network/ocrd_network/runtime_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,24 @@ class DataMongoDB:
def __init__(self, config: Dict) -> None:
self.address = config['address']
self.port = int(config['port'])
self.ssh_username = config['ssh']['username']
self.ssh_keypath = config['ssh'].get('path_to_privkey', None)
self.ssh_password = config['ssh'].get('password', None)
self.username = config['credentials']['username']
self.password = config['credentials']['password']
self.url = f'mongodb://{self.address}:{self.port}'
if 'ssh' in config:
self.ssh_username = config['ssh']['username']
self.ssh_keypath = config['ssh'].get('path_to_privkey', None)
self.ssh_password = config['ssh'].get('password', None)
else:
self.ssh_username = None
self.ssh_keypath = None
self.ssh_password = None

if 'credentials' in config:
self.username = config['credentials']['username']
self.password = config['credentials']['password']
self.url = f'mongodb://{self.username}:{self.password}@{self.address}:{self.port}'
else:
self.username = None
self.password = None
self.url = f'mongodb://{self.address}:{self.port}'
self.skip_deployment = config.get('skip_deployment', False)
# Assigned when deployed
self.pid = None

Expand All @@ -112,12 +124,19 @@ class DataRabbitMQ:
def __init__(self, config: Dict) -> None:
self.address = config['address']
self.port = int(config['port'])
self.ssh_username = config['ssh']['username']
self.ssh_keypath = config['ssh'].get('path_to_privkey', None)
self.ssh_password = config['ssh'].get('password', None)
if 'ssh' in config:
self.ssh_username = config['ssh']['username']
self.ssh_keypath = config['ssh'].get('path_to_privkey', None)
self.ssh_password = config['ssh'].get('password', None)
else:
self.ssh_username = None
self.ssh_keypath = None
self.ssh_password = None

self.vhost = '/'
self.username = config['credentials']['username']
self.password = config['credentials']['password']
self.url = f'amqp://{self.username}:{self.password}@{self.address}:{self.port}{self.vhost}'
self.skip_deployment = config.get('skip_deployment', False)
# Assigned when deployed
self.pid = None
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ properties:
ssh:
description: Information required for an SSH connection
$ref: "#/$defs/ssh"
skip_deployment:
description: set to true to deploy queue yourself
type: boolean
database:
description: Information about the MongoDB
type: object
Expand All @@ -46,6 +49,9 @@ properties:
ssh:
description: Information required for an SSH connection
$ref: "#/$defs/ssh"
skip_deployment:
description: set to true to deploy database yourself
type: boolean
hosts:
description: A list of hosts where Processing Servers will be deployed
type: array
Expand Down