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

Webhook implementation #66

Merged
merged 28 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b188056
Adjust gitignore, add webhook implementation instead of active mq
markusweigelt Aug 14, 2023
461635c
Add test for webhook implementation in ocrd-lib, improve scripts to u…
markusweigelt Dec 18, 2023
5c9dbdb
Code fixes and add missing content of README.md
markusweigelt Dec 18, 2023
04610d3
improvements
markusweigelt Dec 18, 2023
38a5d22
Add newline
markusweigelt Dec 18, 2023
7f91893
Merge main
markusweigelt Dec 18, 2023
e9100a0
Add mypy
markusweigelt Dec 18, 2023
f21945b
Fix tests
markusweigelt Dec 18, 2023
4cfb4c8
lower timeout
markusweigelt Dec 18, 2023
5eaaa4b
refactore request function
markusweigelt Dec 19, 2023
1c89399
Add active mq client and log4j to Dockerfile, Add parameters for WEBH…
markusweigelt Dec 19, 2023
60022d9
Adjust of the makefile to the webhook implementation
markusweigelt Dec 19, 2023
85f228f
Improvements
markusweigelt Dec 20, 2023
82d4ac9
Adjust webhook key data
markusweigelt Dec 20, 2023
fffeae6
Improvements
markusweigelt Dec 20, 2023
f9503b5
Improvements
markusweigelt Dec 21, 2023
a78e793
improvements regarding tests and async handling
markusweigelt Dec 21, 2023
fe6b94a
gitignore testdata folders
markusweigelt Dec 21, 2023
b86c666
run sync mode by default
markusweigelt Jan 9, 2024
56980dc
Adjust make test cause of changed async behaviour
markusweigelt Jan 9, 2024
0ae9ce4
Merge branch 'main' into basic-webhook-implementation
markusweigelt Feb 29, 2024
770e1b6
Update ocrd_lib.sh
markusweigelt Mar 1, 2024
e47ab84
Update process_images.sh
markusweigelt Mar 1, 2024
0f1c0d7
Update process_mets.sh
markusweigelt Mar 1, 2024
7d199f9
Update process_mets.sh
markusweigelt Mar 1, 2024
0432489
Update process_images.sh
markusweigelt Mar 1, 2024
55e3144
Add workflow behaviour again
markusweigelt Mar 1, 2024
b1e3d26
improve names of webhook actions
markusweigelt Mar 1, 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
4 changes: 0 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,3 @@ MANAGER_WORKFLOWS=/workflows

MONITOR_DB_ROOT_USER=root
MONITOR_DB_ROOT_USER=root_password

MQ_HOST=kitodo-mq
MQ_PORT=61616
MQ_CLIENT_QUEUE=FinalizeTaskQueue
52 changes: 36 additions & 16 deletions .github/workflows/test-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,47 @@ on:
workflow_dispatch:

jobs:
build-test:
mypy:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]

steps:
- name: Checkout repository and submodules
uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4

- name: Prepare
run: |
# Rename example .env file
mv .env.example .env
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

# Set environment variables from .env file
export $(cat .env | xargs)
- name: Install dependencies using pip
run: pip install -e ".[dev]"

# Generate ssh keys
mkdir -p ./ssh
ssh-keygen -t rsa -q -f $MANAGER_KEY -P '' -C 'OCR-D manager key'
- name: Checking static types using mypy
run: mypy --strict tests

- name: Docker Compose build
run: docker compose build

- name: Test
run: make test
pytest:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Install project dependencies
run: |
pip install pdm
pdm install -G dev

- name: Testing using pytest
run: pdm run pytest tests
168 changes: 165 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,166 @@
*~
authorized_keys
# Byte-compiled / optimized / DLL files
__pycache__/
.python-version
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# ignore generated testdata folders
testdata-production
testdata-presentation
22 changes: 11 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ LABEL \
org.opencontainers.image.revision=$VCS_REF \
org.opencontainers.image.created=$BUILD_DATE

ARG KITODO_MQ_CLIENT_VERSION=0.3

# Changelog https://www.mongodb.com/docs/mongodb-shell/changelog/
# Supported MongoDB Version https://www.mongodb.com/docs/mongodb-shell/connect/#supported-mongodb-versions
ARG MONGODB_SHELL_VERSION=1.10.1
Expand All @@ -48,17 +46,19 @@ RUN apt-get update && \
# configure writing to ocrd.log for profiling
COPY ocrd_logging.conf /etc

