-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
fix(vector_stores): elasticsearch - add missing await #11089
Conversation
@@ -239,7 +239,7 @@ async def _create_index_if_not_exists( | |||
index_name: Name of the AsyncElasticsearch index to create. | |||
dims_length: Length of the embedding vectors. | |||
""" | |||
if self.client.indices.exists(index=index_name): | |||
if await self.client.indices.exists(index=index_name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually removed this because in another version of the elastic client, this was synchronous
Can we figure out which version has this synchronous and pin the version in pyproject.toml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@logan-markewich thanks for the review
I see that the ES client being used is actually the async one here
which is also mentioned when providing it as a paramater here
What say you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi. I am having the same issue with the method not being awaited. What is the best way to get this change on my machine? I am a C# developer and I am finding my way with python :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@afederici75 this fix is not merged yet -- was hoping we could narrow down proper requirements on the client version (since in some client version, this isn't async, as seen in the issue linked above)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking maybe to wrap the function with asyncio.coroutine, so both clients will work when calling the functions with await
.
What do you say?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@logan-markewich thank you. I temporarily changed the code in the imported package and it seems to work for now.
Description
vector_stores
@ elasticsearch - Added missing await for indices.exists function call.solves:
/llama_index/vector_stores/elasticsearch/base.py:344: RuntimeWarning: coroutine 'IndicesClient.exists' was never awaited
- which causes not creating the ES index.Fixes # (issue)
Type of Change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Suggested Checklist:
make format; make lint
to appease the lint gods