Skip to content

Commit

Permalink
fix: Fix stacklevel in warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
hh-space-invader committed Dec 18, 2024
1 parent 3373cc5 commit f1d9cc7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion qdrant_client/local/local_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2195,7 +2195,7 @@ def upsert(self, points: Union[Sequence[models.PointStruct], models.Batch]) -> N
"Consider using Qdrant in Docker or Qdrant Cloud for better performance with large datasets.",
category=UserWarning,
idx="large-local-collection",
stacklevel=4,
stacklevel=6,
)

def _update_named_vectors(
Expand Down
8 changes: 4 additions & 4 deletions qdrant_client/local/qdrant_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def close(self, **kwargs: Any) -> None:
message=f"Collection appears to be None before closing. The existing collections are: "
f"{list(self.collections.keys())}",
category=UserWarning,
stacklevel=1,
stacklevel=5,
)

try:
Expand Down Expand Up @@ -121,7 +121,7 @@ def _load(self) -> None:
"with large datasets.",
category=UserWarning,
idx="large-local-collection",
stacklevel=4,
stacklevel=6,
)
self.aliases = meta["aliases"]

Expand Down Expand Up @@ -1140,7 +1140,7 @@ def create_payload_index(
message="Payload indexes have no effect in the local Qdrant. Please use server Qdrant if you need payload indexes.",
category=UserWarning,
idx="server-payload-indexes",
stacklevel=1,
stacklevel=5,
)
return self._default_update_result()

Expand All @@ -1151,7 +1151,7 @@ def delete_payload_index(
message="Payload indexes have no effect in the local Qdrant. Please use server Qdrant if you need payload indexes.",
category=UserWarning,
idx="server-payload-indexes",
stacklevel=1,
stacklevel=5,
)
return self._default_update_result()

Expand Down
14 changes: 7 additions & 7 deletions qdrant_client/qdrant_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def __init__(
show_warning(
message="Api key is used with an insecure connection.",
category=RuntimeWarning,
stacklevel=2,
stacklevel=4,
)

# http2 = True
Expand Down Expand Up @@ -177,7 +177,7 @@ def __init__(
show_warning(
message="Auth token provider is used with an insecure connection.",
category=RuntimeWarning,
stacklevel=2,
stacklevel=4,
)

bearer_auth = BearerAuth(self._auth_token_provider)
Expand Down Expand Up @@ -214,7 +214,7 @@ def close(self, grpc_grace: Optional[float] = None, **kwargs: Any) -> None:
show_warning(
message="Unable to close grpc_channel. Connection was interrupted on the server side",
category=RuntimeWarning,
stacklevel=2,
stacklevel=4,
)

if hasattr(self, "_aio_grpc_channel") and self._aio_grpc_channel is not None:
Expand All @@ -225,7 +225,7 @@ def close(self, grpc_grace: Optional[float] = None, **kwargs: Any) -> None:
show_warning(
message="Unable to close aio_grpc_channel. Connection was interrupted on the server side",
category=RuntimeWarning,
stacklevel=2,
stacklevel=4,
)
except RuntimeError:
pass
Expand All @@ -236,7 +236,7 @@ def close(self, grpc_grace: Optional[float] = None, **kwargs: Any) -> None:
show_warning(
message="Unable to close http connection. Connection was interrupted on the server side",
category=RuntimeWarning,
stacklevel=2,
stacklevel=4,
)

self._closed = True
Expand Down Expand Up @@ -2780,7 +2780,7 @@ def create_collection(
) -> bool:
if init_from is not None:
show_warning(
message="init_from is deprecated", category=DeprecationWarning, stacklevel=2
message="init_from is deprecated", category=DeprecationWarning, stacklevel=4
)

if self._prefer_grpc:
Expand Down Expand Up @@ -3064,7 +3064,7 @@ def create_payload_index(
show_warning(
message="field_type is deprecated, use field_schema instead",
category=DeprecationWarning,
stacklevel=2,
stacklevel=4,
)
field_schema = field_type

Expand Down

0 comments on commit f1d9cc7

Please sign in to comment.