-
Notifications
You must be signed in to change notification settings - Fork 17
Added python gRPC API bindings #618
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
gaius-qi
left a comment
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.
Please remove v2 path => api/*.py
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.
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. |
Copilot
AI
Feb 2, 2026
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.
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. |
Copilot
AI
Feb 2, 2026
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.
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. |
Copilot
AI
Feb 2, 2026
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.
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 | ||
|
|
Copilot
AI
Feb 2, 2026
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.
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" |
Copilot
AI
Feb 2, 2026
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.
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 = "[email protected]" }, | |
| ] | |
| 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 |
Copilot
AI
Feb 2, 2026
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.
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 |
Copilot
AI
Feb 2, 2026
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.
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 |
Copilot
AI
Feb 2, 2026
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.
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 |
Copilot
AI
Feb 2, 2026
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.
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 |
Copilot
AI
Feb 2, 2026
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.
Import of 'warnings' is not used.
| import warnings |
gaius-qi
left a comment
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.
Please generate code by namely/protoc-all, refer to https://github.com/dragonflyoss/api/blob/main/hack/protoc.sh.
|
Sure, on it @gaius-qi |
|
Should I address all Copilot comments as well or https://github.com/dragonflyoss/api/blob/main/hack/protoc.sh would be enough? |
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