From 5b0c0efdc1c8c502214d0ee99f9264454042b7f5 Mon Sep 17 00:00:00 2001 From: Chris Knight Date: Wed, 1 May 2024 13:33:37 +0100 Subject: [PATCH 1/4] fix: Weaviate schema class name conversion which preserves PascalCase --- .../document_stores/weaviate/document_store.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/integrations/weaviate/src/haystack_integrations/document_stores/weaviate/document_store.py b/integrations/weaviate/src/haystack_integrations/document_stores/weaviate/document_store.py index ec66e07c3..1b6e95155 100644 --- a/integrations/weaviate/src/haystack_integrations/document_stores/weaviate/document_store.py +++ b/integrations/weaviate/src/haystack_integrations/document_stores/weaviate/document_store.py @@ -166,7 +166,9 @@ def __init__( } else: # Set the class if not set - collection_settings["class"] = collection_settings.get("class", "default").capitalize() + _class_name = collection_settings.get("class", "Default") + _class_name = _class_name[0].upper() + _class_name[1:] + collection_settings["class"] = _class_name # Set the properties if they're not set collection_settings["properties"] = collection_settings.get("properties", DOCUMENT_COLLECTION_PROPERTIES) From 1208bda263533fdc25a88dfe9e0fe6347a9c4714 Mon Sep 17 00:00:00 2001 From: "David S. Batista" Date: Fri, 3 May 2024 11:35:34 +0200 Subject: [PATCH 2/4] adding a test case for schema name conversion --- .../weaviate/tests/test_document_store.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/integrations/weaviate/tests/test_document_store.py b/integrations/weaviate/tests/test_document_store.py index cc76923f6..d07b62305 100644 --- a/integrations/weaviate/tests/test_document_store.py +++ b/integrations/weaviate/tests/test_document_store.py @@ -664,3 +664,20 @@ def test_filter_documents_over_default_limit(self, document_store): document_store.write_documents(docs) with pytest.raises(DocumentStoreError): document_store.filter_documents({"field": "content", "operator": "==", "value": "This is some content"}) + + def test_schema_class_name_conversion_preserves_pascal_case(self, document_store): + collection_settings = {"class": "CaseDocument"} + doc_score = WeaviateDocumentStore( + url="http://localhost:8080", + collection_settings=collection_settings, + ) + assert doc_score._collection_settings['class'] == "CaseDocument" + + collection_settings = {"class": "lower_case_name"} + doc_score = WeaviateDocumentStore( + url="http://localhost:8080", + collection_settings=collection_settings, + ) + assert doc_score._collection_settings['class'] == "Lower_case_name" + + From 04c5d31f074e65aa04aaf94095cb97bf84d3a6c8 Mon Sep 17 00:00:00 2001 From: "David S. Batista" Date: Fri, 3 May 2024 11:40:01 +0200 Subject: [PATCH 3/4] linting --- integrations/weaviate/tests/test_document_store.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/integrations/weaviate/tests/test_document_store.py b/integrations/weaviate/tests/test_document_store.py index d07b62305..d0aa37135 100644 --- a/integrations/weaviate/tests/test_document_store.py +++ b/integrations/weaviate/tests/test_document_store.py @@ -665,19 +665,19 @@ def test_filter_documents_over_default_limit(self, document_store): with pytest.raises(DocumentStoreError): document_store.filter_documents({"field": "content", "operator": "==", "value": "This is some content"}) - def test_schema_class_name_conversion_preserves_pascal_case(self, document_store): + def test_schema_class_name_conversion_preserves_pascal_case(self): collection_settings = {"class": "CaseDocument"} doc_score = WeaviateDocumentStore( url="http://localhost:8080", collection_settings=collection_settings, ) - assert doc_score._collection_settings['class'] == "CaseDocument" + assert doc_score._collection_settings["class"] == "CaseDocument" collection_settings = {"class": "lower_case_name"} doc_score = WeaviateDocumentStore( url="http://localhost:8080", collection_settings=collection_settings, ) - assert doc_score._collection_settings['class'] == "Lower_case_name" + assert doc_score._collection_settings["class"] == "Lower_case_name" From 8b73372f79fc2665c441a7c5a2acb5bf259fc236 Mon Sep 17 00:00:00 2001 From: "David S. Batista" Date: Fri, 3 May 2024 11:45:37 +0200 Subject: [PATCH 4/4] formatting --- integrations/weaviate/tests/test_document_store.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/integrations/weaviate/tests/test_document_store.py b/integrations/weaviate/tests/test_document_store.py index d0aa37135..59a6ed2e3 100644 --- a/integrations/weaviate/tests/test_document_store.py +++ b/integrations/weaviate/tests/test_document_store.py @@ -679,5 +679,3 @@ def test_schema_class_name_conversion_preserves_pascal_case(self): collection_settings=collection_settings, ) assert doc_score._collection_settings["class"] == "Lower_case_name" - -