-
Notifications
You must be signed in to change notification settings - Fork 16.8k
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
community[minor]: Add async methods to AstraDBCache #17415
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
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.
Nice! Thank you for the PR. A few nit comments
) | ||
|
||
|
||
class AstraDBCollectionEnvironment(AstraDBEnvironment): |
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.
- Would you mind adding doc-strings explaining what this is?
- Could we prefix this with a
_
to mark is as an internal object? I don't think that we expect most LangChain users to know about this object?
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.
done
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.
ah it was public because it's used in other files (obvious, but I missed that lol). I don't think we have a great convention right now with respect to public/private. I still prefer erring on the side of private and prioritize what users see as public
if async_setup: | ||
async_astra_db = self.async_astra_db | ||
|
||
async def _setup_db() -> None: |
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.
The code block seems to force a network request during initialization.
I left a comment about this above. We don't necessarily need to do anything at this stage, but could be good to allow a developer to opt-out from the init somehow for more advanced use cases
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.
FYI, the Cassandra vector store is about to receive a skip_provisioning: bool = False
flag for exactly that purpose. There might be a same-named parameter here.
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.
added SetupMode param (SYNC, ASYNC, OFF)
""" | ||
astra_env = AstraDBEnvironment( | ||
self.astra_env = AstraDBCollectionEnvironment( |
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.
FYI: #17242 -- will make it possible to set caches at request time, so we'll be more likely to see repeated instantiation of objects.
AstraDBCollectionEnvironment makes a network request on every init. OK for now, but could become expensive if user re-instantiates the cache repeatedly (which I think they should be allowed to do)
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.
added SetupMode param (SYNC, ASYNC, OFF)
_unset = ["unset"] | ||
|
||
|
||
class CachedAwaitable: |
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.
If these are internal could we prefix them with _
and add a quick doc-string explaining how they are used?
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.
done
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.
Thank you!
1b2b7f1
to
6f638fb
Compare
async_astra_db_client: Optional[AsyncAstraDB] = None, | ||
namespace: Optional[str] = None, | ||
setup_mode: SetupMode = SetupMode.SYNC, | ||
pre_delete_collection: bool = False, |
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.
do only i find pre_delete_collection
scary? :)
No description provided.