Skip to main content

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.

Release files for datarobot-asgi-middleware 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for datarobot-asgi-middleware 0.2.0
File Size Uploaded
datarobot_asgi_middleware-0.2.0.tar.gz 14.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for datarobot-asgi-middleware 0.2.0
File Interpreter ABI Platform
datarobot_asgi_middleware-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.1 kB

Release files / datarobot_asgi_middleware-0.2.0.tar.gz

Download URL datarobot_asgi_middleware-0.2.0.tar.gz
Size 14.0 kB
Tags Source
SHA-256 checksum
How to use checksums
44588d6b16a8420ed8b6b8a198a8326be61f48d39a27f7df1a6511dc319b467b
BLAKE2b-256 checksum
How to use checksums
3710b7651ffa919c76ec808db0af521e30e43adb18af9f4ee2413a4f854e7b6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.13

Release files / datarobot_asgi_middleware-0.2.0-py3-none-any.whl

Download URL datarobot_asgi_middleware-0.2.0-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ac6f999a568c04964673d6f2f5134e2ce4ad67ef3eebb4c2896981c0f5291493
BLAKE2b-256 checksum
How to use checksums
429cdf8319321f8b606580cc0dab2884dcf58373aa567b8539c4a0681c96dfcc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.13

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page