From cd14a599e08cc7a9ce3ad53e6408d95d822df885 Mon Sep 17 00:00:00 2001 From: Eric Hare Date: Mon, 11 Mar 2024 10:51:14 -0700 Subject: [PATCH 1/6] Astra DB: Add integration usage tracking --- .../document_stores/astra/astra_client.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/integrations/astra/src/haystack_integrations/document_stores/astra/astra_client.py b/integrations/astra/src/haystack_integrations/document_stores/astra/astra_client.py index c1eb1f6a7..e320288d0 100644 --- a/integrations/astra/src/haystack_integrations/document_stores/astra/astra_client.py +++ b/integrations/astra/src/haystack_integrations/document_stores/astra/astra_client.py @@ -12,6 +12,11 @@ NON_INDEXED_FIELDS = ["metadata._node_content", "content"] +# For version tracking +from haystack import __name__ as integration_name +from haystack.version import __version__ as integration_version + + @dataclass class Response: document_id: str @@ -64,7 +69,13 @@ def __init__( self.namespace = namespace # Build the Astra DB object - self._astra_db = AstraDB(api_endpoint=api_endpoint, token=token, namespace=namespace) + self._astra_db = AstraDB( + api_endpoint=api_endpoint, + token=token, + namespace=namespace, + caller_name=integration_name, + caller_version=integration_version, + ) try: # Create and connect to the newly created collection From b07d5d74196b8b1f6f446ca72e919b7c39e12f30 Mon Sep 17 00:00:00 2001 From: Eric Hare Date: Mon, 11 Mar 2024 10:54:18 -0700 Subject: [PATCH 2/6] Update astra_client.py --- .../document_stores/astra/astra_client.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/integrations/astra/src/haystack_integrations/document_stores/astra/astra_client.py b/integrations/astra/src/haystack_integrations/document_stores/astra/astra_client.py index e320288d0..4272c69d1 100644 --- a/integrations/astra/src/haystack_integrations/document_stores/astra/astra_client.py +++ b/integrations/astra/src/haystack_integrations/document_stores/astra/astra_client.py @@ -7,16 +7,16 @@ from astrapy.db import AstraDB from pydantic.dataclasses import dataclass -logger = logging.getLogger(__name__) - -NON_INDEXED_FIELDS = ["metadata._node_content", "content"] - - # For version tracking from haystack import __name__ as integration_name from haystack.version import __version__ as integration_version +logger = logging.getLogger(__name__) + +NON_INDEXED_FIELDS = ["metadata._node_content", "content"] + + @dataclass class Response: document_id: str From 8844f21cb3550eeecc7e71310a02f81f8153a4e6 Mon Sep 17 00:00:00 2001 From: Eric Hare Date: Mon, 11 Mar 2024 10:55:31 -0700 Subject: [PATCH 3/6] Update requirements.txt --- integrations/astra/examples/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integrations/astra/examples/requirements.txt b/integrations/astra/examples/requirements.txt index 284fd46fe..21aec1397 100644 --- a/integrations/astra/examples/requirements.txt +++ b/integrations/astra/examples/requirements.txt @@ -1,4 +1,4 @@ haystack-ai==2.0.0b4 sentence_transformers==2.2.2 openai==1.6.1 -astrapy>=0.7.0 \ No newline at end of file +astrapy>=0.7.7 \ No newline at end of file From b07c29affe5e40a3a902577043cf2023dc24e44f Mon Sep 17 00:00:00 2001 From: Eric Hare Date: Mon, 11 Mar 2024 11:17:24 -0700 Subject: [PATCH 4/6] Fix sorting of imports for ruff linting --- .../document_stores/astra/astra_client.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/integrations/astra/src/haystack_integrations/document_stores/astra/astra_client.py b/integrations/astra/src/haystack_integrations/document_stores/astra/astra_client.py index 4272c69d1..2549719d6 100644 --- a/integrations/astra/src/haystack_integrations/document_stores/astra/astra_client.py +++ b/integrations/astra/src/haystack_integrations/document_stores/astra/astra_client.py @@ -5,12 +5,11 @@ from astrapy.api import APIRequestError from astrapy.db import AstraDB -from pydantic.dataclasses import dataclass # For version tracking from haystack import __name__ as integration_name from haystack.version import __version__ as integration_version - +from pydantic.dataclasses import dataclass logger = logging.getLogger(__name__) From c9282055d4bfa5196ef0b26943ff8ce5ee072c54 Mon Sep 17 00:00:00 2001 From: Eric Hare Date: Tue, 12 Mar 2024 10:35:33 -0700 Subject: [PATCH 5/6] Hardcode the caller name --- .../document_stores/astra/astra_client.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/integrations/astra/src/haystack_integrations/document_stores/astra/astra_client.py b/integrations/astra/src/haystack_integrations/document_stores/astra/astra_client.py index 2549719d6..ff7086515 100644 --- a/integrations/astra/src/haystack_integrations/document_stores/astra/astra_client.py +++ b/integrations/astra/src/haystack_integrations/document_stores/astra/astra_client.py @@ -6,14 +6,13 @@ from astrapy.api import APIRequestError from astrapy.db import AstraDB -# For version tracking -from haystack import __name__ as integration_name from haystack.version import __version__ as integration_version from pydantic.dataclasses import dataclass logger = logging.getLogger(__name__) NON_INDEXED_FIELDS = ["metadata._node_content", "content"] +CALLER_NAME = 'haystack' @dataclass @@ -72,7 +71,7 @@ def __init__( api_endpoint=api_endpoint, token=token, namespace=namespace, - caller_name=integration_name, + caller_name=CALLER_NAME, caller_version=integration_version, ) From 6f2e8f847aa6a2498ebb1d187c1039106a82409a Mon Sep 17 00:00:00 2001 From: Eric Hare Date: Tue, 12 Mar 2024 10:39:26 -0700 Subject: [PATCH 6/6] Update astra_client.py --- .../document_stores/astra/astra_client.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/integrations/astra/src/haystack_integrations/document_stores/astra/astra_client.py b/integrations/astra/src/haystack_integrations/document_stores/astra/astra_client.py index ff7086515..fc5f4b6c9 100644 --- a/integrations/astra/src/haystack_integrations/document_stores/astra/astra_client.py +++ b/integrations/astra/src/haystack_integrations/document_stores/astra/astra_client.py @@ -5,14 +5,13 @@ from astrapy.api import APIRequestError from astrapy.db import AstraDB - from haystack.version import __version__ as integration_version from pydantic.dataclasses import dataclass logger = logging.getLogger(__name__) NON_INDEXED_FIELDS = ["metadata._node_content", "content"] -CALLER_NAME = 'haystack' +CALLER_NAME = "haystack" @dataclass