core
core copied to clipboard
resmgr: download --overwrite does not work
I accidentally ran calamari-predict from the top-level (instead of a sub-venv), which tried to update my GT4HistOCR model to the more recent TF – overwriting the checkpoint JSON.
Now, I tried to download that model again:
ocrd resmgr download --overwrite ocrd-calamari-recognize qurator-gt4histocr-1.0
INFO ocrd.cli.resmgr - Downloading resource {'url': 'https://qurator-data.de/calamari-models/GT4HistOCR/2019-12-11T11_10+0100/model.tar.xz', 'type': 'tarball', 'name': 'qurator-gt4histocr-1.0', 'description': 'Calamari model trained with GT4HistOCR', 'size': 90275264, 'path_in_archive': '.', 'version_range': '>= 1.0.0', 'parameter_usage': 'as-is'}
INFO ocrd.resource_manager._download_impl - Downloading https://qurator-data.de/calamari-models/GT4HistOCR/2019-12-11T11_10+0100/model.tar.xz to download.tar.xx
[####################################] 100% INFO ocrd.resource_manager.download - Extracting tarball
INFO ocrd.resource_manager.download - Copying '.' from tarball to /.local/share/ocrd-resources/ocrd-calamari-recognize/qurator-gt4histocr-1.0
Traceback (most recent call last):
File "/venv/bin/ocrd", line 8, in <module>
sys.exit(cli())
File "/venv/lib/python3.6/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/venv/lib/python3.6/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/venv/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/venv/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/venv/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/venv/lib/python3.6/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/venv/lib/python3.6/site-packages/ocrd/cli/resmgr.py", line 137, in download
progress_cb=lambda delta: bar.update(delta)
File "/venv/lib/python3.6/site-packages/ocrd/resource_manager.py", line 225, in download
copytree(path_in_archive, str(fpath))
File "/usr/lib/python3.6/shutil.py", line 321, in copytree
os.makedirs(dst)
File "/usr/lib/python3.6/os.py", line 220, in makedirs
mkdir(name, mode)
FileExistsError: [Errno 17] File exists: '/.local/share/ocrd-resources/ocrd-calamari-recognize/qurator-gt4histocr-1.0'
Looks like overwrite is not implemented properly.