smoke test, circle ci

Conflicts:
	Makefile
	ocrd_calamari/__init__.py
fix/readme-no-checkpoint
Konstantin Baierer 5 years ago committed by Gerber, Mike
parent afe6eec5a2
commit b54ccf90f7

@ -0,0 +1,21 @@
version: 2.1
orbs:
codecov: codecov/codecov@1.0.5
jobs:
build-python36:
docker:
- image: ubuntu:18.04
steps:
- run: apt-get update ; apt-get install -y make git curl
- checkout
- run: make install
- run: pip install -r requirements-test.txt
- run: make coverage
- codecov/upload
workflows:
build:
jobs:
- build-python36

4
.gitignore vendored

@ -102,7 +102,9 @@ venv.bak/
# mypy # mypy
.mypy_cache/ .mypy_cache/
/calamari /calamari
/calamari_models /calamari_models
/repo /repo
/test /test/assets

@ -1,7 +1,11 @@
GIT_CLONE = git clone --depth 1 # '$(PYTHON)'
PYTHON = python
# '$(PIP_INSTALL)'
PIP_INSTALL = pip install
# Docker tag # '$(GIT_CLONE)'
DOCKER_TAG = ocrd/calamari GIT_CLONE = git clone --depth 1
# BEGIN-EVAL makefile-parser --make-help Makefile # BEGIN-EVAL makefile-parser --make-help Makefile
@ -9,31 +13,75 @@ help:
@echo "" @echo ""
@echo " Targets" @echo " Targets"
@echo "" @echo ""
@echo " calamari git clone calamari" @echo " install Install ocrd_calamari"
@echo " calamari_models git clone calamari_models" @echo " calamari Clone calamari repo"
@echo " calamari/build Install calamari" @echo " calamari_models Clone calamari_models repo"
@echo " docker Build docker image" @echo " calamari/build pip install calamari"
@echo " deps-test Install testing python deps via pip"
@echo " repo/assets Clone OCR-D/assets to ./repo/assets"
@echo " test/assets Setup test assets"
@echo " assets-clean Remove symlinks in test/assets"
@echo " test Run unit tests"
@echo " coverage Run unit tests and determine test coverage"
@echo "" @echo ""
@echo " Variables" @echo " Variables"
@echo "" @echo ""
@echo " DOCKER_TAG Docker tag" @echo " PYTHON '$(PYTHON)'"
@echo " PIP_INSTALL '$(PIP_INSTALL)'"
@echo " GIT_CLONE '$(GIT_CLONE)'"
# END-EVAL # END-EVAL
# git clone calamari # Install ocrd_calamari
install:
$(PIP_INSTALL) .
# Clone calamari repo
calamari: calamari:
$(GIT_CLONE) https://github.com/chwick/calamari $(GIT_CLONE) https://github.com/chwick/calamari
# git clone calamari_models # Clone calamari_models repo
calamari_models: calamari_models:
$(GIT_CLONE) https://github.com/chwick/calamari_models $(GIT_CLONE) https://github.com/chwick/calamari_models
# Install calamari # pip install calamari
calamari/build: calamari calamari_models calamari/build: calamari calamari_models
cd calamari &&\ cd calamari && $(PIP_INSTALL) .
pip install -r requirements.txt ;\
python setup.py install #
# Assets and Tests
#
# Install testing python deps via pip
deps-test:
$(PIP) install -r requirements_test.txt
# Clone OCR-D/assets to ./repo/assets
repo/assets:
mkdir -p $(dir $@)
git clone https://github.com/OCR-D/assets "$@"
# Setup test assets
test/assets: repo/assets
mkdir -p $@
cp -r -t $@ repo/assets/data/*
# Remove symlinks in test/assets
assets-clean:
rm -rf test/assets
# Run unit tests
test: test/assets calamari_models
# declare -p HTTP_PROXY
$(PYTHON) -m pytest --continue-on-collection-errors test $(PYTEST_ARGS)
# Run unit tests and determine test coverage
coverage:
coverage erase
make test PYTHON="coverage run"
coverage report
coverage html
# Build docker image .PHONY: assets-clean test
docker:
docker build -t '$(DOCKER_TAG)' .

@ -1 +1,5 @@
__all__ = [
'CalamariRecognize'
]
from .recognize import CalamariRecognize from .recognize import CalamariRecognize

@ -0,0 +1,2 @@
pytest
ocrd_tesserocr >= 0.4.0

@ -0,0 +1,10 @@
# pylint: disable=unused-import
import os
import sys
from unittest import TestCase, skip, main # pylint: disable=unused-import
from test.assets import assets
PWD = os.path.dirname(os.path.realpath(__file__))
sys.path.append(PWD + '/../ocrd')

@ -0,0 +1,62 @@
import os
from os.path import join, exists
import shutil
from test.base import TestCase, main, assets, skip
from ocrd.resolver import Resolver
from ocrd_tesserocr import TesserocrSegmentRegion
from ocrd_tesserocr import TesserocrSegmentLine
from ocrd_calamari import CalamariRecognize
#METS_HEROLD_SMALL = assets.url_of('SBB0000F29300010000/data/mets_one_file.xml')
# as long as #96 remains, we cannot use workspaces which have local relative files:
METS_HEROLD_SMALL = assets.url_of('kant_aufklaerung_1784-binarized/data/mets.xml')
WORKSPACE_DIR = '/tmp/test-ocrd-calamari'
class TestCalamariRecognize(TestCase):
def setUp(self):
if exists(WORKSPACE_DIR):
shutil.rmtree(WORKSPACE_DIR)
os.makedirs(WORKSPACE_DIR)
#skip("Takes too long")
def runTest(self):
resolver = Resolver()
workspace = resolver.workspace_from_url(METS_HEROLD_SMALL, dst_dir=WORKSPACE_DIR)
TesserocrSegmentRegion(
workspace,
input_file_grp="OCR-D-IMG",
output_file_grp="OCR-D-SEG-BLOCK"
).process()
workspace.save_mets()
TesserocrSegmentLine(
workspace,
input_file_grp="OCR-D-SEG-BLOCK",
output_file_grp="OCR-D-SEG-LINE"
).process()
workspace.save_mets()
CalamariRecognize(
workspace,
input_file_grp="OCR-D-SEG-LINE",
output_file_grp="OCR-D-OCR-CALAMARI",
parameter={
'checkpoint': 'calamari_models/fraktur_historical/*.ckpt.json'
}
).process()
workspace.save_mets()
page1 = join(workspace.directory, 'OCR-D-OCR-CALAMARI/OCR-D-OCR-CALAMARI_0001.xml')
self.assertTrue(exists(page1))
with open(page1, 'r') as f:
self.assertIn('verſchuldeten', f.read())
if __name__ == '__main__':
main()
Loading…
Cancel
Save