Skip to content

feat(weaviate): add tenant support in write_documents with tests (syn…#3056

Open
Akash504-ai wants to merge 10 commits intodeepset-ai:mainfrom
Akash504-ai:feat/weaviate-multitenancy
Open

feat(weaviate): add tenant support in write_documents with tests (syn…#3056
Akash504-ai wants to merge 10 commits intodeepset-ai:mainfrom
Akash504-ai:feat/weaviate-multitenancy

Conversation

@Akash504-ai
Copy link
Copy Markdown
Contributor

Related Issues

Proposed Changes

  • Added tenant support to write_documents and write_documents_async
  • Updated internal batch write logic to pass tenant parameter correctly
  • Enables basic multi-tenancy support for Weaviate document store
  • Added tests for tenant support in:
    • sync document store
    • async document store

How did you test it?

  • Added integration tests for:
    • test_write_documents_with_tenant
    • test_write_documents_with_tenant_async
  • Verified no regression in default (non-tenant) behavior
  • Did not run full Weaviate integration locally, relying on CI for validation

Notes for the reviewer

  • Changes are minimal and focused on tenant support in write operations
  • Both sync and async flows are covered
  • Backward compatible (no tenant → existing behavior unchanged)

Checklist

  • I have read the contributors guidelines and code of conduct
  • I have updated the related issue
  • I added tests
  • I used a conventional commit message

@Akash504-ai Akash504-ai requested a review from a team as a code owner March 26, 2026 09:30
@Akash504-ai Akash504-ai requested review from julian-risch and removed request for a team March 26, 2026 09:31
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 26, 2026

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added integration:weaviate type:documentation Improvements or additions to documentation labels Mar 26, 2026
@Akash504-ai Akash504-ai force-pushed the feat/weaviate-multitenancy branch from 1fe6aeb to 73e97f2 Compare March 26, 2026 17:53
Copy link
Copy Markdown
Member

@julian-risch julian-risch left a comment

Choose a reason for hiding this comment

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

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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's keep this link

: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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's keep this link

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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's keep this link

raise ValueError(msg)

try:
collection = self.collection # ✅ FIX
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
collection = self.collection # ✅ FIX
collection = self.collection

vector = obj.vector

self.collection.data.replace(
collection.data.replace( # ✅ FIX
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
collection.data.replace( # ✅ FIX
collection.data.replace(

import base64
import logging
import os
import platform
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
import platform

doc = Document(content="tenant test doc")

# Write with tenant
written = document_store.write_documents([doc], tenant="tenant1")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This test could check if _write_async get's called with the expected tenant parameter value.

Comment on lines -967 to -969

Documents with the same id will be overwritten.
Raises in case of errors.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please keep comments that are not related to tenant_support unchanged in this pull request.

Comment on lines -960 to -961
# If the document already exists we get no status message back from Weaviate.
# So we assume that all Documents were written.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please keep comments that are not related to tenant_support unchanged in this pull request.

@Akash504-ai
Copy link
Copy Markdown
Contributor Author

Thanks for the suggestion! Initially I implemented the test using _write_async mocking, but it was not aligned with the current implementation and caused CI failures.
I updated the test to validate the actual behavior instead. Let me know if you'd prefer keeping the internal call assertion happy to adjust accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:weaviate type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Weaviate: Consider Adding support for multi tenancy

3 participants