-
Notifications
You must be signed in to change notification settings - Fork 285
refactor: Separate protobuf dependencies into sensible extras #522
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
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @vinoo999, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refactors the project's dependency management by isolating protobuf-related packages into a new Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request effectively refactors the project's dependencies by separating protobuf into an optional [proto] extra. This is a great improvement for users who don't need Protobuf-related functionality, reducing the core dependency footprint. The changes in pyproject.toml correctly move the dependencies, and the try-except block in proto_utils.py provides a clear error message for missing optional dependencies. I have one suggestion in pyproject.toml to further improve the structure and maintainability of the optional dependencies for server implementations.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
pyproject.toml
Outdated
|
|
||
| [project.optional-dependencies] | ||
| http-server = ["fastapi>=0.115.2", "sse-starlette", "starlette"] | ||
| proto = ["protobuf>=5.29.5"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure protobuf really needs to be a separate dependency group from grpc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can remove the extra altogether if you want to be explicit for the REST and gRPC servers. My goal was removing protobuf dependencies especially for JSON-RPC servers + clients.
If you prefer can do:
jsonrpc-server = ["fastapi>=0.115.2", "sse-starlette", "starlette"]
http-server = ["a2a-sdk[jsonrpc-server]", "protobuf>=5.29.5"]
grpc = ["grpcio>=1.60", "grpcio-tools>=1.60", "grpcio_reflection>=1.7.0", "google-api-core>=1.26.0", "protobuf>=5.29.5"]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
http-server is a bit confusing naming of the extra now that JSON-RPC is split out but needed for backward compatibility
Co-authored-by: Holt Skinner <[email protected]>
|
@pstephengoogle Can you review and make sure this follows with current plans for the protocol? |
|
@pstephengoogle / @holtskinner any updates on this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why make changes to this file? It appears that entires were in an alphabetical order here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unclear. i think this came directly from the github action when updating readme. i can revert
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in fact I think this may have come from the Format script which must have a bug for capitalization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reran with ^ and applied. removed postres dup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we leave it as it was? I'm not entirely familiar with how this file is used and I worry that dependents may be case-sensitive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was intentionally left case-sensitive, because the case-insensitive sort wasn't always consistent.
README.md
Outdated
| | **All Extras** | `uv add "a2a-sdk[all]"` | `pip install "a2a-sdk[all]"` | | ||
| | **HTTP Server** | `uv add "a2a-sdk[http-server]"` | `pip install "a2a-sdk[http-server]"` | | ||
| | **JSON-RPC Server** | `uv add "a2a-sdk[jsonrpc-server]"` | `pip install "a2a-sdk[jsonrpc-server]"` | | ||
| | **HTTP (REST) Server** | `uv add "a2a-sdk[http-server]"` | `pip install "a2a-sdk[http-server]"` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's copy the terminology from the spec documentation: HTTP+JSON/REST Server
| [project.optional-dependencies] | ||
| http-server = ["fastapi>=0.115.2", "sse-starlette", "starlette"] | ||
| jsonrpc-server = ["fastapi>=0.115.2", "sse-starlette", "starlette"] | ||
| http-server = ["a2a-sdk[jsonrpc-server]", "protobuf>=5.29.5"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HTTP+JSON/REST also requires these dependencies.
rest_handler.py depends on a2a_pb2:
| from a2a.grpc import a2a_pb2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already encompassed here. a2a.grpc.a2a_pb2 has no grpcio dependencies. Just protobuf. This is encapsulated in the PR already.
Any concerns here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a2a_pb2 seems to depend on google-api-core:
a2a-python/src/a2a/grpc/a2a_pb2.py
Line 26 in 89e9b7c
| from google.api import client_pb2 as google_dot_api_dot_client__pb2 |
I think we need to include it here as well.
Description
This introduces a
protoextra into the package. The core library itself has no direct dependency on protobuf and only rest server and clients require a2a. google-api-core is only a dependency for grpc. Refactor accordingly to reduce dependency mangling introduced by proto for non grpc/rest servers. Assuming a CI regenerates the uv.lock file but can regenerate it otherwise.This does not follow the runtime validation pattern in #217 as proto dependencies are localized in
proto_utils.py.CONTRIBUTINGGuide.fix:which represents bug fixes, and correlates to a SemVer patch.feat:represents a new feature, and correlates to a SemVer minor.feat!:, orfix!:,refactor!:, etc., which represent a breaking change (indicated by the!) and will result in a SemVer major.bash scripts/format.shfrom the repository root to format)