feat(weaviate): add tenant support in write_documents with tests (syn…#3056
feat(weaviate): add tenant support in write_documents with tests (syn…#3056Akash504-ai wants to merge 10 commits intodeepset-ai:mainfrom
Conversation
1fe6aeb to
73e97f2
Compare
julian-risch
left a comment
There was a problem hiding this comment.
Hello @Akash504-ai Thank you for opening this pull request. I have a couple of smaller change requests, which I explain in more detail below. Please keep comments that are not related to tenant_support unchanged in this pull request. Other than that the code changes look quite good to me already.
|
|
||
| :param filters: The filters to apply to select documents for deletion. | ||
| For filter syntax, see [Haystack metadata filtering](https://docs.haystack.deepset.ai/docs/metadata-filtering) | ||
| For filter syntax, see Haystack metadata filtering docs. |
| :param filters: The filters to apply to select documents for deletion. | ||
| For filter syntax, see [Haystack metadata filtering](https://docs.haystack.deepset.ai/docs/metadata-filtering) | ||
| :returns: The number of documents deleted. | ||
| :param filters: Filters to select documents for deletion. |
| For filter syntax, see [Haystack metadata filtering](https://docs.haystack.deepset.ai/docs/metadata-filtering) | ||
| :param meta: The metadata fields to update. These will be merged with existing metadata. | ||
| :returns: The number of documents updated. | ||
| :param filters: Filters to select documents for updating. |
| raise ValueError(msg) | ||
|
|
||
| try: | ||
| collection = self.collection # ✅ FIX |
There was a problem hiding this comment.
| collection = self.collection # ✅ FIX | |
| collection = self.collection |
| vector = obj.vector | ||
|
|
||
| self.collection.data.replace( | ||
| collection.data.replace( # ✅ FIX |
There was a problem hiding this comment.
| collection.data.replace( # ✅ FIX | |
| collection.data.replace( |
| import base64 | ||
| import logging | ||
| import os | ||
| import platform |
There was a problem hiding this comment.
| import platform |
| doc = Document(content="tenant test doc") | ||
|
|
||
| # Write with tenant | ||
| written = document_store.write_documents([doc], tenant="tenant1") |
There was a problem hiding this comment.
this test could check that _write get's called with the expected tenant parameter value.
| async def test_write_documents_with_tenant_async(self, document_store): | ||
| doc = Document(content="tenant test doc") | ||
|
|
||
| written = await document_store.write_documents_async([doc], tenant="tenant1") |
There was a problem hiding this comment.
This test could check if _write_async get's called with the expected tenant parameter value.
|
|
||
| Documents with the same id will be overwritten. | ||
| Raises in case of errors. |
There was a problem hiding this comment.
Please keep comments that are not related to tenant_support unchanged in this pull request.
| # If the document already exists we get no status message back from Weaviate. | ||
| # So we assume that all Documents were written. |
There was a problem hiding this comment.
Please keep comments that are not related to tenant_support unchanged in this pull request.
|
Thanks for the suggestion! Initially I implemented the test using |
Related Issues
Proposed Changes
write_documentsandwrite_documents_asyncHow did you test it?
test_write_documents_with_tenanttest_write_documents_with_tenant_asyncNotes for the reviewer
Checklist