-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use ocrd-tesserocr with caching for Processing Server not possible #190
Comments
Indeed, this pattern is a problem.
We could easily rewrite this by testing for |
The only solution I see is making |
I don't understand how that would help. The kwarg transfer needs to happen in the constructor already. Within the new paradigm of the changed processor API, differentiating between processing and non-processing context becomes painless. (The former can happen in But for the moment, as I said, exchanging |
That's the problem I am trying to describe. At the constructor we don't have the workspace yet because we are creating a cached instance. We want to set the workspace later after the constructor has finished. But when we do that (setting the workspace) the wrapped instance of With the code snipped (ocrd_tesserocr/ocrd_tesserocr/segment_region.py) I only wanted to show that the processor wraps an instance of TesserocrRecognize which does the real work. The |
Ah, sry, I didn't see it! Yes, since we don't override the constructor, but construct and then wrap a separate processor object, many patterns don't work. So I would say this trick is bad practice and should be ruled out in the future. IIRC I used that wrap pattern instead of overriding the constructor because I did not want the user to see the processor appear like ocrd-tesserocr-recognize (with all its complicated parameters). But the downsides are obviously too great. I'll make a PR based on the simpler pattern.
Yes, that would work, and maybe it's also the best pattern in general going forward for all processors. (The setter could do many other things, like syncing/closing log files, releasing locks, syncing the METS cache or METS server.) |
In the processing server pull request we want to use caching. Therefore an instance of a processor without a workspace is created. Later when the user requests a processor-run we want to set the workspace into that cache-instance.
The problem seems to be that ocrd-tesserocr processors delegates the processing internally to the processor TesserocrRecognize`:
ocrd_tesserocr/ocrd_tesserocr/segment_region.py
Lines 13 to 32 in c10f94d
The workspace is transferred to this class on creation. If the workspace is (re-)set afterwards it does not get delegated to the created instance of
TesserocrRecognize
The text was updated successfully, but these errors were encountered: