diff --git a/.gitignore b/.gitignore index 8bfdf32..3c0c0ee 100644 --- a/.gitignore +++ b/.gitignore @@ -105,6 +105,5 @@ ENV/ *.swp .pytest_cache tests/assets -repo .pynative _*.png diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..5b24fbb --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "repo/assets"] + path = repo/assets + url = https://github.com/OCR-D/assets diff --git a/Makefile b/Makefile index ea8cbba..d88c9e2 100644 --- a/Makefile +++ b/Makefile @@ -69,10 +69,14 @@ test: tests/assets # Assets # -# Clone OCR-D/assets to ./repo/assets -repo/assets: - mkdir -p $(dir $@) - git clone --quiet https://github.com/OCR-D/assets "$@" +# Update OCR-D/assets submodule +.PHONY: repos always-update tests/assets +repo/assets: always-update + git submodule sync --recursive $@ + if git submodule status --recursive $@ | grep -qv '^ '; then \ + git submodule update --init --recursive $@ && \ + touch $@; \ + fi # Setup test assets diff --git a/repo/assets b/repo/assets new file mode 160000 index 0000000..05568aa --- /dev/null +++ b/repo/assets @@ -0,0 +1 @@ +Subproject commit 05568aaa2dc20678bf87ffec77f3baf2924d7c24 diff --git a/tests/test_binarize.py b/tests/test_binarize.py index e710a63..98f3745 100644 --- a/tests/test_binarize.py +++ b/tests/test_binarize.py @@ -21,7 +21,8 @@ def workspace(tmpdir): shutil.rmtree(tmpdir) workspace = Resolver().workspace_from_url( assets.path_to('kant_aufklaerung_1784/data/mets.xml'), - dst_dir=tmpdir + dst_dir=tmpdir, + download=True ) return workspace diff --git a/tests/test_recognize.py b/tests/test_recognize.py index 71246c6..0ae2850 100644 --- a/tests/test_recognize.py +++ b/tests/test_recognize.py @@ -18,7 +18,7 @@ def test_recognize(self): resolver = Resolver() # with pushd_popd('/tmp/kraken-test') as tempdir: with pushd_popd(tempdir=True) as tempdir: - workspace = resolver.workspace_from_url(assets.path_to('communist_manifesto/data/mets.xml'), dst_dir=tempdir) + workspace = resolver.workspace_from_url(assets.path_to('communist_manifesto/data/mets.xml'), dst_dir=tempdir, download=True) workspace.overwrite_mode = True proc = KrakenRecognize( workspace, diff --git a/tests/test_segment.py b/tests/test_segment.py index 2cdee40..af59a7f 100644 --- a/tests/test_segment.py +++ b/tests/test_segment.py @@ -17,7 +17,7 @@ def setUp(self): def test_run_blla(self): resolver = Resolver() with pushd_popd(tempdir=True) as tempdir: - workspace = resolver.workspace_from_url(assets.path_to('communist_manifesto/data/mets.xml'), dst_dir=tempdir) + workspace = resolver.workspace_from_url(assets.path_to('communist_manifesto/data/mets.xml'), dst_dir=tempdir, download=True) proc = KrakenSegment( workspace, input_file_grp="OCR-D-IMG-BIN", @@ -31,7 +31,7 @@ def test_run_legacy(self): resolver = Resolver() # with pushd_popd('/tmp/kraken-test') as tempdir: with pushd_popd(tempdir=True) as tempdir: - workspace = resolver.workspace_from_url(assets.path_to('communist_manifesto/data/mets.xml'), dst_dir=tempdir) + workspace = resolver.workspace_from_url(assets.path_to('communist_manifesto/data/mets.xml'), dst_dir=tempdir, download=True) proc = KrakenSegment( workspace, input_file_grp="OCR-D-IMG-BIN",