Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…n-client into implement-async-client
  • Loading branch information
tsmith023 committed Jul 1, 2024
2 parents 7bb2dae + 18d94fc commit 21b89a6
Show file tree
Hide file tree
Showing 71 changed files with 1,665 additions and 500 deletions.
23 changes: 14 additions & 9 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ env:
WEAVIATE_123: 1.23.16
WEAVIATE_124: 1.24.19
WEAVIATE_125: 1.25.5
WEAVIATE_126: 1.26.0-rc.0



jobs:
Expand Down Expand Up @@ -121,13 +123,14 @@ jobs:
fail-fast: false
matrix:
versions: [
{ py: "3.8", weaviate: $WEAVIATE_125},
{ py: "3.9", weaviate: $WEAVIATE_125},
{ py: "3.10", weaviate: $WEAVIATE_125},
{ py: "3.8", weaviate: $WEAVIATE_126},
{ py: "3.9", weaviate: $WEAVIATE_126},
{ py: "3.10", weaviate: $WEAVIATE_126},
{ py: "3.11", weaviate: $WEAVIATE_123},
{ py: "3.11", weaviate: $WEAVIATE_124},
{ py: "3.11", weaviate: $WEAVIATE_125},
{ py: "3.12", weaviate: $WEAVIATE_125}
{ py: "3.11", weaviate: $WEAVIATE_126},
{ py: "3.12", weaviate: $WEAVIATE_126}
]
optional_dependencies: [false]
steps:
Expand Down Expand Up @@ -172,13 +175,14 @@ jobs:
fail-fast: false
matrix:
versions: [
{ py: "3.8", weaviate: $WEAVIATE_125},
{ py: "3.9", weaviate: $WEAVIATE_125},
{ py: "3.10", weaviate: $WEAVIATE_125},
{ py: "3.8", weaviate: $WEAVIATE_126},
{ py: "3.9", weaviate: $WEAVIATE_126},
{ py: "3.10", weaviate: $WEAVIATE_126},
{ py: "3.11", weaviate: $WEAVIATE_123},
{ py: "3.11", weaviate: $WEAVIATE_124},
{ py: "3.11", weaviate: $WEAVIATE_125},
{ py: "3.12", weaviate: $WEAVIATE_125}
{ py: "3.11", weaviate: $WEAVIATE_126},
{ py: "3.12", weaviate: $WEAVIATE_126}
]
optional_dependencies: [false]
steps:
Expand Down Expand Up @@ -313,7 +317,8 @@ jobs:
server: [
$WEAVIATE_123,
$WEAVIATE_124,
$WEAVIATE_125
$WEAVIATE_125,
$WEAVIATE_126
]
steps:
- name: Download build artifact to append to release
Expand Down
2 changes: 1 addition & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ This patch version includes:
- Support for new modules in Weaviate 1.24.2:
- ``text2vec-voyageai``
- ``generative-mistral``
- Support new parameters for interference URLs in ``text2vec-transformers`` and ``multi2vec-clip``
- Support new parameters for inference URLs in ``text2vec-transformers`` and ``multi2vec-clip``
- Support for new modules in Weaviate 1.24.3:
- ``multi2vec-palm``

Expand Down
106 changes: 80 additions & 26 deletions integration/test_collection_config.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from typing import Generator

import pytest as pytest
import pytest

