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 6 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 f22b18b
🔍 Latest deploy log https://app.netlify.com/sites/poetic-froyo-8baba7/deploys/6763c687348725000868c08c
😎 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
@@ -4,12 +4,15 @@
SEEN_MESSAGES = set()


def show_warning(message: str, category: type[Warning] = UserWarning) -> None:
warnings.warn(message, category, stacklevel=4)
def show_warning(message: str, category: type[Warning] = UserWarning, stacklevel: int = 1) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

let's use the stacklevel which we are using the most (2 or 4 i guess)

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="server-payload-indexes",
Copy link
Member

@joein joein Dec 18, 2024

Choose a reason for hiding this comment

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

let's separate create and delete payload index

@@ -3043,7 +3062,11 @@ def create_payload_index(
**kwargs: Any,
) -> types.UpdateResult:
if field_type is not None:
warnings.warn("field_type is deprecated, use field_schema instead", DeprecationWarning)
show_warning(
Copy link
Member

Choose a reason for hiding this comment

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

should be show_warning_once

@@ -2763,7 +2780,9 @@ def create_collection(
**kwargs: Any,
) -> bool:
if init_from is not None:
logging.warning("init_from is deprecated")
show_warning(
Copy link
Member

Choose a reason for hiding this comment

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

should be show_warning_once

Comment on lines 349 to 351
show_warning(
message="async_grpc_snapshots is deprecated and will be removed in a future release. Use `AsyncQdrantRemote.grpc_snapshots` instead.",
category=DeprecationWarning,
Copy link
Member

Choose a reason for hiding this comment

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

we can't change warnings here since IDE stop striking them through

Comment on lines 365 to 367
show_warning(
message="async_grpc_root is deprecated and will be removed in a future release. Use `AsyncQdrantRemote.grpc_root` instead.",
category=DeprecationWarning,
Copy link
Member

Choose a reason for hiding this comment

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

same about striking through

@@ -492,8 +507,10 @@ def search(
**kwargs: Any,
) -> list[types.ScoredPoint]:
if not append_payload:
logging.warning(
"Usage of `append_payload` is deprecated. Please consider using `with_payload` instead"
show_warning(
Copy link
Member

Choose a reason for hiding this comment

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

should be show_warning_once

show_warning(
message=f"Batch upload failed {attempt + 1} times. Retrying...",
category=UserWarning,
stacklevel=1,
Copy link
Member

Choose a reason for hiding this comment

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

seems that it should be 7

show_warning(
message=f"Batch upload failed {attempt + 1} times. Retrying...",
category=UserWarning,
stacklevel=1,
Copy link
Member

Choose a reason for hiding this comment

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

seems that it should be 8

Copy link

Choose a reason for hiding this comment

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

This one does not reproduce show_warning message, but raises RuntimeError("Thread unexpectedly terminated") if the qdrant is stopped

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@I8dNLo it retries 3 times (by default) with warning then raises.

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