Skip to content

Added python gRPC API bindings#618

Open
chinmaychahar wants to merge 1 commit intodragonflyoss:mainfrom
chinmaychahar:python-grpc-api
Open

Added python gRPC API bindings#618
chinmaychahar wants to merge 1 commit intodragonflyoss:mainfrom
chinmaychahar:python-grpc-api

Conversation

@chinmaychahar
Copy link

This PR adds codegen Python gRPC bindings for Dragonfly APIs

Description

  • Added generated Python code from existing protobuf definitions
  • Added pyproject.toml for packaging
  • Added basic README

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

Copy link
Member

@gaius-qi gaius-qi left a 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

Copy link

Copilot AI left a 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.
Copy link

Copilot AI Feb 2, 2026

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.

Suggested change
"""DeletCacheePeer releases cache peer in scheduler.
"""DeleteCachePeer releases cache peer in scheduler.

Copilot uses AI. Check for mistakes.
raise NotImplementedError('Method not implemented!')

def ListSeedPeers(self, request, context):
"""List acitve schedulers configuration.
Copy link

Copilot AI Feb 2, 2026

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.

Copilot uses AI. Check for mistakes.
raise NotImplementedError('Method not implemented!')

def ListSchedulers(self, request, context):
"""List acitve schedulers configuration.
Copy link

Copilot AI Feb 2, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +6
## Python Dragonfly API

Generated Python gRPC bindings for Dragonfly.

Source protos in https://github.com/dragonflyoss/api

Copy link

Copilot AI Feb 2, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +13
]

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
Copy link

Copilot AI Feb 2, 2026

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.

Suggested change
]
[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*"]

Copilot uses AI. Check for mistakes.


from . import common_pb2 as common__pb2
from . import errordetails_pb2 as errordetails__pb2
Copy link

Copilot AI Feb 2, 2026

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.

Suggested change
from . import errordetails_pb2 as errordetails__pb2

Copilot uses AI. Check for mistakes.

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
Copy link

Copilot AI Feb 2, 2026

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.

Copilot uses AI. Check for mistakes.
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
Copy link

Copilot AI Feb 2, 2026

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.

Copilot uses AI. Check for mistakes.
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
Copy link

Copilot AI Feb 2, 2026

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.

Suggested change
from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2

Copilot uses AI. Check for mistakes.
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc
import warnings
Copy link

Copilot AI Feb 2, 2026

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.

Suggested change
import warnings

Copilot uses AI. Check for mistakes.
Copy link
Member

@gaius-qi gaius-qi left a 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.

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.

2 participants