pymilvus icon indicating copy to clipboard operation
pymilvus copied to clipboard

[FEATURE]: asyncio support

Open belkka opened this issue 2 years ago • 11 comments
trafficstars

Is there an existing issue for this?

  • [X] I have searched the existing issues

Is your feature request related to a problem? Please describe.

Is there any chance that PR adding asyncio support will be accepted?

If yes, do maintainers have a vision of how should it be implemented? E. g. create async version of existing classes like AsyncCollection with same interface as Collection, but async versions of methods like async def search(...). Or maybe add an optional argument def search(_awaitable: bool = False) similar to existing _async, but forcing the method to return an awaitable instead of future object? Or implement something like async def async_search(...) in existing Collection class.

Describe the solution you'd like

No response

Describe alternatives you've considered

Also, do you have considerations related to desired implementation? E. g. is it okay to implement asyncio support as a simple wrapper around asgiref and add asgiref as a project dependency (which may be not so elegant solution)?

Anything else?

There was an issue on this topic, but author closed it (probably, because found a solution for their use-case)

https://github.com/milvus-io/pymilvus/issues/1190

belkka avatar Jan 17 '23 13:01 belkka

Is there an existing issue for this?

  • [x] I have searched the existing issues

Is your feature request related to a problem? Please describe.

Is there any chance that PR adding asyncio support will be accepted?

If yes, do maintainers have a vision of how should it be implemented? E. g. create async version of existing classes like AsyncCollection with same interface as Collection, but async versions of methods like async def search(...). Or maybe add an optional argument def search(_awaitable: bool = False) similar to existing _async, but forcing the method to return an awaitable instead of future object? Or implement something like async def async_search(...) in existing Collection class.

Describe the solution you'd like

No response

Describe alternatives you've considered

Also, do you have considerations related to desired implementation? E. g. is it okay to implement asyncio support as a simple wrapper around asgiref and add asgiref as a project dependency (which may be not so elegant solution)?

Anything else?

There was an issue on this topic, but author closed it (probably, because found a solution for their use-case)

#1190

Most of the pymilvus already support async.

If you look at search params, you will see _async and _callback params, I guess that's what you are looking for

xiaofan-luan avatar Jan 21 '23 01:01 xiaofan-luan

I would say user could do it by themselves. Since pymilvus is hard to control the threadpool size or what. But on the other side, maybe we can have some example about how to maintain pool to work with Milvus? @XuanYang-cn @filip-halt

xiaofan-luan avatar Jan 21 '23 02:01 xiaofan-luan

actually I still think async style would be better. one actor can submit request asyncly and another actor check the result

xiaofan-luan avatar Jan 21 '23 02:01 xiaofan-luan

AFAIK, all the pymilvus calls are blocking so you should run them on another thread (await loop.run_in_executor(coro)). However, this approach seems to be not so efficient compared with ordinary async-await logics. So async-module for pymilvus is highly desirable feature, agree with @belkka.

VitalyPetrov avatar Jan 23 '23 08:01 VitalyPetrov

This is also relevant to my use case, it looks like this got prioritised for the 2.3.0 release?

HennerM avatar Apr 27 '23 10:04 HennerM

should think about it. Anyone want to contribute on it?

xiaofan-luan avatar Apr 28 '23 02:04 xiaofan-luan

should think about it. Anyone want to contribute on it?

I'm willing to contribute. Any heads-up before I start contributing, other than the stuff mentioned in CONTRIBUTING.md

jinayshah86 avatar Jun 24 '23 12:06 jinayshah86

I was checking out this Pull Request, for the async support, any reason it is stuck ?

mistborn17 avatar Sep 14 '23 02:09 mistborn17

@mistborn17 looks like at some point maintainers wanted to deprecate orm module (in dev branch), so I stopped working on the PR. Apparently, they changed their mind later. Though, I have not received feedback about whether or not I should continue working in same direction/do they like selected approach (interface/implementation). Right now PR has some minor conflicts (type annotations were added into master since then).

belkka avatar Sep 15 '23 08:09 belkka

async,await like I think is good. Can anyone continue working on this?orz

danyang-rainbow avatar Feb 05 '24 03:02 danyang-rainbow

Anyone volunteered?

xiaofan-luan avatar Feb 05 '24 05:02 xiaofan-luan