Skip to content

Commit

Permalink
move grpc_compression parameter from client's signature to **kwargs
Browse files Browse the repository at this point in the history
  • Loading branch information
geetu040 committed Feb 16, 2024
1 parent 1b0b19b commit 940e7c4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
6 changes: 0 additions & 6 deletions qdrant_client/async_qdrant_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ def __init__(
path: Optional[str] = None,
force_disable_check_same_thread: bool = False,
grpc_options: Optional[Dict[str, Any]] = None,
grpc_compression: Optional[grpc.Compression] = None,
**kwargs: Any,
):
super().__init__(**kwargs)
Expand All @@ -96,10 +95,6 @@ def __init__(
raise ValueError(
"Only one of <location>, <url>, <host> or <path> should be specified."
)
if grpc_compression is not None and not isinstance(grpc_compression, grpc.Compression):
raise TypeError(
f"Expected 'grpc_compression' to be of type grpc.Compression or None, but got {type(grpc_compression).__name__}"
)
if location == ":memory:":
self._client = AsyncQdrantLocal(
location=location, force_disable_check_same_thread=force_disable_check_same_thread
Expand All @@ -122,7 +117,6 @@ def __init__(
timeout=timeout,
host=host,
grpc_options=grpc_options,
grpc_compression=grpc_compression,
**kwargs,
)
self._is_fastembed_installed: Optional[bool] = None
Expand Down
8 changes: 6 additions & 2 deletions qdrant_client/async_qdrant_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,12 @@ def __init__(
timeout: Optional[int] = None,
host: Optional[str] = None,
grpc_options: Optional[Dict[str, Any]] = None,
grpc_compression: Optional[grpc.Compression] = None,
**kwargs: Any,
):
super().__init__(**kwargs)
self._prefer_grpc = prefer_grpc
self._grpc_port = grpc_port
self._grpc_options = grpc_options
self._grpc_compression = grpc_compression
self._https = https if https is not None else api_key is not None
self._scheme = "https" if self._https else "http"
self._prefix = prefix or ""
Expand Down Expand Up @@ -113,6 +111,12 @@ def __init__(
warnings.warn("Api key is used with unsecure connection.")
self._rest_headers["api-key"] = api_key
self._grpc_headers.append(("api-key", api_key))
grpc_compression = kwargs.pop("grpc_compression", None)
if grpc_compression is not None and (not isinstance(grpc_compression, grpc.Compression)):
raise TypeError(
f"Expected 'grpc_compression' to be of type grpc.Compression or None, but got {type(grpc_compression).__name__}"
)
self._grpc_compression = grpc_compression
address = f"{self._host}:{self._port}" if self._port is not None else self._host
self.rest_uri = f"{self._scheme}://{address}{self._prefix}"
self._rest_args = {"headers": self._rest_headers, "http2": http2, **kwargs}
Expand Down
6 changes: 0 additions & 6 deletions qdrant_client/qdrant_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ def __init__(
path: Optional[str] = None,
force_disable_check_same_thread: bool = False,
grpc_options: Optional[Dict[str, Any]] = None,
grpc_compression: Optional[grpc.Compression] = None,
**kwargs: Any,
):
super().__init__(
Expand All @@ -92,10 +91,6 @@ def __init__(
raise ValueError(
"Only one of <location>, <url>, <host> or <path> should be specified."
)
if grpc_compression is not None and not isinstance(grpc_compression, grpc.Compression):
raise TypeError(
f"Expected 'grpc_compression' to be of type grpc.Compression or None, but got {type(grpc_compression).__name__}"
)

if location == ":memory:":
self._client = QdrantLocal(
Expand All @@ -121,7 +116,6 @@ def __init__(
timeout=timeout,
host=host,
grpc_options=grpc_options,
grpc_compression=grpc_compression,
**kwargs,
)
self._is_fastembed_installed: Optional[bool] = None
Expand Down
10 changes: 8 additions & 2 deletions qdrant_client/qdrant_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,12 @@ def __init__(
timeout: Optional[int] = None,
host: Optional[str] = None,
grpc_options: Optional[Dict[str, Any]] = None,
grpc_compression: Optional[grpc.Compression] = None,
**kwargs: Any,
):
super().__init__(**kwargs)
self._prefer_grpc = prefer_grpc
self._grpc_port = grpc_port
self._grpc_options = grpc_options
self._grpc_compression = grpc_compression
self._https = https if https is not None else api_key is not None
self._scheme = "https" if self._https else "http"

Expand Down Expand Up @@ -128,6 +126,14 @@ def __init__(
self._rest_headers["api-key"] = api_key
self._grpc_headers.append(("api-key", api_key))

# GRPC Channel-Level Compression
grpc_compression = kwargs.pop("grpc_compression", None)
if grpc_compression is not None and not isinstance(grpc_compression, grpc.Compression):
raise TypeError(
f"Expected 'grpc_compression' to be of type grpc.Compression or None, but got {type(grpc_compression).__name__}"
)
self._grpc_compression = grpc_compression

address = f"{self._host}:{self._port}" if self._port is not None else self._host
self.rest_uri = f"{self._scheme}://{address}{self._prefix}"

Expand Down

0 comments on commit 940e7c4

Please sign in to comment.