pulp / pulpcore

Pulp 3 pulpcore package https://pypi.org/project/pulpcore/
GNU General Public License v2.0
261 stars 107 forks source link

Evaluate django-ninja as a DRF replacement #3793

Open dralley opened 1 year ago

dralley commented 1 year ago

Don't freak out or take it too seriously, emphasis on "evaluate". This is probably a pulpcore 3.40 change at the earliest and might not ultimately be realistic.

DRF is verbose and doesn't deal with situations like https://github.com/pulp/pulpcore/issues/2138 well (or some of the optimizations that Gerrod has added). The particular way it separates serializers and viewsets make some optimizations and features which we need very difficult. Additionally the inclusion of type annotations in Python has opened up a lot of new ergonomic approaches which weren't available at the time.

django-ninja is a FastAPI-style framework built on top of Django (instead of Starlette like FastAPI is). In my personal subjective opinion, it is far far nicer than DRF. It works with both async and non-async code, but is designed for async first, whereas DRF has no real roadmap for async except through an entirely new package

https://django-ninja.rest-framework.com/

The main challenges would be:

daviddavis commented 1 year ago

We use fastapi and I like it a lot. Being able to use pydantic and Python's type hinting is quite helpful, and I find running mypy catches a lot of problems.

We did evaluate django-ninja but ultimately chose fastapi as we didn't need full blown ORM like django as we only have a few data models so we use sqlalchemy, which is mediocre but probably more lightweight than django. Since Pulp relies heavily on django for data modeling, I think django-ninja might be a good fit and it definitely seems to have grown since the last time I checked it out.

ggainey commented 1 year ago

The question I have is whether this is a 3.40 change, or a "Pulp4" change. It won't be impacting just the plugin-promise - it sounds like it'll change the openapi spec as well, and that would make me lean towards "Pulp4"

Lots of discussion/brainstorming to be had, let's hold it here.