Skip to content

feat: async. HTTP communication in tesseract REST API #225

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

linusseelinger
Copy link
Contributor

@linusseelinger linusseelinger commented Jun 16, 2025

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:

  • Honor the user-specified number of workers.
  • Possibly avoid redundant checking when serializing/deserializing inputs and outputs when passing between worker and main process.
  • Either accept or avoid the changes in tesseract_core/runtime/schema_generation.py.
  • Attaching schemas to endpoint functions works (and is actually kind of elegant here) but probably not good practice. Any cleaner approach?
  • General clean-up iteration.

Testing done

Simple local testing done
TODO: Ensure CI covers asynchronous AND synchronous endpoints

@PasteurBot
Copy link
Contributor

PasteurBot commented Jun 16, 2025

CLA signatures confirmed

All contributors have signed the Contributor License Agreement.
Posted by the CLA Assistant Lite bot.

@linusseelinger
Copy link
Contributor Author

@PasteurBot I have read the CLA Document and I hereby sign the CLA

@jpbrodrick89
Copy link
Contributor

@linusseelinger let me know if the validator stuff becomes a bottleneck/blocker at an point, I have a draft PR (not pushed) for some of the validation stuff (mainly (co)tangent vectors) that I de-prioritised, not sure whether this is relevant or not.

@linusseelinger
Copy link
Contributor Author

linusseelinger commented Jun 17, 2025

Nice @jpbrodrick89 :) Honestly, at this point, I have no idea how performance relevant the redundant validation is here. Maybe we can work around that all together (seems unlikely though); if no, would be great to see your approach!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants