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 for if a path is given for a remote client URL it is stored as the prefix and not discarded. #876

Merged
merged 3 commits into from
Jan 7, 2025
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
2 changes: 2 additions & 0 deletions qdrant_client/async_qdrant_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ def __init__(
raise ValueError(
f"Prefix can be set either in `url` or in `prefix`. url is {url}, prefix is {parsed_url.path}"
)
elif parsed_url.path:
self._prefix = parsed_url.path
if self._scheme not in ("http", "https"):
raise ValueError(f"Unknown scheme: {self._scheme}")
else:
Expand Down
3 changes: 2 additions & 1 deletion qdrant_client/qdrant_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ def __init__(
"Prefix can be set either in `url` or in `prefix`. "
f"url is {url}, prefix is {parsed_url.path}"
)
elif parsed_url.path:
self._prefix = parsed_url.path

if self._scheme not in ("http", "https"):
raise ValueError(f"Unknown scheme: {self._scheme}")
Expand Down Expand Up @@ -274,7 +276,6 @@ def _init_grpc_root_client(self) -> None:
self._init_grpc_channel()
self._grpc_root_client = grpc.QdrantStub(self._grpc_channel)


@property
def grpc_collections(self) -> grpc.CollectionsStub:
"""gRPC client for collections methods
Expand Down
6 changes: 6 additions & 0 deletions tests/test_qdrant_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ def test_client_init():
assert isinstance(client._client, QdrantRemote)
assert client._client.rest_uri == "http://localhost:6333/custom"

client = QdrantClient(url="http://localhost:6333/custom")
assert isinstance(client._client, QdrantRemote)
assert client._client.rest_uri == "http://localhost:6333/custom"
assert client._client._prefix == "/custom"

client = QdrantClient("my-domain.com")
assert isinstance(client._client, QdrantRemote)
assert client._client.rest_uri == "http://my-domain.com:6333"
Expand Down Expand Up @@ -2080,6 +2085,7 @@ async def auth_token_provider():

assert token == ""


@pytest.mark.parametrize("prefer_grpc", [True, False])
def test_read_consistency(prefer_grpc):
fixture_points = generate_fixtures(vectors_sizes=DIM, num=NUM_VECTORS)
Expand Down
Loading