import weaviate
from integration.conftest import OpenAICollection, CollectionFactory
from integration.conftest import _sanitize_collection_name
from weaviate.collections.classes.config import (
_BQConfig,
_SQConfig,
_CollectionConfig,
_CollectionConfigSimple,
_PQConfig,
Expand Down Expand Up @@ -137,6 +138,7 @@ def test_collection_config_empty(collection_factory: CollectionFactory) -> None:
assert config.multi_tenancy_config.enabled is False

assert config.replication_config.factor == 1
assert config.replication_config.async_enabled is False

assert isinstance(config.vector_index_config, _VectorIndexConfigHNSW)
assert config.vector_index_config.cleanup_interval_seconds == 300
Expand Down Expand Up @@ -190,6 +192,7 @@ def test_collection_config_defaults(collection_factory: CollectionFactory) -> No
assert config.multi_tenancy_config.enabled is True

assert config.replication_config.factor == 1
assert config.replication_config.async_enabled is False

assert isinstance(config.vector_index_config, _VectorIndexConfigHNSW)
assert config.vector_index_config.cleanup_interval_seconds == 300
Expand Down Expand Up @@ -242,7 +245,7 @@ def test_collection_config_full(collection_factory: CollectionFactory) -> None:
multi_tenancy_config=Configure.multi_tenancy(
enabled=True, auto_tenant_activation=True, auto_tenant_creation=True
),
# replication_config=Configure.replication(factor=2), # currently not updateable in RAFT
replication_config=Configure.replication(factor=2, async_enabled=True),
vector_index_config=Configure.VectorIndex.hnsw(
cleanup_interval_seconds=10,
distance_metric=VectorDistances.DOT,
Expand Down Expand Up @@ -311,13 +314,20 @@ def test_collection_config_full(collection_factory: CollectionFactory) -> None:
assert config.inverted_index_config.stopwords.removals == ["the"]

assert config.multi_tenancy_config.enabled is True
if collection._connection._weaviate_version.is_at_least(1, 25, 0):
if collection._connection._weaviate_version.is_at_least(1, 25, 2):
assert config.multi_tenancy_config.auto_tenant_activation is True
# change to 1.25.2 after it is out
if collection._connection._weaviate_version.is_at_least(1, 25, patch=1):
else:
assert config.multi_tenancy_config.auto_tenant_activation is False
if collection._connection._weaviate_version.is_at_least(1, 25, 1):
assert config.multi_tenancy_config.auto_tenant_creation is True
else:
assert config.multi_tenancy_config.auto_tenant_creation is False

# assert config.replication_config.factor == 2
assert config.replication_config.factor == 2
if collection._connection._weaviate_version.is_at_least(1, 26, 0):
assert config.replication_config.async_enabled is True
else:
assert config.replication_config.async_enabled is False

assert isinstance(config.vector_index_config, _VectorIndexConfigHNSW)
assert isinstance(config.vector_index_config.quantizer, _PQConfig)
Expand Down Expand Up @@ -357,12 +367,10 @@ def test_collection_config_update(collection_factory: CollectionFactory) -> None
config = collection.config.get()

assert config.replication_config.factor == 1
assert config.replication_config.async_enabled is False
assert config.multi_tenancy_config.enabled is True
if collection._connection._weaviate_version.is_at_least(1, 25, 0):
assert config.multi_tenancy_config.auto_tenant_activation is False
# change to 1.25.2 after it is out
if collection._connection._weaviate_version.is_at_least(1, 25, patch=1):
assert config.multi_tenancy_config.auto_tenant_creation is False
assert config.multi_tenancy_config.auto_tenant_activation is False
assert config.multi_tenancy_config.auto_tenant_creation is False

collection.config.update(
description="Test",
Expand All @@ -374,7 +382,9 @@ def test_collection_config_update(collection_factory: CollectionFactory) -> None
stopwords_preset=StopwordsPreset.EN,
stopwords_removals=["the"],
),
# replication_config=Reconfigure.replication(factor=2), # currently not updateable in RAFT
replication_config=Reconfigure.replication(
factor=2, async_enabled=True
), # currently not updateable in RAFT
vectorizer_config=Reconfigure.VectorIndex.hnsw(
vector_cache_max_objects=2000000,
quantizer=Reconfigure.VectorIndex.Quantizer.pq(
Expand All @@ -392,15 +402,25 @@ def test_collection_config_update(collection_factory: CollectionFactory) -> None

config = collection.config.get()

# assert config.description == "Test"
if collection._connection._weaviate_version.is_at_least(
1, 25, 2
) or collection._connection._weaviate_version.is_lower_than(1, 25, 0):
assert config.description == "Test"
else:
assert config.description is None

assert config.inverted_index_config.bm25.b == 0.8
assert config.inverted_index_config.bm25.k1 == 1.25
assert config.inverted_index_config.cleanup_interval_seconds == 10
# assert config.inverted_index_config.stopwords.additions is ["a"] # potential weaviate bug, this returns as None
assert config.inverted_index_config.stopwords.removals == ["the"]

# assert config.replication_config.factor == 2
assert config.replication_config.factor == 2

if collection._connection._weaviate_version.is_at_least(1, 26, 0):
assert config.replication_config.async_enabled is True
else:
assert config.replication_config.async_enabled is False

assert isinstance(config.vector_index_config, _VectorIndexConfigHNSW)
assert isinstance(config.vector_index_config.quantizer, _PQConfig)
Expand All @@ -425,11 +445,16 @@ def test_collection_config_update(collection_factory: CollectionFactory) -> None
assert config.vector_index_type == VectorIndexType.HNSW

assert config.multi_tenancy_config.enabled is True
if collection._connection._weaviate_version.is_at_least(1, 25, 0):

if collection._connection._weaviate_version.is_at_least(1, 25, 2):
assert config.multi_tenancy_config.auto_tenant_activation is True
# change to 1.25.2 after it is out
if collection._connection._weaviate_version.is_at_least(1, 25, patch=1):
else:
assert config.multi_tenancy_config.auto_tenant_activation is False

if collection._connection._weaviate_version.is_at_least(1, 25, 1):
assert config.multi_tenancy_config.auto_tenant_creation is True
else:
assert config.multi_tenancy_config.auto_tenant_creation is False

collection.config.update(
vectorizer_config=Reconfigure.VectorIndex.hnsw(
Expand All @@ -438,15 +463,25 @@ def test_collection_config_update(collection_factory: CollectionFactory) -> None
)
config = collection.config.get()

# assert config.description == "Test"
if collection._connection._weaviate_version.is_at_least(
1, 25, 2
) or collection._connection._weaviate_version.is_lower_than(1, 25, 0):
assert config.description == "Test"
else:
assert config.description is None

assert config.inverted_index_config.bm25.b == 0.8
assert config.inverted_index_config.bm25.k1 == 1.25
assert config.inverted_index_config.cleanup_interval_seconds == 10
# assert config.inverted_index_config.stopwords.additions is ["a"] # potential weaviate bug, this returns as None
assert config.inverted_index_config.stopwords.removals == ["the"]

# assert config.replication_config.factor == 2
assert config.replication_config.factor == 2

if collection._connection._weaviate_version.is_at_least(1, 26, 0):
assert config.replication_config.async_enabled is True
else:
assert config.replication_config.async_enabled is False

assert isinstance(config.vector_index_config, _VectorIndexConfigHNSW)
assert config.vector_index_config.cleanup_interval_seconds == 300
Expand All @@ -466,14 +501,16 @@ def test_collection_config_update(collection_factory: CollectionFactory) -> None


def test_hnsw_with_bq(collection_factory: CollectionFactory) -> None:
dummy = collection_factory("dummy")
if dummy._connection._weaviate_version.is_lower_than(1, 24, 0):
pytest.skip("BQ+HNSW is not supported in Weaviate versions lower than 1.24.0")

collection = collection_factory(
vector_index_config=Configure.VectorIndex.hnsw(
vector_cache_max_objects=5,
quantizer=Configure.VectorIndex.Quantizer.bq(rescore_limit=10),
),
)
if collection._connection._weaviate_version.is_lower_than(1, 24, 0):
pytest.skip("BQ+HNSW is not supported in Weaviate versions lower than 1.24.0")

config = collection.config.get()
assert config.vector_index_type == VectorIndexType.HNSW
Expand All @@ -482,6 +519,25 @@ def test_hnsw_with_bq(collection_factory: CollectionFactory) -> None:
assert isinstance(config.vector_index_config.quantizer, _BQConfig)


def test_hnsw_with_sq(collection_factory: CollectionFactory) -> None:
dummy = collection_factory("dummy")
if dummy._connection._weaviate_version.is_lower_than(1, 26, 0):
pytest.skip("SQ+HNSW is not supported in Weaviate versions lower than 1.26.0")

collection = collection_factory(
vector_index_config=Configure.VectorIndex.hnsw(
vector_cache_max_objects=5,
quantizer=Configure.VectorIndex.Quantizer.sq(rescore_limit=10, training_limit=1000000),
),
)

config = collection.config.get()
assert config.vector_index_type == VectorIndexType.HNSW
assert config.vector_index_config is not None
assert isinstance(config.vector_index_config, _VectorIndexConfigHNSW)
assert isinstance(config.vector_index_config.quantizer, _SQConfig)


def test_update_flat(collection_factory: CollectionFactory) -> None:
collection = collection_factory(
vector_index_config=Configure.VectorIndex.flat(
Expand Down Expand Up @@ -640,14 +696,12 @@ def test_config_vector_index_hnsw_and_quantizer_pq(collection_factory: Collectio
],
)
def test_config_reranker_module(
client: weaviate.WeaviateClient,
collection_factory: CollectionFactory,
reranker_config: _RerankerConfigCreate,
expected_reranker: Rerankers,
expected_model: dict,
) -> None:
client.collections.delete("TestCollectionConfigRerankerModule")
collection = client.collections.create(
name="TestCollectionConfigRerankerModule",
collection = collection_factory(
reranker_config=reranker_config,
vectorizer_config=Configure.Vectorizer.none(),
)
Expand Down Expand Up @@ -712,7 +766,7 @@ def test_config_export_and_recreate_from_dict(collection_factory: CollectionFact
Property(name="age", data_type=DataType.INT),
],
multi_tenancy_config=Configure.multi_tenancy(enabled=True),
replication_config=Configure.replication(factor=1),
replication_config=Configure.replication(factor=1, async_enabled=False),
vector_index_config=Configure.VectorIndex.hnsw(
quantizer=Configure.VectorIndex.Quantizer.pq(centroids=256)
),
Expand Down
2 changes: 1 addition & 1 deletion integration/test_collection_multi_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_consistency_on_multinode(
properties=[
Property(name="name", data_type=DataType.TEXT),
],
replication_config=Configure.replication(factor=2),
replication_config=Configure.replication(factor=2, async_enabled=False),
ports=(8087, 50058),
).with_consistency_level(level)

Expand Down
Loading

0 comments on commit 21b89a6

Please sign in to comment.