similie / fastapi-ml-wrapper

FastApi web wrapper for running python ML Models
GNU General Public License v3.0
0 stars 0 forks source link

Implement the web hook callbacks interface #6

Open s-g-1 opened 5 months ago

s-g-1 commented 5 months ago

Describe the solution you'd like src/interfaces/ReqRes.py contains class definitions for a web hook system, including POST request models. The BasePredictor class contains some functions for implementing these web hooks (e.g. for long running inference tasks).

The current situation Currently, POST requests have an optional web hook field that is ignored in all cases. The required functionality would be to add a conditional branch to API routes such that requests that contain a web hook model are added to a BackgroundTasks queue (https://fastapi.tiangolo.com/tutorial/background-tasks/) with an appropriate HTTP status code (received) and message. When the background task has finished, it should call the end-point in the web hook, setting HTTP headers as necessary.

Describe alternatives you've considered The current situation is to await a POST request.

s-g-1 commented 4 months ago

Linked to issue 16, enhance tests for Predictor classes. Note: see docs in the respx library for setting a Starlette application as a side-effect: https://lundberg.github.io/respx/guide/#route-with-an-app