Skip to content

RussellLuo/grpc-pytools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grpc-pytools

Some useful Python's gRPC tools.

Prerequisites

Install gRPC tools:

$ pip install grpcio-tools

See gRPC Python Quickstart for more details.

Installation

Install grpc-pytools:

$ pip install grpc-pytools

Usage

Plugins

AST-like JSON

Generate an AST-like JSON file from the .proto file:

$ python -m grpc_tools.protoc -I. --pytools-ast_out=. xx.proto

Tools

Pythonic services

Generate more Pythonic services for all gRPC services defined in the xx_pb2.py file (generated by grpcio-tools):

$ python -m grpc_pytools.pythonic --proto-ast-file=/path/to/xx_ast.json --pb2-module-name=python.path.to.xx_pb2

Marshmallow schemas

Generate Marshmallow schemas for all gRPC messages defined in the xx_pb2.py file:

$ python -m grpc_pytools.marshmallow --proto-ast-file=/path/to/xx_ast.json --pb2-module-name=python.path.to.xx_pb2

RESTArt APIs

Generate simple RESTArt APIs for all gRPC methods defined in the xx_pb2.py file:

$ python -m grpc_pytools.restart --proto-ast-file=/path/to/xx_ast.json --pb2-module-name=python.path.to.xx_pb2 --grpc-server=localhost:50051

Examples

See examples to find out how to generate a simple JSON proxy for gRPC services.

License

MIT