Skip to content
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

Support Pydantic models #322

Open
danielgafni opened this issue Jun 6, 2024 · 0 comments
Open

Support Pydantic models #322

danielgafni opened this issue Jun 6, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@danielgafni
Copy link

Is your feature request related to a problem? Please describe.
runpod is built on top of FastAPI, yet it currently doesn't support one of FastAPI's main features: automatic serialization/deserialization with Pydantic models.

It would be really useful it such support existed. This would make writing code for RunPod less error-prone, increase type-checking coverage, and simplify migration from existing FastAPI endpoints.

Describe the solution you'd like
I would like to be able to write code similar to:

from runpod import EndpointRequest
from pydantic import BaseModel

class MyRequest(BaseModel):
    foo: str

class MyResponse(BaseModel):
    bar: float

def handler(request: EndpointRequest[MyRequest] ) -> MyReponse:
    # type-checkers should recognize this as an instance of MyRequest (with the help of the generic annotation above)
    my_data = request.input
    ...
    return MyReponse(...)

Describe alternatives you've considered
Currently there is no clean way of integrating existing FastAPI endpoints to RunPod.
They have to be rewritten, and data has to be parsed manually.

@danielgafni danielgafni added the enhancement New feature or request label Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant