feat: Added IBM Db2 vector store integration#3518
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Hey @bogdankostic I was already reviewing this in #3458 (comment) so I'll take this over |
| Use inside a Haystack pipeline after a text embedder:: | ||
|
|
||
| pipeline.add_component("embedder", SentenceTransformersTextEmbedder()) | ||
| pipeline.add_component("retriever", Db2EmbeddingRetriever( | ||
| document_store=store, top_k=5 | ||
| )) | ||
| pipeline.connect("embedder.embedding", "retriever.query_embedding") |
There was a problem hiding this comment.
Please wrap python code in code blocks.
There was a problem hiding this comment.
Done! The example in the class docstring is now wrapped in a .. code-block:: python directive.
There was a problem hiding this comment.
Sorry I didn't provide more context in my earlier comment but could we enclose with triple-backticks instead of .. code-block::. Our API doc strings don't support the .. code-block:: syntax.
…ove obsolete test_from_dict_without_filter_policy test
|
Hey @priyanshu-krishnan1 and @GeetikaChughIBM thanks for the updates! @GeetikaChughIBM would it be possible for you to sign the CLA agreement as well? #3518 (comment) |
* test: replace live DB fixture with mocked Db2DocumentStore in serialization tests * refactor: move util method unit tests to test_document_store.py and delete test_document_store_unit.py * Remove dead code: unreachable return in count_unique_metadata_by_filter_async * Fix typo: ____cause__ -> __cause__ in hasattr check * Move empty documents check after isinstance check in write_documents * Add missing LICENSE.txt (Apache 2.0) to ibm_db integration * Wrap Python example in proper code-block directive in Db2EmbeddingRetriever docstring * Convert run() docstring to Haystack :param:/:returns: style in Db2EmbeddingRetriever * Add missing __init__ docstring with :param:/:raises: to Db2EmbeddingRetriever * Add full :param:/:returns: docstring to run_async() in Db2EmbeddingRetriever * Simplify README to lightweight format following the conventions * Fix line length in run_async() docstring to pass fmt-check --------- Co-authored-by: priyanshu-krishnan1 <priyanshu.krishnan1@ibm.com>
…ecret for credentials * refactor(ibm_db): inline connection params and use Secret for credentials Remove the Db2ConnectionConfig dataclass and pass connection parameters directly to Db2DocumentStore.__init__(). username and password are now required Secret values (oracle-style) and are serialized as env-var references, never as plaintext. Tests use Secret.from_token in the live fixture; serialization tests build their own env-var-backed store. * refactor(ibm_db): rename Db2DocumentStore/Db2EmbeddingRetriever to IBMDb2 prefix Renames the public classes to IBMDb2DocumentStore and IBMDb2EmbeddingRetriever (and their test classes), updating imports, __all__ exports, serialization type strings, and docstrings.
Added |
|
Hi @sjrl, we have addressed all the review comments, please provide your feedback. |
| def test_write_documents(self, document_store: IBMDb2DocumentStore): | ||
| """Test basic write with duplicate handling - default policy is NONE.""" | ||
| doc = Document(content="test doc") | ||
| assert document_store.write_documents([doc]) == 1 | ||
| # Default policy is NONE — a second write of the same doc raises DuplicateDocumentError | ||
| with pytest.raises(DuplicateDocumentError): | ||
| document_store.write_documents([doc]) |
There was a problem hiding this comment.
test_write_documents currently shadows WriteDocumentsTest.test_write_documents
from the mixin.
Could you rename it (e.g. test_write_documents_default_policy_none) so the mixin's version still runs?
There was a problem hiding this comment.
I've renamed the original test_write_documents to test_write_documents_default_policy_none as suggested, and added a separate test_write_documents override to satisfy the mixin's required hook - it just asserts that a basic write returns 1. I think now the mixin's version runs, and the duplicate-rejection behaviour (DuplicateDocumentError) is now tested independently in test_write_documents_default_policy_none.
| database: str, | ||
| hostname: str, | ||
| username: Secret, | ||
| password: Secret, |
There was a problem hiding this comment.
It could be nice to set default values for these like
| password: Secret, | |
| username: Secret = Secret.from_env_var("DB2_USERNAME"), | |
| password: Secret = Secret.from_env_var("DB2_PASSWORD"), |
There was a problem hiding this comment.
Both username and password now default to Secret.from_env_var("DB2_USERNAME") and Secret.from_env_var("DB2_PASSWORD") respectively.
|
Hey @GeetikaChughIBM thanks for addressing all of the comments! I have a few minor ones left and then this is good to go! |
|
|
||
| Use inside a Haystack pipeline after a text embedder: | ||
|
|
||
| .. code-block:: python |
There was a problem hiding this comment.
Our api docstrings don't support this type of markdown .. code-block:: python so could we switch to using the triple-backticks with the python tag?
There was a problem hiding this comment.
Okay, switched to triple-backtick fenced code block (```python) in the docstring.
| :param query_embedding: Dense float vector from an embedder component. | ||
| :param filters: Runtime filters, merged with constructor filters according to filter_policy. | ||
| :param top_k: Override the constructor top_k for this call. | ||
| :returns: A dictionary with key ``documents`` containing a list of matching :class:`Document` objects. |
There was a problem hiding this comment.
| :returns: A dictionary with key ``documents`` containing a list of matching :class:`Document` objects. | |
| :returns: A dictionary with key `documents` containing a list of matching :class:`Document` objects. |
There was a problem hiding this comment.
Done.. changed to documents in the :returns: docstring.
| Booleans are stored in JSON as ``true``/``false`` and read back by ``JSON_VALUE`` as the | ||
| lowercase strings ``'true'``/``'false'``. ibm_db would otherwise bind a Python bool as the | ||
| integer ``1``/``0``, so the comparison would never match. Convert it explicitly. |
There was a problem hiding this comment.
Please only use single backticks for inline code comments
| Booleans are stored in JSON as ``true``/``false`` and read back by ``JSON_VALUE`` as the | |
| lowercase strings ``'true'``/``'false'``. ibm_db would otherwise bind a Python bool as the | |
| integer ``1``/``0``, so the comparison would never match. Convert it explicitly. | |
| Booleans are stored in JSON as `true`/`false` and read back by `JSON_VALUE` as the | |
| lowercase strings `'true'`/`'false'`. ibm_db would otherwise bind a Python bool as the | |
| integer `1`/`0`, so the comparison would never match. Convert it explicitly. |
There was a problem hiding this comment.
Done! now using single backticks for inline code comments
* fix: replace placeholder copyright with 'Copyright 2023-present deepset GmbH' in LICENSE.txt * fix: remove CHANGELOG.md * fix: rename test_write_documents to test_write_documents_default_policy_none to avoid shadowing mixin * fix: add default Secret env var values for username and password params * fix: replace code-block directive with triple-backtick markdown in docstring * fix: use single backticks for 'documents' key in :returns: docstring * fix: replace double backticks with single backticks in inline code comments in filters.py * fix: add test_write_documents mixin override and separate test_write_documents_default_policy_none
Related Issues
Proposed Changes:
Added a new integration for IBM Db2 database with vector search capabilities:
How did you test it?
Notes for the reviewer
Checklist
feat: Add IBM Db2 vector store integration