test: use resmgr for downloading model

fix/readme-no-checkpoint
Robert Sachunsky 3 years ago
parent 7661662e3e
commit 59089fbe89

@ -3,6 +3,7 @@ PIP_INSTALL = pip3 install
GIT_CLONE = git clone GIT_CLONE = git clone
PYTHON = python3 PYTHON = python3
PYTEST_ARGS = -W 'ignore::DeprecationWarning' -W 'ignore::FutureWarning' PYTEST_ARGS = -W 'ignore::DeprecationWarning' -W 'ignore::FutureWarning'
MODEL = qurator-gt4histocr-1.0
# BEGIN-EVAL makefile-parser --make-help Makefile # BEGIN-EVAL makefile-parser --make-help Makefile
@ -11,7 +12,7 @@ help:
@echo " Targets" @echo " Targets"
@echo "" @echo ""
@echo " install Install ocrd_calamari" @echo " install Install ocrd_calamari"
@echo " gt4histocr-calamari1 Get GT4HistOCR Calamari model (from SBB)" @echo " $(MODEL) Get Calamari model (from SBB)"
@echo " actevedef_718448162 Download example data" @echo " actevedef_718448162 Download example data"
@echo " deps-test Install testing python deps via pip" @echo " deps-test Install testing python deps via pip"
@echo " repo/assets Clone OCR-D/assets to ./repo/assets" @echo " repo/assets Clone OCR-D/assets to ./repo/assets"
@ -25,6 +26,7 @@ help:
@echo " PYTHON '$(PYTHON)'" @echo " PYTHON '$(PYTHON)'"
@echo " PIP_INSTALL '$(PIP_INSTALL)'" @echo " PIP_INSTALL '$(PIP_INSTALL)'"
@echo " GIT_CLONE '$(GIT_CLONE)'" @echo " GIT_CLONE '$(GIT_CLONE)'"
@echo " MODEL '$(MODEL)'"
# END-EVAL # END-EVAL
@ -34,17 +36,14 @@ install:
# Get GT4HistOCR Calamari model (from SBB) # Get GT4HistOCR Calamari model (from SBB)
gt4histocr-calamari1: $(MODEL):
mkdir -p gt4histocr-calamari1 ocrd resmgr download ocrd-calamari-recognize $@
cd gt4histocr-calamari1 && \
wget https://qurator-data.de/calamari-models/GT4HistOCR/2019-12-11T11_10+0100/model.tar.xz && \ # Download example data (not used currently)
tar xfv model.tar.xz && \
rm model.tar.xz
# Download example data
actevedef_718448162: actevedef_718448162:
wget https://qurator-data.de/examples/actevedef_718448162.zip && \ wget https://qurator-data.de/examples/actevedef_718448162.zip \
unzip actevedef_718448162.zip && unzip actevedef_718448162.zip \
&& rm actevedef_718448162.zip
@ -73,15 +72,15 @@ assets-clean:
rm -rf test/assets rm -rf test/assets
# Run unit tests # Run unit tests
test: test/assets gt4histocr-calamari1 test: test/assets $(MODEL)
# declare -p HTTP_PROXY # declare -p HTTP_PROXY
$(PYTHON) -m pytest --continue-on-collection-errors test $(PYTEST_ARGS) $(PYTHON) -m pytest --continue-on-collection-errors test $(PYTEST_ARGS)
# Run unit tests and determine test coverage # Run unit tests and determine test coverage
coverage: test/assets gt4histocr-calamari1 coverage: test/assets $(MODEL)
coverage erase coverage erase
make test PYTHON="coverage run" make test PYTHON="coverage run"
coverage report coverage report
coverage html coverage html
.PHONY: assets-clean test .PHONY: install assets-clean deps-test test coverage $(MODEL)

@ -14,7 +14,7 @@ from .base import assets
METS_KANT = assets.url_of('kant_aufklaerung_1784-page-region-line-word_glyph/data/mets.xml') METS_KANT = assets.url_of('kant_aufklaerung_1784-page-region-line-word_glyph/data/mets.xml')
WORKSPACE_DIR = '/tmp/test-ocrd-calamari' WORKSPACE_DIR = '/tmp/test-ocrd-calamari'
CHECKPOINT_DIR = os.path.join(os.getcwd(), 'gt4histocr-calamari1') CHECKPOINT_DIR = os.getenv('MODEL')
# Because XML namespace versions are so much fun, we not only use one, we use TWO! # Because XML namespace versions are so much fun, we not only use one, we use TWO!
NSMAP = { "pc": "http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15" } NSMAP = { "pc": "http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15" }

Loading…
Cancel
Save