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

Removed async_grpc #866

Merged
merged 4 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 1 addition & 14 deletions qdrant_client/qdrant_remote.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import asyncio
import importlib.metadata
import logging
import math
Expand Down Expand Up @@ -28,7 +27,7 @@
from qdrant_client.auth import BearerAuth
from qdrant_client.client_base import QdrantBase
from qdrant_client.common.version_check import is_compatible, get_server_version
from qdrant_client.connection import get_async_channel, get_channel
from qdrant_client.connection import get_channel
from qdrant_client.conversions import common_types as types
from qdrant_client.conversions.common_types import get_args_subscribed
from qdrant_client.conversions.conversion import (
Expand Down Expand Up @@ -188,7 +187,6 @@ def __init__(
self._grpc_snapshots_client: Optional[grpc.SnapshotsStub] = None
self._grpc_root_client: Optional[grpc.QdrantStub] = None

self._aio_grpc_channel = None
self._aio_grpc_points_client: Optional[grpc.PointsStub] = None
self._aio_grpc_collections_client: Optional[grpc.CollectionsStub] = None
self._aio_grpc_snapshots_client: Optional[grpc.SnapshotsStub] = None
Expand Down Expand Up @@ -223,17 +221,6 @@ def close(self, grpc_grace: Optional[float] = None, **kwargs: Any) -> None:
"Unable to close grpc_channel. Connection was interrupted on the server side"
)

if hasattr(self, "_aio_grpc_channel") and self._aio_grpc_channel is not None:
try:
loop = asyncio.get_running_loop()
loop.create_task(self._aio_grpc_channel.close(grace=grpc_grace))
except AttributeError:
logging.warning(
"Unable to close aio_grpc_channel. Connection was interrupted on the server side"
)
except RuntimeError:
pass

try:
self.openapi_client.close()
except Exception:
Expand Down
30 changes: 0 additions & 30 deletions tests/test_qdrant_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2051,36 +2051,6 @@ def auth_token_provider():
client.unlock_storage()
assert token == "token_2"


def test_async_auth_token_provider():
"""Check that initialization fails if async auth_token_provider is provided to sync client."""
token = ""

async def auth_token_provider():
nonlocal token
await asyncio.sleep(0.1)
token = "test_token"
return token

client = QdrantClient(auth_token_provider=auth_token_provider)

with pytest.raises(
qdrant_client.http.exceptions.ResponseHandlingException,
match="Synchronous token provider is not set.",
):
client.get_collections()

assert token == ""

client = QdrantClient(auth_token_provider=auth_token_provider, prefer_grpc=True)
with pytest.raises(
ValueError, match="Synchronous channel requires synchronous auth token provider."
):
client.get_collections()

assert token == ""


I8dNLo marked this conversation as resolved.
Show resolved Hide resolved
@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
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ def visit_ImportFrom(self, node: ast.ImportFrom) -> ast.AST:
if hasattr(alias, "name"):
for old_value, new_value in self.import_replace_map.items():
alias.name = alias.name.replace(old_value, new_value)
if alias.name == "get_async_channel":
alias.asname = "get_channel"
node.names = [alias for alias in node.names if alias.name != "get_channel"]
if alias.name == "get_channel":
alias.name = "get_async_channel as get_channel"
# alias.asname = "get_channel"
# node.names = [alias for alias in node.names if alias.name != "get_channel"]

return self.generic_visit(node)
Loading