Skip to content
Snippets Groups Projects
Unverified Commit 1c12c910 authored by Daniel Ecer's avatar Daniel Ecer Committed by GitHub
Browse files

added multiple override models option (#53)

parent 0dc971fe
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,11 @@ REVISION=develop
# $GROBID_TAG-$REVISION
IMAGE_TAG=0.5.6-develop
OVERRIDE_MODELS=
OVERRIDE_MODEL_1=
OVERRIDE_MODEL_2=
OVERRIDE_MODEL_3=
# all grobid tags built by ci
ALL_GROBID_TAGS=0.5.3,0.5.4,0.5.5,0.5.6
LATEST_GROBID_TAG=04346b26b5fa7966cef4d6ec6bba867feba52d66
version: '3'
version: '3.4'
services:
sciencebeam-trainer-grobid:
......
version: '3'
version: '3.4'
x-grobid-env:
&grobid-env
- OVERRIDE_MODELS=${OVERRIDE_MODELS}
- OVERRIDE_MODEL_1=${OVERRIDE_MODEL_1}
- OVERRIDE_MODEL_2=${OVERRIDE_MODEL_2}
- OVERRIDE_MODEL_3=${OVERRIDE_MODEL_3}
services:
grobid-builder:
......@@ -21,6 +28,7 @@ services:
image: elifesciences/sciencebeam-trainer-grobid:${IMAGE_TAG}
depends_on:
- grobid-builder
environment: *grobid-env
volumes:
- data:/data
......@@ -48,6 +56,7 @@ services:
image: elifesciences/sciencebeam-trainer-grobid-dev:${IMAGE_TAG}
depends_on:
- sciencebeam-trainer-grobid-dev-base
environment: *grobid-env
volumes:
- data:/data
......
......@@ -4,16 +4,26 @@ set -e
GROBID_MODELS_DIRECTORY=${GROBID_MODELS_DIRECTORY:-/opt/grobid-source/grobid-home/models}
if [ ! -z "${OVERRIDE_MODELS}" ]; then
# override models via OVERRIDE_MODELS or OVERRIDE_MODELS_*
# the latter makes it easier to override multiple models as separate env variables
env -0 | while IFS='=' read -r -d '' env_var_name env_var_value; do
if [[ -z "${env_var_value}" ]]; then
# skip empty values
continue
fi
if [[ "${env_var_name}" != "OVERRIDE_MODELS" ]] && [[ "${env_var_name}" != OVERRIDE_MODEL_* ]]; then
# skipping other env variable names
continue
fi
if [ ! -d "${GROBID_MODELS_DIRECTORY}" ]; then
echo "directory does not exist: ${GROBID_MODELS_DIRECTORY}"
exit 1
fi
echo "installing models: ${OVERRIDE_MODELS}"
echo "installing models: ${env_var_value} (${env_var_name})"
python -m sciencebeam_trainer_grobid.tools.install_models \
--model-base-path=${GROBID_MODELS_DIRECTORY} \
--install "${OVERRIDE_MODELS}" \
--install "${env_var_value}" \
--validate-pickles
fi
done
exec "$@"
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment