meilisearch / meilisearch-python

Python wrapper for the Meilisearch API
https://meilisearch.com
MIT License
465 stars 85 forks source link

Support for asyncio in the official Python SDK #414

Open icnahom opened 2 years ago

icnahom commented 2 years ago

Description A way to have an asynchronous friendly (non-blocking) Python APIs.

Basic example Can be used with other async enabled web server/framework like Sanic or FastAPI.

Other How Elasticsearch built their python client is described here. They are using libraries like aiohttp, and unasync.

icnahom commented 2 years ago

https://github.com/ziyoubaba/aiomeilisearch this one looks good, but it would be great if we can have up-to-date support in this official python sdk.

sanders41 commented 2 years ago

It's not part of this sdk like you are asking, but I maintain an async Python client here https://github.com/sanders41/meilisearch-python-async that is up-to-date with the latest release of Meilisearch.

icnahom commented 2 years ago

@sanders41 Nice! May I ask why it's not part of this sdk? Would be great if it's supported because we can follow up and learn with the official meilisearch documentation.

sanders41 commented 2 years ago

I am a contributor to this SDK, but not a Meilisearch employee so I'll answer with that in mind. @alallema and @brunoocasali feel free to correct anything I get wrong.

This SDK was built from the ground up as a synchronous client, so adding async support would be a big re-write. Then trying to support both async and sync in the same client would make that re-write and future maintenance more difficult. @alallema is the main Meilisearch maintainer of this client, and she also maintains the DigitialOcean, AWS, GCP, php, Java, and Kubernetes SDKs (I may have some wrong and may have missed some, but you get the point...it's a lot). So with that there are only so many things they can maintain themselves.

While there are a few differences between this SDK and my async SDK in the way parameters are passed and values are returned, everything that is supported here is also supported there so the Meilisearch documentation will be very close to the same way to do it. There is specific documentation available here where you can see differences.

If you feel like anything is missing or unclear contributions are always welcome.

alallema commented 2 years ago

Hi @icnahom, Thanks for this feedback. I totally agree with sanders answer, indeed rewriting the python SDK to handle synchronous and asynchronous would be a huge work and the maintenance would be heavy. This is for the moment not something we are considering knowing that @sanders maintains for the moment an asynchronous client. And Thank you @sanders for your answer ❤️ By the way your SDK should be on amwesome-meilisearch. You can do a PR directly on the repo or I will ask the team in charge of it ⭐

pawarren commented 6 months ago

would be lovely to have async support merged in at some point!

sanders41 commented 6 months ago

As far as I know there is still no plan to add async support here. For async use this SDK.