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

[Bug]: Async operation is not working as expected for search in collection by using pymilvus #2264

Open
1 task done
V-N-Bhat opened this issue Sep 17, 2024 · 0 comments
Open
1 task done
Labels
kind/bug Something isn't working

Comments

@V-N-Bhat
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I am trying to perform searching in the collection asynchronously and using pymilvus by passing _async as true along with a call back function it was running in the sync way instead of async . And tried to run the same collection.search. on different threads then also the database it self is running the search operation one by one .

Expected Behavior

The queries should run parallel or asynchronously.

Steps/Code To Reproduce behavior

def milvus_search(embedding_query):
    collection = Collection("bank")
    return collection.search(data=[embedding_query],
                                      anns_field="vector",
                                      param=search_params,
                                      limit=10,
                                      kwargs={"_async": True, "_callback": handle_result}
                                      )

async def search() -> SearchResult:
    embedding_function = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")
    embedding_query = embedding_function.embed_query("sso")
    search_future = await asyncio.to_thread(
        milvus_search,
        embedding_query
    )
return search_future


async def something() -> None:
    start =time.time()

    search_tasks = [search() for _ in range(2)]
    await asyncio.gather(*search_tasks)
    end = time.time()

    print(f"took{start - end} ")


if __name__ == "__main__":
    asyncio.run(something())

Environment details

- Hardware/Softward conditions (OS, CPU, GPU, Memory):
- Method of installation (Docker, or from source):
- Milvus version (v0.3.1, or v0.4.0):
- Milvus configuration (Settings you made in `server_config.yaml`):

Anything else?

No response

@V-N-Bhat V-N-Bhat added the kind/bug Something isn't working label Sep 17, 2024
@V-N-Bhat V-N-Bhat changed the title [Bug]: Async operation is not supported for search in collection [Bug]: Async operation is not working as expected for search in collection by using pymilvus Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant