-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Validate add
to prevent duplicate IDs.
#363
Conversation
@levand let's find time to review in person |
15643da
to
25d451f
Compare
metadatas: List[types.Metadata] | ||
documents: List[types.Document] | ||
|
||
|
||
class EmbeddingStateMachine(RuleBasedStateMachine): |
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.
Rename TestCollectionContents
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.
Can do as a separate PR.
self._add_embeddings(embedding_set) | ||
return multiple(*embedding_set["ids"]) | ||
if set(embedding_set["ids"]).intersection(set(self.embeddings["ids"])): | ||
with pytest.raises(ValueError): |
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.
Test that the value error is correct.
@@ -129,8 +160,8 @@ def _add_embeddings(self, embeddings: strategies.EmbeddingSet): | |||
else: | |||
documents = [None] * len(embeddings["ids"]) | |||
|
|||
self.embeddings["metadatas"].extend(metadatas) # type: ignore | |||
self.embeddings["documents"].extend(documents) # type: ignore | |||
self.embeddings["metadatas"] += metadatas # type: ignore |
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.
Revert this bit.
def test_dup_add(api): | ||
api.reset() | ||
coll = api.create_collection(name="foo") | ||
with pytest.raises(ValueError): |
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.
Create more specific error type.
35f93c2
to
693a53a
Compare
Reviewed in-person with @atroyn and incorporated feedback prior to merging. |
Description of changes
Throw errors if the user attempts to add duplicate IDs, either via separate calls to
Collection.add
or the same one.Test plan
This branch is based of #355 which contains failing tests for this functionality.
Documentation Changes
chroma-core/docs#42