refactor: Separate protobuf dependencies into sensible extras#522
refactor: Separate protobuf dependencies into sensible extras#522vinoo999 wants to merge 15 commits intoa2aproject:mainfrom
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.
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.
I'm not sure protobuf really needs to be a separate dependency group from grpc
There was a problem hiding this comment.
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.
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.
Why make changes to this file? It appears that entires were in an alphabetical order here.
There was a problem hiding this comment.
unclear. i think this came directly from the github action when updating readme. i can revert
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
reran with ^ and applied. removed postres dup
There was a problem hiding this comment.
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.
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.
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.
HTTP+JSON/REST also requires these dependencies.
rest_handler.py depends on a2a_pb2:
There was a problem hiding this comment.
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.
a2a_pb2 seems to depend on google-api-core:
a2a-python/src/a2a/grpc/a2a_pb2.py
Line 26 in 89e9b7c
I think we need to include it here as well.
There was a problem hiding this comment.
You're right. I'll add some tests that do the individual extras plus tests accordingly. I'm going to move this PR to draft because it looks like 1.0 is going to require some changes that depend directly on the proto rather than the a2a spec json even in jsonrpc. In doing so this split may not be directly possible in the way I'd like.
|
Moving to draft. pending 1.0 will see if this is still possible. based on discussion the proto dependency might be required in all protocol bindings. |
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)