-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
107 lines (83 loc) · 2.76 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
export # export variables to subshells
PIP_INSTALL = pip3 install
GIT_CLONE = git clone
PYTHON = python3
PYTEST_ARGS = -W 'ignore::DeprecationWarning' -W 'ignore::FutureWarning'
MODEL = qurator-gt4histocr-1.0
EXAMPLE = actevedef_718448162.first-page+binarization+segmentation
# BEGIN-EVAL makefile-parser --make-help Makefile
DOCKER_BASE_IMAGE = docker.io/ocrd/core-cuda-tf2:v2.70.0
DOCKER_TAG = 'ocrd/calamari'
help:
@echo ""
@echo " Targets"
@echo ""
@echo " install Install ocrd_calamari"
@echo " $(MODEL) Get Calamari model (from SBB)"
@echo " example Download example data"
@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 " docker Build Docker image"
@echo ""
@echo " Variables"
@echo ""
@echo " PYTHON '$(PYTHON)'"
@echo " PIP_INSTALL '$(PIP_INSTALL)'"
@echo " GIT_CLONE '$(GIT_CLONE)'"
@echo " MODEL '$(MODEL)'"
@echo " DOCKER_TAG '$(DOCKER_TAG)'"
@echo " DOCKER_BASE_IMAGE '$(DOCKER_BASE_IMAGE)'"
# END-EVAL
# Install ocrd_calamari
install:
$(PIP_INSTALL) .
# Get GT4HistOCR Calamari model (from SBB)
$(MODEL):
ocrd resmgr download ocrd-calamari-recognize $@
# Download example data (for the README)
example: $(EXAMPLE)
$(EXAMPLE):
wget -c https://qurator-data.de/examples/$(EXAMPLE).zip -O $(EXAMPLE).zip.tmp
mv $(EXAMPLE).zip.tmp $(EXAMPLE).zip
unzip $(EXAMPLE).zip
rm $(EXAMPLE).zip
#
# Assets and Tests
#
# Install testing python deps via pip
deps-test:
$(PIP_INSTALL) -r requirements-dev.txt
deps-test-ubuntu: deps-test
apt-get install -y make git curl wget imagemagick
# 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 $(MODEL)
# declare -p HTTP_PROXY
$(PYTHON) -m pytest --continue-on-collection-errors test $(PYTEST_ARGS)
# Run unit tests and determine test coverage
coverage: test/assets $(MODEL)
coverage erase
make test PYTHON="coverage run"
coverage report
coverage html
docker:
docker build \
--build-arg DOCKER_BASE_IMAGE=$(DOCKER_BASE_IMAGE) \
--build-arg VCS_REF=$$(git rev-parse --short HEAD) \
--build-arg BUILD_DATE=$$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
-t $(DOCKER_TAG) .
.PHONY: install assets-clean deps-test test coverage $(MODEL) example docker