Skip to content

Commit 819c799

Browse files
author
macronova
committed
Fix tests
1 parent 6214126 commit 819c799

2 files changed

Lines changed: 31 additions & 15 deletions

File tree

chromadb/test/api/test_schema.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,9 +1876,7 @@ def test_error_handling_invalid_operations(self) -> None:
18761876
schema.create_index(config=fts_config, key="#document")
18771877

18781878
# Test 3: Cannot disable all indexes globally (no config, no key)
1879-
with pytest.raises(
1880-
ValueError, match="Cannot disable all indexes"
1881-
):
1879+
with pytest.raises(ValueError, match="Cannot disable all indexes"):
18821880
schema.delete_index()
18831881

18841882
# Test 4: Cannot enable all indexes globally
@@ -2790,12 +2788,14 @@ def test_cmek_schema_without_cmek_serialization(self) -> None:
27902788

27912789
def test_cmek_invalid_deserialization(self) -> None:
27922790
"""Test that invalid CMEK data raises a warning and sets cmek to None."""
2793-
with pytest.raises(ValueError, match="Unsupported or missing CMEK provider in data"):
2794-
Schema.deserialize_from_json(
2795-
{"defaults": {}, "keys": {}, "cmek": {}}
2796-
)
2791+
with pytest.raises(
2792+
ValueError, match="Unsupported or missing CMEK provider in data"
2793+
):
2794+
Schema.deserialize_from_json({"defaults": {}, "keys": {}, "cmek": {}})
27972795

2798-
with pytest.raises(ValueError, match="Unsupported or missing CMEK provider in data"):
2796+
with pytest.raises(
2797+
ValueError, match="Unsupported or missing CMEK provider in data"
2798+
):
27992799
Schema.deserialize_from_json(
28002800
{
28012801
"defaults": {},
@@ -2804,6 +2804,7 @@ def test_cmek_invalid_deserialization(self) -> None:
28042804
}
28052805
)
28062806

2807+
28072808
def test_sparse_vector_cannot_be_created_globally() -> None:
28082809
"""Test that sparse vector index cannot be created globally (without a key)."""
28092810
schema = Schema()
@@ -2964,15 +2965,11 @@ def test_delete_index_rejects_special_keys() -> None:
29642965
schema.delete_index(config=string_config, key=Key.DOCUMENT)
29652966

29662967
# Test that Key.EMBEDDING is rejected
2967-
with pytest.raises(
2968-
ValueError, match="Cannot modify #embedding"
2969-
):
2968+
with pytest.raises(ValueError, match="Cannot modify #embedding"):
29702969
schema.delete_index(config=string_config, key=Key.EMBEDDING)
29712970

29722971
# Test that string "#embedding" is also rejected (for consistency)
2973-
with pytest.raises(
2974-
ValueError, match="Cannot modify #embedding"
2975-
):
2972+
with pytest.raises(ValueError, match="Cannot modify #embedding"):
29762973
schema.delete_index(config=string_config, key="#embedding")
29772974

29782975
# Test that any other key starting with # is rejected (second check)
@@ -3156,7 +3153,11 @@ def test_config_classes_reject_invalid_fields() -> None:
31563153

31573154
error_msg = str(exc_info.value)
31583155
assert "key" in error_msg.lower()
3159-
assert "extra" in error_msg.lower() or "permitted" in error_msg.lower()
3156+
assert (
3157+
"extra" in error_msg.lower()
3158+
or "permitted" in error_msg.lower()
3159+
or "not a valid field" in error_msg.lower()
3160+
)
31603161

31613162
# Test VectorIndexConfig rejects invalid fields
31623163
with pytest.raises((ValueError, ValidationError)) as exc_info:

clients/new-js/packages/chromadb/src/api/types.gen.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,14 @@ export type SpannIndexConfig = {
592592
write_rng_factor?: number | null;
593593
};
594594

595+
/**
596+
* Sparse vector index algorithm.
597+
*
598+
* Controls which posting list format and query engine are used for
599+
* sparse vector search within a collection.
600+
*/
601+
export type SparseIndexAlgorithm = 'wand' | 'max_score';
602+
595603
/**
596604
* Represents a sparse vector using parallel arrays for indices and values.
597605
*
@@ -616,6 +624,13 @@ export type SparseVector = {
616624
};
617625

618626
export type SparseVectorIndexConfig = {
627+
/**
628+
* Sparse index algorithm (cloud-only, tenant-gated).
629+
* Omitted from JSON when set to the default (Wand) so that old
630+
* servers/clients that do not know about this field can still
631+
* deserialize the schema.
632+
*/
633+
algorithm?: SparseIndexAlgorithm;
619634
/**
620635
* Whether this embedding is BM25
621636
*/

0 commit comments

Comments
 (0)