Added python gRPC API bindings#618
Conversation
gaius-qi
left a comment
There was a problem hiding this comment.
Please remove v2 path => api/*.py
There was a problem hiding this comment.
Pull request overview
This PR adds Python gRPC API bindings for Dragonfly by generating Python code from existing protobuf definitions. This serves as the foundation (step 1) for a future Python SDK.
Changes:
- Added generated Python gRPC stub files from protobuf definitions for scheduler, manager, dfdaemon, common, and errordetails APIs
- Added pyproject.toml for Python package configuration with setuptools backend
- Added basic README documenting the package
Reviewed changes
Copilot reviewed 12 out of 20 changed files in this pull request and generated 24 comments.
Show a summary per file
| File | Description |
|---|---|
| python/pyproject.toml | Package configuration defining dependencies (grpcio, protobuf) and build system |
| python/api/v2/*.py | Generated Python gRPC stubs for v2 API (scheduler, manager, dfdaemon, common, errordetails) |
| python/api/v2/pycache/*.pyc | Compiled Python bytecode files (should NOT be committed) |
| python/README.md | Basic documentation for the package |
| .gitignore | Added .venv/ pattern for Python virtual environments |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| raise NotImplementedError('Method not implemented!') | ||
|
|
||
| def DeleteCachePeer(self, request, context): | ||
| """DeletCacheePeer releases cache peer in scheduler. |
There was a problem hiding this comment.
Typo in docstring: "DeletCacheePeer" should be "DeleteCachePeer" (remove the extra 'e'). This is auto-generated code from the protobuf definition, so the typo exists in the source .proto file and should be fixed there before regenerating.
| """DeletCacheePeer releases cache peer in scheduler. | |
| """DeleteCachePeer releases cache peer in scheduler. |
| raise NotImplementedError('Method not implemented!') | ||
|
|
||
| def ListSeedPeers(self, request, context): | ||
| """List acitve schedulers configuration. |
There was a problem hiding this comment.
Typo in docstring: "acitve" should be "active". This appears twice (lines 98 and 133). This is auto-generated code from the protobuf definition, so the typo exists in the source .proto file and should be fixed there before regenerating.
| raise NotImplementedError('Method not implemented!') | ||
|
|
||
| def ListSchedulers(self, request, context): | ||
| """List acitve schedulers configuration. |
There was a problem hiding this comment.
Typo in docstring: "acitve" should be "active". This is the second occurrence of the same typo. This is auto-generated code from the protobuf definition, so the typo exists in the source .proto file and should be fixed there before regenerating.
| ## Python Dragonfly API | ||
|
|
||
| Generated Python gRPC bindings for Dragonfly. | ||
|
|
||
| Source protos in https://github.com/dragonflyoss/api | ||
|
|
There was a problem hiding this comment.
The Python package is missing essential metadata and configuration files. Consider adding: 1) A MANIFEST.in file to ensure non-Python files (like README.md) are included in distributions, 2) Package metadata fields in pyproject.toml (authors, license, repository URL, etc.), 3) A way to specify which packages to include (either explicitly listing them or using [tool.setuptools.packages.find]). Without these, the package may not install or distribute correctly.
| ] | ||
|
|
||
| [build-system] | ||
| requires = ["setuptools"] | ||
| build-backend = "setuptools.build_meta" |
There was a problem hiding this comment.
The pyproject.toml is missing several important metadata fields for a proper Python package distribution: 'authors', 'readme', 'license', 'homepage', and 'repository'. Additionally, the package should specify 'packages' or use a proper package discovery mechanism to ensure the API modules are included in the distribution. Consider adding: authors = [{name = "...", email = "..."}], readme = "README.md", license = {text = "..."}, and [tool.setuptools.packages.find] to automatically discover packages.
| ] | |
| [build-system] | |
| requires = ["setuptools"] | |
| build-backend = "setuptools.build_meta" | |
| ] | |
| authors = [ | |
| { name = "Your Name", email = "you@example.com" }, | |
| ] | |
| readme = "README.md" | |
| license = { text = "Proprietary" } | |
| [project.urls] | |
| homepage = "https://example.com/dragonfly-api" | |
| repository = "https://example.com/dragonfly-api/repository" | |
| [build-system] | |
| requires = ["setuptools"] | |
| build-backend = "setuptools.build_meta" | |
| [tool.setuptools.packages.find] | |
| include = ["dragonfly_api*"] |
|
|
||
|
|
||
| from . import common_pb2 as common__pb2 | ||
| from . import errordetails_pb2 as errordetails__pb2 |
There was a problem hiding this comment.
Import of 'errordetails__pb2' is not used.
| from . import errordetails_pb2 as errordetails__pb2 |
|
|
||
| from . import common_pb2 as common__pb2 | ||
| from . import errordetails_pb2 as errordetails__pb2 | ||
| from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2 |
There was a problem hiding this comment.
Import of 'google_dot_protobuf_dot_duration__pb2' is not used.
| from . import common_pb2 as common__pb2 | ||
| from . import errordetails_pb2 as errordetails__pb2 | ||
| from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2 | ||
| from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 |
There was a problem hiding this comment.
Import of 'google_dot_protobuf_dot_empty__pb2' is not used.
| from . import errordetails_pb2 as errordetails__pb2 | ||
| from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2 | ||
| from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 | ||
| from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 |
There was a problem hiding this comment.
Import of 'google_dot_protobuf_dot_timestamp__pb2' is not used.
| from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 |
| # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! | ||
| """Client and server classes corresponding to protobuf-defined services.""" | ||
| import grpc | ||
| import warnings |
There was a problem hiding this comment.
Import of 'warnings' is not used.
| import warnings |
gaius-qi
left a comment
There was a problem hiding this comment.
Please generate code by namely/protoc-all, refer to https://github.com/dragonflyoss/api/blob/main/hack/protoc.sh.
This PR adds codegen Python gRPC bindings for Dragonfly APIs
Description
Related Issue
#4421
Motivation and Context
This API dependency package with generated Python gRPC code based on the existing .protoc files serves as step 1 for the Python SDK design