Skip to content
Merged
Show file tree
Hide file tree
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
15 changes: 15 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,18 @@ jobs:

- name: Run pytest
run: pytest

test-alto:
name: Test Alto XML
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true

- name: Pull docker images to run ALTO XML test
run: cd test-alto && docker compose pull

- name: Run ALTO XML test
run: cd test-alto && bash test-alto-batch.sh example-file/0001.xml
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,3 @@ dist/

src/lp_labelstudio/web_server/test_images/*.json
.env

test_batches/*
!test_batches/default_mets.xml
!test_batches/create_awardee_title.py
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "open-oni"]
path = open-oni
path = test-alto/open-oni
url = [email protected]:codemyriad/open-oni.git
branch = masca
3 changes: 3 additions & 0 deletions test-alto/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test_batches/*
!test_batches/default_mets.xml
!test_batches/create_awardee_title.py
File renamed without changes.
File renamed without changes
File renamed without changes.
11 changes: 10 additions & 1 deletion how-to-test-alto-xml.md → test-alto/how-to-test-alto-xml.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Setup Open ONI as submodule. This is needed since the open-oni folder will be mounted in the `web` container.

`git submodule --init --checkout`
`git submodule update --init --checkout`

Than you should be able to test an XML Alto file with:

Expand All @@ -21,3 +21,12 @@ The script will lookup for a .jpeg image in the same directory and with the same
|-- 0001.jpeg

One can reset all data by removing the docker peristent volumes `data-mariadb` and `data-solr`.


Data reset
----------

To reset local state run

docker compose down
docker volume rm test-alto_data-solr test-alto_data-mariadb
16 changes: 11 additions & 5 deletions test-alto-batch.sh → test-alto/test-alto-batch.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

set -e
cd "$(dirname "$0")"

# Check if input file is provided
if [ $# -eq 0 ]; then
Expand Down Expand Up @@ -77,20 +78,25 @@ if [ ! -f "$DOCKER_COMPOSE_PATH" ]; then
exit 1
fi

# Stop any existing Open ONI containers
docker compose -f "$DOCKER_COMPOSE_PATH" down

# Start Docker Compose with batch mounted
docker compose -f "$DOCKER_COMPOSE_PATH" up -d

# Wait for the container to fully start
sleep 15
timeout=90
until docker compose logs web | grep -q "ONI setup successful"; do
if [ $timeout -le 0 ]; then
echo "Timeout waiting for ONI setup"
exit 1
fi
sleep 3
timeout=$((timeout-5))
done

# Create Awardee and Title objects if they don't exists
docker compose -f "$DOCKER_COMPOSE_PATH" exec -T web bash -c "source ENV/bin/activate && python manage.py shell < /opt/create_awardee_title.py"

# Purge the batch if it exists in Open ONI
docker compose -f "$DOCKER_COMPOSE_PATH" exec -T web bash -c "source ENV/bin/activate && python manage.py purge_batch $BATCH_NAME"
docker compose -f "$DOCKER_COMPOSE_PATH" exec -T web bash -c "source ENV/bin/activate && (python manage.py batches | grep -q '^$BATCH_NAME$' && python manage.py purge_batch $BATCH_NAME; true)"

# Load the batch into Open ONI
docker compose -f "$DOCKER_COMPOSE_PATH" exec -T web bash -c "source ENV/bin/activate && python manage.py load_batch /opt/openoni/data/batches/$BATCH_NAME"
Expand Down
File renamed without changes.
Loading