A FastAPI/ASGI middleware to simplify development of FastAPI apps on DataRobot
Project description
DataRobot ASGI Middleware
A middleware to simplify front-proxy handling and health checks in DataRobot.
Usage
Simply add to your FastAPI application that you expect to run in DataRobot
from fastapi import FastAPI
from datarobot_asgi_middleware import DataRobotASGIMiddleware
app = FastAPI()
app.add_middleware(DataRobotASGIMiddleware)
@app.get("/")
async def root():
return {"message": "hello"}
Doing so will enable the automatic URLs such as docs/ and
openapi.json to work as expected both in DataRobot and locally.
If you'd like to do proper Kubernetes health checks to let DataRobot
know your application is healthy, the middleware adds a way to tell
DataRobot to use a specific health URL endpoint like:/healthto validate your app is
working as expected using
kube-probe.
So, similar to the example above, but this time with health_endpoint="/health":
from fastapi import FastAPI
from datarobot_asgi_middleware import DataRobotASGIMiddleware
app = FastAPI()
app.add_middleware(DataRobotASGIMiddleware, health_endpoint="/health")
@app.get("/")
async def root():
return {"message": "hello"}
@app.get("/health")
async def health():
# Check on database connections, memory utilization, etc. If it returns
# any error code like a 404 or 500, the app is marked as unhealthy
return {"status": "healthy"}
Development
Development is designed to run with uv and Taskfile/go-task.
You can run tests, linters, etc. by setting these two up to work together
Testing realistically with Traefic
To test through a DataRobot-like proxy the examples/basic folder it contains a basic app and traefik configuration
to start up with docker-compose -f examples/basic/docker-compose.yml up from the repo root folder, and validate by going to http://localhost:9999/front-proxy or run the baked-in task for it with:
task run-example-basic
Technically DataRobot does a double front-proxy for applications, so this configuration mimics the double proxy with one traefic instance.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file datarobot_asgi_middleware-0.2.0.tar.gz.
File metadata
- Download URL: datarobot_asgi_middleware-0.2.0.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44588d6b16a8420ed8b6b8a198a8326be61f48d39a27f7df1a6511dc319b467b
|
|
| MD5 |
4595993b8f82fcdac6334dd7b25ad3ca
|
|
| BLAKE2b-256 |
3710b7651ffa919c76ec808db0af521e30e43adb18af9f4ee2413a4f854e7b6f
|
File details
Details for the file datarobot_asgi_middleware-0.2.0-py3-none-any.whl.
File metadata
- Download URL: datarobot_asgi_middleware-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac6f999a568c04964673d6f2f5134e2ce4ad67ef3eebb4c2896981c0f5291493
|
|
| MD5 |
94d23c93ec53f17a5f008e6d9ff3b9a1
|
|
| BLAKE2b-256 |
429cdf8319321f8b606580cc0dab2884dcf58373aa567b8539c4a0681c96dfcc
|