# add activemq log4j properties
COPY kitodo-activemq-client-log4j2.properties /opt/kitodo-activemq-client/log4j2.properties
ENV ACTIVEMQ_CLIENT_LOG4J2 /opt/kitodo-activemq-client/log4j2.properties

# add ActiveMQ client library
ADD https://github.com/slub/kitodo-production-activemq/releases/download/${KITODO_MQ_CLIENT_VERSION}/kitodo-activemq-client-${KITODO_MQ_CLIENT_VERSION}.jar /opt/kitodo-activemq-client
ENV ACTIVEMQ_CLIENT /opt/kitodo-activemq-client/kitodo-activemq-client-${KITODO_MQ_CLIENT_VERSION}.jar
RUN chmod go+r $ACTIVEMQ_CLIENT
## Kitodo.Production ActiveMQ specifics for process_images.sh (for_production.sh)
# https://github.com/slub/kitodo-production-activemq/tags
ARG KITODO_PRODUCTION_ACTIVEMQ_CLIENT_VERSION=0.3

# add Kitodo.Production ActiveMQ log4j properties
COPY kitodo-production-activemq-client-log4j2.properties /opt/kitodo-production-activemq-client/log4j2.properties
ENV KITODO_PRODUCTION_ACTIVEMQ_CLIENT_LOG4J2 /opt/kitodo-production-activemq-client/log4j2.properties

# configure ActiveMQ client queue
ENV ACTIVEMQ_CLIENT_QUEUE FinalizeTaskQueue
# add Kitodo.Production client library
ADD https://github.com/slub/kitodo-production-activemq/releases/download/${KITODO_PRODUCTION_ACTIVEMQ_CLIENT_VERSION}/kitodo-activemq-client-${KITODO_PRODUCTION_ACTIVEMQ_CLIENT_VERSION}.jar /opt/kitodo-production-activemq-client
ENV KITODO_PRODUCTION_ACTIVEMQ_CLIENT /opt/kitodo-production-activemq-client/kitodo-activemq-client-${KITODO_PRODUCTION_ACTIVEMQ_CLIENT_VERSION}.jar
RUN chmod go+r $KITODO_PRODUCTION_ACTIVEMQ_CLIENT

# install mets-mods2tei (for METS updates outside of OCR-D workspace)
RUN pip install mets-mods2tei
Expand Down
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ Variables:
- CONTROLLER network address:port for the controller client
(must be reachable from the container network)
currently: $(CONTROLLER)
- ACTIVEMQ network address:port for the ActiveMQ client
(must be reachable from the container network)
currently: $(ACTIVEMQ)
EOF
endef
export HELP
Expand All @@ -57,7 +54,6 @@ PORT ?= 9022
NETWORK ?= bridge
CONTROLLER_HOST ?= $(shell dig +short $$HOSTNAME)
CONTROLLER_PORT_SSH ?= 8022
#ACTIVEMQ ?= $(shell dig +short $$HOSTNAME):61616
run: $(DATA)
docker run -d --rm \
-p $(PORT):22 \
Expand All @@ -70,7 +66,6 @@ run: $(DATA)
--mount type=bind,source=$(PRIVATE),target=/id_rsa \
-e UID=$(UID) -e GID=$(GID) -e UMASK=$(UMASK) \
-e CONTROLLER=$(CONTROLLER_HOST):$(CONTROLLER_PORT_SSH) \
-e ACTIVEMQ=$(ACTIVEMQ) \
$(TAGNAME)

$(DATA)/testdata-production:
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ services:
UMASK: ${MANAGER_ENV_UMASK}
CONTROLLER: "${CONTROLLER_HOST}:${CONTROLLER_PORT_SSH}"
DB_CONNECTION: "mongodb://${MONITOR_DB_ROOT_USER:-root}:${MONITOR_DB_ROOT_PASSWORD:-root_password}@ocrd-database:27017"
ACTIVEMQ: "${MQ_HOST}:${MQ_PORT}"
ACTIVEMQ_CLIENT_QUEUE: "${MQ_CLIENT_QUEUE}"

ports:
- ${MANAGER_PORT_SSH}:22
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
status = warn
# Name of the configuration
name = KitodoActiveMQClientLog4j2Config
name = KitodoProductionActiveMQClientLog4j2Config

# Console appender configuration
appender.console.type = console
Expand Down
Loading
Loading