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

refactor: Refactored the way of warnings #864

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from

Conversation

hh-space-invader
Copy link
Contributor

All Submissions:

  • Contributions should target the dev branch. Did you create your branch from dev?
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Have you installed pre-commit with pip3 install pre-commit and set up hooks with pre-commit install?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Copy link

netlify bot commented Dec 16, 2024

Deploy Preview for poetic-froyo-8baba7 ready!

Name Link
🔨 Latest commit 78f7879
🔍 Latest deploy log https://app.netlify.com/sites/poetic-froyo-8baba7/deploys/6777a4a679f1ff00084d3cbe
😎 Deploy Preview https://deploy-preview-864--poetic-froyo-8baba7.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@joein
Copy link
Member

joein commented Dec 16, 2024

  1. CI is failing
  2. Warnings should point to the users code which led to a warning, try applying such code to get the idea:
def create_payload_index(
        self,
        collection_name: str,
        field_name: str,
        field_schema: Optional[types.PayloadSchemaType] = None,
        field_type: Optional[types.PayloadSchemaType] = None,
        **kwargs: Any,
    ) -> types.UpdateResult:
        show_warning_once(
            message="Payload indexes have no effect in the local Qdrant. Please use server Qdrant if you need payload indexes.",
            category=UserWarning,
            idx="create-payload-index",
            stacklevel=5,
        )
        return self._default_update_result()

and running this code:

/.../qdrant_client/check_depr.py:59: UserWarning: Payload indexes have no effect in the local Qdrant. Please use server Qdrant if you need payload indexes.
  cl.create_payload_index('cn', 'payload')

Clicking on /.../qdrant_client/check_depr.py:59 path should lead to cl.create_payload_index call

@joein joein requested a review from I8dNLo December 18, 2024 12:26
qdrant_client/common/client_warnings.py Outdated Show resolved Hide resolved
qdrant_client/local/qdrant_local.py Outdated Show resolved Hide resolved
qdrant_client/qdrant_remote.py Outdated Show resolved Hide resolved
qdrant_client/qdrant_remote.py Outdated Show resolved Hide resolved
qdrant_client/qdrant_remote.py Outdated Show resolved Hide resolved
qdrant_client/qdrant_remote.py Outdated Show resolved Hide resolved
qdrant_client/qdrant_remote.py Outdated Show resolved Hide resolved
qdrant_client/uploader/rest_uploader.py Outdated Show resolved Hide resolved
qdrant_client/uploader/grpc_uploader.py Outdated Show resolved Hide resolved
@hh-space-invader hh-space-invader requested a review from joein January 3, 2025 08:49
Comment on lines +80 to +84
show_warning(
message=f"Collection appears to be None before closing. The existing collections are: "
f"{list(self.collections.keys())}",
category=UserWarning,
stacklevel=5,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stacklevel should be 4 and it should also be show_warning_once, since we don't provide collection name here

the output with stacklevel=5:

sys:1: UserWarning: Collection appears to be None before closing. The existing collections are: ['test']

stacklevel=4:

/.../qdrant_client/check_warnings/local_close_collection.py:6: UserWarning: Collection appears to be None before closing. The existing collections are: ['test']
  cl.close()
/.../qdrant/qdrant_client/qdrant_client/qdrant_client.py:157: UserWarning: Collection appears to be None before closing. The existing collections are: ['test']

the script I used to reproduce:

from qdrant_client import QdrantClient, models

cl = QdrantClient(":memory:")
cl.create_collection('test', vectors_config=models.VectorParams(size=2, distance=models.Distance.COSINE))
cl._client.collections = {x: None for x in cl._client.collections}
cl.close()

@@ -119,6 +121,7 @@ def _load(self) -> None:
"with large datasets.",
category=UserWarning,
idx="large-local-collection",
stacklevel=6,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be show_warning, since we are providing collection name here

warnings.warn("Auth token provider is used with an insecure connection.")
show_warning(
message="Auth token provider is used with an insecure connection.",
category=RuntimeWarning,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is UserWarning

warnings.warn("Api key is used with an insecure connection.")
show_warning(
message="Api key is used with an insecure connection.",
category=RuntimeWarning,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is UserWarning

@joein
Copy link
Member

joein commented Jan 3, 2025

Also

async def close(self, grpc_grace: Optional[float] = None, **kwargs: Any) -> None:

is still using logging.warning

Should be updated here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants