Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
fix(grpc): add auto-gen grpc code
Browse files Browse the repository at this point in the history
  • Loading branch information
Larryjianfeng committed Jul 22, 2019
1 parent b89d8fa commit 6e6bbf8
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 5 deletions.
22 changes: 20 additions & 2 deletions gnes/proto/gnes_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions gnes/proto/gnes_pb2_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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 = {
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions shell/make-proto.sh
Original file line number Diff line number Diff line change
@@ -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.