Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
fix(grpc): add auto-gen grpc code
  • Loading branch information
Larryjianfeng committed Jul 22, 2019
1 parent b89d8fa commit 6e6bbf834933b2fa04ab6c62c3c64421b6fed360
Showing with 57 additions and 5 deletions.
  1. +20 −2 gnes/proto/gnes_pb2.py
  2. +34 −0 gnes/proto/gnes_pb2_grpc.py
  3. +3 −3 shell/make-proto.sh

Some generated files are not rendered by default. Learn more.

@@ -34,6 +34,16 @@ def __init__(self, channel):
request_serializer=gnes__pb2.Request.SerializeToString,
response_deserializer=gnes__pb2.Response.FromString,
)
self.TrainStream = channel.stream_unary(
'/gnes.GnesRPC/TrainStream',
request_serializer=gnes__pb2.Request.SerializeToString,
response_deserializer=gnes__pb2.Response.FromString,
)
self.IndexStream = channel.stream_unary(
'/gnes.GnesRPC/IndexStream',
request_serializer=gnes__pb2.Request.SerializeToString,
response_deserializer=gnes__pb2.Response.FromString,
)


class GnesRPCServicer(object):
@@ -69,6 +79,20 @@ def _Call(self, request, context):
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def TrainStream(self, request_iterator, context):
# missing associated documentation comment in .proto file
pass
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def IndexStream(self, request_iterator, context):
# missing associated documentation comment in .proto file
pass
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')


def add_GnesRPCServicer_to_server(servicer, server):
rpc_method_handlers = {
@@ -92,6 +116,16 @@ def add_GnesRPCServicer_to_server(servicer, server):
request_deserializer=gnes__pb2.Request.FromString,
response_serializer=gnes__pb2.Response.SerializeToString,
),
'TrainStream': grpc.stream_unary_rpc_method_handler(
servicer.TrainStream,
request_deserializer=gnes__pb2.Request.FromString,
response_serializer=gnes__pb2.Response.SerializeToString,
),
'IndexStream': grpc.stream_unary_rpc_method_handler(
servicer.IndexStream,
request_deserializer=gnes__pb2.Request.FromString,
response_serializer=gnes__pb2.Response.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'gnes.GnesRPC', rpc_method_handlers)
@@ -1,10 +1,10 @@
#!/usr/bin/env bash

SRC_DIR=../gnes/proto/
PLUGIN_PATH=/Volumes/TOSHIBA-4T/Documents/grpc/bins/opt/grpc_python_plugin
#PLUGIN_PATH=/Users/yanlarry/Desktop/git/grpc/bins/opt/grpc_python_plugin
#PLUGIN_PATH=/Volumes/TOSHIBA-4T/Documents/grpc/bins/opt/grpc_python_plugin
PLUGIN_PATH=/Users/yanlarry/Desktop/git/grpc/bins/opt/grpc_python_plugin

protoc -I ${SRC_DIR} --python_out=${SRC_DIR} --grpc_python_out=${SRC_DIR} --plugin=protoc-gen-grpc_python=${PLUGIN_PATH} ${SRC_DIR}gnes.proto

# fix import bug in google generator
sed -i '' -e '4s/.*/from\ \.\ import\ gnes_pb2\ as\ gnes__pb2/' ${SRC_DIR}gnes_pb2_grpc.py
sed -i '' -e '4s/.*/from\ \.\ import\ gnes_pb2\ as\ gnes__pb2/' ${SRC_DIR}gnes_pb2_grpc.py

0 comments on commit 6e6bbf8

Please sign in to comment.