Processor.resolve_resource: support on-demand download of URL values#799
Processor.resolve_resource: support on-demand download of URL values#799
Conversation
bertsky
left a comment
There was a problem hiding this comment.
LGTM. Perhaps the resource_type can also be guessed from the URL suffix (/ for directory, .zip etc for archive).
(As a test case, because we would not want to be dependent on an external module, you could define a subclass of DummyProcessor with a file parameter and some resolve_resource logic in the constructor, e.g. printing the file to stdout.)
Yes. For Ocropy recognition, your cisocrgroup/ocrd_cis#83 is long overdue. And for Tesseract, I believe your OCR-D/ocrd_tesserocr#176 could be rewritten such that instead of overriding the constructor (for the
Yes, Github directory downloads would be hard to implement. But IMO we can assume that model deployment for Calamari and and eynollah and sbb_binarize will involve release archives in the future.
With the recent changes to bashlib, this should work out of the box, though. (What happens is that it delegates to A Pythonic test scenario would be running-downloading |
With this in place, users can use URL directly for parameter values:
and it should download on demand the first time it encounters and registers the URL in the user resource_list.yml. Subsequent calls will use the cached download.
In practice though I cannot seem to find an example where this works:
ocrd_{tesserocr,cis-ocropy}have a different mechanism of model storage. It's still compatible withocrd resmgr downloadin tesserocr's case but does not use theself.resolve_resourcemethod this PR extendsocrd_calamarirequires a directory of files, or an archive which is too complex to do on demand in a generalized way IMHOocrd-page-transformis a bashlib processor and won't support this.So if anybody has a good idea on how to test and/or generalize this to make it available to all the processors, pls let me know.