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

[ENH]: Adding close() method to clients #1792

Closed

Conversation

tazarov
Copy link
Contributor

@tazarov tazarov commented Feb 29, 2024

Refs: #1756, Also (https://discord.com/channels/1073293645303795742/1209706648243929128)

Description of changes

Summarize the changes made by this PR.

  • New functionality
    • Ability to close persistent/HttpClients

Test plan

How are these changes tested?

  • Tests pass locally with pytest for python

Documentation Changes

TBD

Copy link

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

Copy link
Contributor

@beggers beggers left a comment

Choose a reason for hiding this comment

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

I don't understand the use-case here. Why would someone want to shut down their system without just destroying the object?

@tazarov
Copy link
Contributor Author

tazarov commented Mar 15, 2024

@beggers, there are two issues that users have reported:

While close() might not be the silver bullet here, allowing resources to be freed without making assumptions about how users use Chroma can be beneficial.

Copy link
Contributor

@beggers beggers left a comment

Choose a reason for hiding this comment

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

My main concern here is that this puts Clients and Servers into a weird and inconsistent state where they can't do anything. Could we instead call this close_connections() and have it kill open network connections?

@tazarov
Copy link
Contributor Author

tazarov commented Mar 15, 2024

For HTTP/Cloud clients, that makes sense; the intent is clear. What are your thoughts about PersistentClient?

@beggers
Copy link
Contributor

beggers commented Mar 15, 2024

PersistentClient doesn't make any network connections IIUC. So it should be a no-op and probably raise an error explaining.

@tazarov
Copy link
Contributor Author

tazarov commented Mar 15, 2024

Actually, the issue with PersistentClient (see above) is that it keeps open files - the SQLite3 db (at least one handle), 4 handles for each open index. The problem for some apps is that they rely on being able to clean up resources e.g. open files.

One challenge I see with implementing close_connections() is that we expose ServerAPI for all clients, meaning that if the abstract method is added at ServerAPI or any of the inherited interfaces, we'll have to implement it (even if no-op) for all clients. We can potentially create a wrapper interface that is specific to the client type and exposes the appropriate methods for resource clean-up. Wdyt?

@tazarov tazarov marked this pull request as ready for review March 15, 2024 19:28
@HammadB
Copy link
Collaborator

HammadB commented Mar 20, 2024

This makes sense to me, whats the UX for

  • double close
  • and use after close

@tazarov tazarov force-pushed the feature/close-persistent-client branch from 25f52b1 to 55b73a9 Compare March 21, 2024 10:56
@tazarov tazarov force-pushed the feature/close-persistent-client branch from 2173199 to 0e35813 Compare March 21, 2024 13:08
@ArslanSaleem
Copy link

@tazarov when this PR is expected to be merged, is anything left in this PR?

@tazarov
Copy link
Contributor Author

tazarov commented Sep 17, 2024

Closing in favor of #2581

@tazarov tazarov closed this Sep 17, 2024
@jeffchuber
Copy link
Contributor

@tazarov i think you linked the wrong issue here?

@tazarov
Copy link
Contributor Author

tazarov commented Sep 17, 2024

@jeffchuber, updated to #2581

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants