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

[gen grpc] Include pyi grpc files #917

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

Conversation

coszio
Copy link
Contributor

@coszio coszio commented Mar 5, 2025

This PR picks up from #506 to improve DX when working with conversions.

Regenerates the gRPC client but with better type stubs that actually work with pyright and ruff.

Copy link

netlify bot commented Mar 5, 2025

Deploy Preview for poetic-froyo-8baba7 ready!

Name Link
🔨 Latest commit dcdeb2b
🔍 Latest deploy log https://app.netlify.com/sites/poetic-froyo-8baba7/deploys/67c858a904b7a00008c907bb
😎 Deploy Preview https://deploy-preview-917--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.

Copy link

coderabbitai bot commented Mar 5, 2025

📝 Walkthrough

Walkthrough

The pull request adds a new dependency, mypy-protobuf, to the project configuration for improved type-checking support. It introduces several new auto-generated stub files (.pyi) for gRPC services including collections, points, and snapshots, along with detailed type annotations for protocol buffer messages. Additionally, the Protocol Buffers definition file (points.proto) has been updated with new messages and fields to support expanded query capabilities such as mathematical expressions, scoring formulas, and enhanced field conditions. The gRPC client generation script has been revised to allow installation of a flexible version of grpcio and to generate type stubs with improved command formatting.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
qdrant_client/proto/points.proto (2)

599-602: Addition of GeoDistance Message

The new GeoDistance message correctly encapsulates geographic distance information with an origin and a target. For clarity, consider renaming the field to to something like destination if it represents a target location.


612-616: Addition of DivExpression Message

The DivExpression message introduces fields for left and right operands, plus an optional by_zero_default to address division by zero. Verify that the generated client and the server implementation use this default value consistently to prevent potential runtime exceptions.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ce4c51d and dcdeb2b.

⛔ Files ignored due to path filters (1)
  • poetry.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • pyproject.toml (1 hunks)
  • qdrant_client/grpc/collections_service_pb2.pyi (1 hunks)
  • qdrant_client/grpc/json_with_int_pb2.pyi (1 hunks)
  • qdrant_client/grpc/points_service_pb2.pyi (1 hunks)
  • qdrant_client/grpc/qdrant_pb2.pyi (1 hunks)
  • qdrant_client/grpc/snapshots_service_pb2.pyi (1 hunks)
  • qdrant_client/proto/points.proto (3 hunks)
  • tools/generate_grpc_client.sh (2 hunks)
✅ Files skipped from review due to trivial changes (4)
  • qdrant_client/grpc/points_service_pb2.pyi
  • qdrant_client/grpc/collections_service_pb2.pyi
  • qdrant_client/grpc/qdrant_pb2.pyi
  • qdrant_client/grpc/snapshots_service_pb2.pyi
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Redirect rules - poetic-froyo-8baba7
  • GitHub Check: Header rules - poetic-froyo-8baba7
  • GitHub Check: Pages changed - poetic-froyo-8baba7
  • GitHub Check: Python 3.13.x on ubuntu-latest test
  • GitHub Check: Python 3.12.x on ubuntu-latest test
  • GitHub Check: Python 3.11.x on ubuntu-latest test
  • GitHub Check: Python 3.10.x on ubuntu-latest test
  • GitHub Check: Python 3.9.x on ubuntu-latest test
  • GitHub Check: Python 3.13 test
🔇 Additional comments (13)
qdrant_client/proto/points.proto (6)

575-578: New Message Added: Formula

The new Formula message encapsulates a scoring formula by holding an Expression along with a defaults map. This design is clear and aligns with expanding query expressiveness.


580-597: Comprehensive Expression Definition

The Expression message now supports a wide range of operations (constant, variable, condition, various arithmetic operations, and logarithmic/exponential functions) via its oneof variant. This provides excellent flexibility for constructing complex formulas. Please ensure that the documentation or usage examples clarify each variant's intended usage.


604-606: New MultExpression Message

The introduction of MultExpression employing a repeated Expression field to represent multiplication is straightforward and meets the design needs.


608-610: New SumExpression Message

The SumExpression message is well-defined with a repeated field for addends to perform summation. This addition is clear and consistent with similar arithmetic operations.


618-621: Introduction of PowExpression Message

The new PowExpression neatly captures power operations with base and exponent fields. The design is clear and should integrate well with the other mathematical expression messages.


1048-1050: Enhancement of FieldCondition

The extension of FieldCondition with optional bool is_empty and optional bool is_null provides additional granularity for filtering based on field content. Ensure that the backend logic correctly interprets the distinction between "empty" and "null" values.

pyproject.toml (1)

55-55: Added necessary dependency for enhanced type checking.

The addition of mypy-protobuf at version ^3.3.0 aligns perfectly with the PR objectives to improve the type stubs for gRPC client. This dependency is used to generate TypeScript-like interface files (.pyi) for Protocol Buffers, which significantly enhances type checking capabilities when working with gRPC services.

tools/generate_grpc_client.sh (2)

7-7: Good flexibility improvement in grpcio dependency.

Changing from a fixed version to a minimum version requirement (grpcio>=1.48.2) provides better flexibility for the build environment while maintaining backward compatibility. This approach allows users to benefit from bug fixes and performance improvements in newer versions of grpcio without being stuck on a specific version.


43-48: Improved code generation with type stub support.

The reformatted command with the addition of --mypy_out=./qdrant_client/grpc is a significant enhancement that enables the generation of .pyi type stub files. These files provide detailed type annotations for the gRPC client, improving compatibility with static type checkers like pyright and tools like ruff, which is the core objective of this PR.

The multi-line format also improves readability and maintainability of the script.

qdrant_client/grpc/json_with_int_pb2.pyi (4)

1-4: Auto-generated type stub file as expected.

This is an auto-generated file by mypy-protobuf, as correctly indicated in the header comments. These type stubs are essential for improving the developer experience when working with the gRPC client.


14-17: Python version compatibility handling is appropriate.

The conditional import based on Python version ensures compatibility with both older and newer Python versions, which is a good practice for a library that supports multiple Python versions.


95-131: Complete type definitions for the Value class.

The Value class contains comprehensive type definitions for various value types, including explicit support for integer values (line 106), which is important for strong typing in Python. The WhichOneof method properly defines the possible field names, and all fields are properly documented.


135-154:

✅ Verification successful

Verify ListValue implementation consistency.

The ListValue class looks well-defined with proper type annotations. To ensure consistency, you might want to verify that the implementation aligns with how lists of values are handled in the rest of your codebase.


🏁 Script executed:

#!/bin/bash
# Check how ListValue is used across the codebase
rg -A 5 -B 5 "ListValue" --glob "*.py" | grep -v "json_with_int_pb2.pyi"

Length of output: 5472


ListValue Implementation Consistency Verified

The usage of ListValue in the conversion logic (as seen in qdrant_client/conversions/conversion.py) aligns with the type definitions provided in qdrant_client/grpc/json_with_int_pb2.pyi. The class is correctly defined with proper type annotations and behaves as expected when wrapping list values. No further modifications are necessary.

@coszio coszio requested a review from joein March 5, 2025 21:19
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.

1 participant