Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: weaviate handles lowercase index names #1711

Merged
merged 2 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docarray/index/backends/weaviate.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,16 @@
}
)

def __post_init__(self):
# To prevent errors, it is important to capitalize the provided index name
# when working with Weaviate, as it stores index names in a capitalized format.
# Can't use .capitalize() because it modifies the whole string (See test).
self.index_name = (

Check warning on line 264 in docarray/index/backends/weaviate.py

View check run for this annotation

Codecov / codecov/patch

docarray/index/backends/weaviate.py#L264

Added line #L264 was not covered by tests
self.index_name[0].upper() + self.index_name[1:]
if self.index_name
else None
)

@dataclass
class RuntimeConfig(BaseDocIndex.RuntimeConfig):
"""Dataclass that contains all "dynamic" configurations of WeaviateDocumentIndex."""
Expand Down
6 changes: 6 additions & 0 deletions tests/index/weaviate/test_column_config_weaviate.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,9 @@ class StringDoc(BaseDoc):

index = WeaviateDocumentIndex[StringDoc]()
assert index.index_name == StringDoc.__name__

index = WeaviateDocumentIndex[StringDoc](index_name='BaseDoc')
assert index.index_name == 'BaseDoc'

index = WeaviateDocumentIndex[StringDoc](index_name='index_name')
assert index.index_name == 'Index_name'
Loading