feat: async. HTTP communication in tesseract REST API #225
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Relevant issue or PR
N/A
Description of changes
The Current REST API makes one sync. HTTP request, whose response may return after hours in case of long-running tasks (e.g. simulations).
Here we introduce new endpoints for asynchronous handling of long-running simulators, specifically in a long-polling fashion:
The client new requests a new task execution and immediately receives a task ID. The client may then repeatedly request to retrieve the task's output; said requests return after a short blocking timeout while the task is still running, but return immediately once the task is done.
Task execution is offloaded to a ProcessPoolExecutor. Worker processes need to initialize the tesseract API themselves, since they don't inherit locally constructed endpoints and schemas from the main process.
As it stands, this is intended as a draft to see if it meets the required needs. Once that is confirmed, there are a few technical points to look into:
tesseract_core/runtime/schema_generation.py
.Testing done
Simple local testing done
TODO: Ensure CI covers asynchronous AND synchronous endpoints