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

community[minor]: Add async methods to AstraDBCache #17415

Merged
merged 2 commits into from
Feb 15, 2024

Conversation

cbornet
Copy link
Collaborator

@cbornet cbornet commented Feb 12, 2024

No description provided.

@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Feb 12, 2024
Copy link

vercel bot commented Feb 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Feb 14, 2024 1:04pm

@dosubot dosubot bot added Ɑ: memory Related to memory module 🤖:improvement Medium size change to existing code to handle new use-cases labels Feb 12, 2024
@baskaryan baskaryan requested a review from eyurtsev February 13, 2024 00:19
Copy link
Collaborator

@eyurtsev eyurtsev left a 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):
Copy link
Collaborator

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator

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:
Copy link
Collaborator

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

Copy link
Contributor

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.

Copy link
Collaborator Author

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(
Copy link
Collaborator

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)

Copy link
Collaborator Author

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:
Copy link
Collaborator

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

async_astra_db_client: Optional[AsyncAstraDB] = None,
namespace: Optional[str] = None,
setup_mode: SetupMode = SetupMode.SYNC,
pre_delete_collection: bool = False,
Copy link
Collaborator

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? :)

@dosubot dosubot bot added the lgtm PR looks good. Use to confirm that a PR is ready for merging. label Feb 15, 2024
@eyurtsev eyurtsev changed the title Add async methods to AstraDBCache community: Add async methods to AstraDBCache Feb 15, 2024
@eyurtsev eyurtsev merged commit ca2d407 into langchain-ai:master Feb 15, 2024
58 checks passed
@eyurtsev eyurtsev changed the title community: Add async methods to AstraDBCache community[minor]: Add async methods to AstraDBCache Feb 15, 2024
@cbornet cbornet deleted the astra-async-cache branch February 15, 2024 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:improvement Medium size change to existing code to handle new use-cases lgtm PR looks good. Use to confirm that a PR is ready for merging. Ɑ: memory Related to memory module size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants