-
Notifications
You must be signed in to change notification settings - Fork 105
Add Hfresh index type #1848
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
Merged
Merged
Add Hfresh index type #1848
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
8957d61
add spfresh to python client
robbespo00 f1abc27
add enum for centroids index type in spfresh
robbespo00 9518b8f
Add missing init parameter for spfresh
rlmanrique 896c333
Fix spfresh params in config of the class
rlmanrique 59a1317
Add missing multivector param for spfresh
rlmanrique f07d50d
Fix multivector
rlmanrique 2bcd33c
Fix update spfresh method
rlmanrique c188305
remove centroids index type
robbespo00 fdefaa4
add spfresh to python client
robbespo00 ffc98b3
add enum for centroids index type in spfresh
robbespo00 1059b43
Add missing init parameter for spfresh
rlmanrique 2cdc5e8
Fix spfresh params in config of the class
rlmanrique e8847a8
Add missing multivector param for spfresh
rlmanrique e735a58
Fix multivector
rlmanrique 88c276c
Fix update spfresh method
rlmanrique 6d6afeb
remove centroids index type
robbespo00 fb49f84
Rename spfresh to hfresh
rlmanrique e37ada4
Merge branch 'rob/spfresh' of https://github.com/weaviate/weaviate-py…
robbespo00 f46fc4a
remove centroids index type
robbespo00 09ab4bb
Merge remote-tracking branch 'origin/main' into rob/spfresh
robbespo00 545168c
use max posting size kb
robbespo00 b24f14c
Merge remote-tracking branch 'origin/main' into rob/spfresh
robbespo00 d4baec8
remove rng factor
robbespo00 0252f7f
run ruff linter and formatting
robbespo00 01b3158
add D417
robbespo00 e4a1273
remove distance metric
robbespo00 9f6f5c2
Merge remote-tracking branch 'origin/main' into rob/spfresh
robbespo00 68fb441
Merge branch 'main' into rob/spfresh
rlmanrique 83076f8
Merge branch 'main' into rob/spfresh
rlmanrique 8d90ee5
Merge branch 'main' into rob/spfresh
rlmanrique 268aae2
Add test for HFresh collection creation
rlmanrique 82e7071
remove unused imports
robbespo00 401ddd4
Merge branch 'dev/1.36' into rob/spfresh
dirkkul 4686e46
add new tests
robbespo00 5d40551
run ruff linter
robbespo00 461b963
ruff check
robbespo00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| import pytest | ||
| import weaviate | ||
| from integration.conftest import CollectionFactory | ||
| from weaviate.collections.classes.config import ( | ||
| Configure, | ||
| Reconfigure, | ||
| VectorDistances, | ||
| VectorIndexType, | ||
| Vectorizers, | ||
| _VectorIndexConfigHFresh, | ||
| ) | ||
|
|
||
|
|
||
| def test_collection_config_hfresh(collection_factory: CollectionFactory) -> None: | ||
| collection_dummy = collection_factory("dummy") | ||
| if collection_dummy._connection._weaviate_version.is_lower_than(1, 36, 0): | ||
| pytest.skip("Hfresh index is not supported in Weaviate versions lower than 1.36.0") | ||
|
|
||
| collection = collection_factory( | ||
| vector_index_config=Configure.VectorIndex.hfresh( | ||
| distance_metric=VectorDistances.COSINE, | ||
| max_posting_size_kb=1024, | ||
| replicas=2, | ||
| search_probe=50, | ||
| ) | ||
| ) | ||
|
|
||
| config = collection.config.get() | ||
|
|
||
| assert config.vector_index_type == VectorIndexType.HFRESH | ||
| assert isinstance(config.vector_index_config, _VectorIndexConfigHFresh) | ||
| assert config.vector_index_config.distance_metric == VectorDistances.COSINE | ||
| assert config.vector_index_config.max_posting_size_kb == 1024 | ||
| assert config.vector_index_config.replicas == 2 | ||
| assert config.vector_index_config.search_probe == 50 | ||
dirkkul marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| def test_collection_named_vectors_hfresh(collection_factory: CollectionFactory) -> None: | ||
| collection_dummy = collection_factory("dummy") | ||
| if collection_dummy._connection._weaviate_version.is_lower_than(1, 36, 0): | ||
| pytest.skip("Hfresh index is not supported in Weaviate versions lower than 1.36.0") | ||
|
|
||
| collection = collection_factory( | ||
| vector_config=[ | ||
| Configure.Vectors.self_provided( | ||
| name="title_vec", | ||
| vector_index_config=Configure.VectorIndex.hfresh( | ||
| distance_metric=VectorDistances.COSINE, | ||
| max_posting_size_kb=512, | ||
| replicas=1, | ||
| search_probe=25, | ||
| ), | ||
| ), | ||
| ], | ||
| ) | ||
|
|
||
| config = collection.config.get() | ||
|
|
||
| assert config.vector_config is not None | ||
| assert "title_vec" in config.vector_config | ||
|
|
||
| title_config = config.vector_config["title_vec"] | ||
| assert title_config.vectorizer.vectorizer == Vectorizers.NONE | ||
| assert isinstance(title_config.vector_index_config, _VectorIndexConfigHFresh) | ||
| assert title_config.vector_index_config.distance_metric == VectorDistances.COSINE | ||
| assert title_config.vector_index_config.max_posting_size_kb == 512 | ||
| assert title_config.vector_index_config.replicas == 1 | ||
| assert title_config.vector_index_config.search_probe == 25 | ||
|
|
||
|
|
||
| def test_collection_update_hfresh(collection_factory: CollectionFactory) -> None: | ||
| collection_dummy = collection_factory("dummy") | ||
| if collection_dummy._connection._weaviate_version.is_lower_than(1, 36, 0): | ||
| pytest.skip("Hfresh index is not supported in Weaviate versions lower than 1.36.0") | ||
|
|
||
| collection = collection_factory( | ||
| vector_index_config=Configure.VectorIndex.hfresh( | ||
| distance_metric=VectorDistances.COSINE, | ||
| max_posting_size_kb=512, | ||
| replicas=1, | ||
| search_probe=25, | ||
| ) | ||
| ) | ||
|
|
||
| config = collection.config.get() | ||
| assert isinstance(config.vector_index_config, _VectorIndexConfigHFresh) | ||
| assert config.vector_index_config.max_posting_size_kb == 512 | ||
| assert config.vector_index_config.replicas == 1 | ||
| assert config.vector_index_config.search_probe == 25 | ||
|
|
||
| collection.config.update(vectorizer_config=Reconfigure.VectorIndex.hfresh(search_probe=100)) | ||
|
|
||
| config = collection.config.get() | ||
| assert isinstance(config.vector_index_config, _VectorIndexConfigHFresh) | ||
| assert config.vector_index_config.max_posting_size_kb == 512 | ||
| assert config.vector_index_config.replicas == 1 | ||
| assert config.vector_index_config.search_probe == 100 | ||
|
|
||
|
|
||
| def test_collection_hfresh_export_and_reimport(collection_factory: CollectionFactory) -> None: | ||
| collection_dummy = collection_factory("dummy") | ||
| if collection_dummy._connection._weaviate_version.is_lower_than(1, 36, 0): | ||
| pytest.skip("Hfresh index is not supported in Weaviate versions lower than 1.36.0") | ||
|
|
||
| collection = collection_factory( | ||
| vector_index_config=Configure.VectorIndex.hfresh( | ||
| distance_metric=VectorDistances.COSINE, | ||
| max_posting_size_kb=1024, | ||
| replicas=2, | ||
| search_probe=50, | ||
| ) | ||
| ) | ||
|
|
||
| config = collection.config.get() | ||
|
|
||
| name = f"TestHFreshExportAndReimport_{collection.name}" | ||
| config.name = name | ||
| with weaviate.connect_to_local() as client: | ||
| client.collections.delete(name) | ||
| client.collections.create_from_dict(config.to_dict()) | ||
| new = client.collections.use(name).config.get() | ||
| assert config == new | ||
| assert config.to_dict() == new.to_dict() | ||
| client.collections.delete(name) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.