Skip to content

Commit

Permalink
remove ivfflat warnings. it has valid use cases
Browse files Browse the repository at this point in the history
  • Loading branch information
olirice committed Sep 15, 2023
1 parent 7d3aff1 commit dc278b4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 22 deletions.
9 changes: 3 additions & 6 deletions src/tests/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,13 +590,11 @@ def test_ivfflat(client: vecs.Client) -> None:
bar = client.get_or_create_collection(name="bar", dimension=dim)
bar.upsert([("a", [1, 2, 3, 4], {})])

with pytest.warns(UserWarning):
bar.create_index(method="ivfflat") # type: ignore
bar.create_index(method="ivfflat") # type: ignore
results = bar.query(data=[1, 2, 3, 4], limit=1, probes=50)
assert len(results) == 1

with pytest.warns(UserWarning):
bar.create_index(method=IndexMethod.ivfflat, replace=True) # type: ignore
bar.create_index(method=IndexMethod.ivfflat, replace=True) # type: ignore
results = bar.query(
data=[1, 2, 3, 4],
limit=1,
Expand Down Expand Up @@ -698,5 +696,4 @@ def test_failover_ivfflat(client: vecs.Client) -> None:
bar.upsert([("a", [1, 2, 3, 4], {})])
# this executes an otherwise uncovered line of code that selects ivfflat when mode is 'auto'
# and hnsw is unavailable
with pytest.warns(UserWarning):
bar.create_index(method=IndexMethod.auto)
bar.create_index(method=IndexMethod.auto)
10 changes: 1 addition & 9 deletions src/vecs/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from __future__ import annotations

import warnings
from typing import TYPE_CHECKING, List, Optional

from deprecated import deprecated
Expand Down Expand Up @@ -48,7 +47,7 @@ class Client:
vx.disconnect()
"""

def __init__(self, connection_string):
def __init__(self, connection_string: str):
"""
Initialize a Client instance.
Expand All @@ -72,13 +71,6 @@ def __init__(self, connection_string):
)
).scalar_one()

if not self._supports_hnsw():
warnings.warn(
UserWarning(
f"vecs will drop support for pgvector < 0.5.0 in version 1.0. Consider updating to latest postgres"
)
)

def _supports_hnsw(self):
return not self.vector_version.startswith("0.4")

Expand Down
7 changes: 0 additions & 7 deletions src/vecs/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,13 +664,6 @@ def create_index(
else:
method = IndexMethod.ivfflat

if method == IndexMethod.ivfflat:
warnings.warn(
UserWarning(
f"vecs will drop support for ivfflat indexes in version 1.0. upgrade to pgvector >= 0.5.0 and use IndexMethod.hnsw"
)
)

ops = INDEX_MEASURE_TO_OPS.get(measure)
if ops is None:
raise ArgError("Unknown index measure")
Expand Down

0 comments on commit dc278b4

Please sign in to comment.