-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Using existing exceptions defined and newly defined exceptions to alter behavior of the get_collection
, create_collection and
delete_collection` methods
#991
Conversation
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
chromadb/errors.py
Outdated
@@ -32,6 +32,13 @@ def name(cls) -> str: | |||
return "InvalidCollection" | |||
|
|||
|
|||
class CollectionAlreadyExistsError(ChromaError): |
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.
@bhashithe-air, this is great but can we make things a bit more RESTful-ish by adding the response code. Here is an example:
class CollectionNotFoundError(ChromaError):
@overrides
def code(self) -> int:
return 409 # Conflict with current state
@classmethod
@overrides
def name(cls) -> str:
return "CollectionNotFound"
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.
Yes let me add this part in as well
@bhashithe-air thank you very much for the PR. I think the issue you have identified around the consistency of the API is important with people deploying Chroma extensively in a Client/Server mode. Please have a look at my review comments regarding response codes and a new error for collection not found. |
@tazarov Thanks! What do you think about the |
Well, it's about consistency, cognitive load and intuitive of the code. While I understand your point |
It does seem counter intuitive yes, i am in favor of your suggestion to use a new exception. But yes, we shall wait for @HammadB :) |
I agree the InvalidCollectionException is underdefined, I prefer NotFound and more prescriptive errors. |
@bhashithe-air, It looks better now :). One suggestion for future PRs - please setup GPG and sign your commits |
Thanks @tazarov, just learnt about the GPG signing for commits, I will make sure to sign my commits in the future. Do you think anything else is needed for this PR? should i look at the whole repo and see if we need to define anything new? |
LGTM. There are many other things to "fix" on the API but this is a step in the right direction. @HammadB wdyt? |
@bhashithe-air, can you rebase off main so tests can pass? |
@tazarov I synced just now. |
@tazarov what is the latest on this? |
@bhashithe-air, can you rebase/merge from the main so things are up to date, or give me write access to your repo so that I can do it? |
@tazarov I added you to the repository. Do not have too much time to work on it today. |
Thank you @bhashithe-air, I will rebase this shortly. |
@bhashithe-air, I redid your PR from a non-main branch in a new PR #1618. Feel free to close this one. |
Description of changes
get_collection
,delete_collection
andcreate_collection
methods raised aValueError
. This was descriptive for the user to find what the error was but was inconvenient because it was the same Exception type for two different scenarios.Resolves #982
Summarize the changes made by this PR.
chromadb.errors
calledInvalidCollectionException
we raise that in the two methods.chromadb.errors
calledCollectionAlreadyExistsError
and raise that in the respective function