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 max_message_size to the argparser
Browse files Browse the repository at this point in the history
  • Loading branch information
hanhxiao committed Aug 9, 2019
1 parent 68d2568 commit e516646
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -36,7 +36,8 @@
<a href="#documentation">Documentation</a> •
<a href="#tutorial">Tutorial</a> •
<a href="#contributing">Contributing</a> •
<a href="./CHANGELOG.md">Release Notes</a>
<a href="./CHANGELOG.md">Release Notes</a>
<a href="https://hanxiao.github.io/2019/07/29/Generic-Neural-Elastic-Search-From-bert-as-service-and-Go-Way-Beyond/">Blog</a>
</p>

<h2 align="center">What is it</h2>
Expand Down
6 changes: 2 additions & 4 deletions gnes/cli/parser.py
Expand Up @@ -217,6 +217,8 @@ def _set_grpc_parser(parser=None):
type=int,
default=8800,
help='host port of the grpc service')
parser.add_argument('--max_message_size', type=int, default=100,
help='maximum send and receive size for grpc server in (MB)')
return parser


Expand All @@ -231,10 +233,6 @@ def set_grpc_frontend_parser(parser=None):
read_only=True)
parser.add_argument('--max_concurrency', type=int, default=10,
help='maximum concurrent client allowed')
parser.add_argument('--max_send_size', type=int, default=100,
help='maximum send size for grpc server in (MB)')
parser.add_argument('--max_receive_size', type=int, default=100,
help='maximum receive size for grpc server in (MB)')
return parser


Expand Down
4 changes: 2 additions & 2 deletions gnes/client/cli.py
Expand Up @@ -37,8 +37,8 @@ def __init__(self, args):

with grpc.insecure_channel(
'%s:%s' % (args.grpc_host, args.grpc_port),
options=[('grpc.max_send_message_length', 70 * 1024 * 1024),
('grpc.max_receive_message_length', 70 * 1024 * 1024)]) as channel:
options=[('grpc.max_send_message_length', args.max_message_size * 1024 * 1024),
('grpc.max_receive_message_length', args.max_message_size * 1024 * 1024)]) as channel:
stub = gnes_pb2_grpc.GnesRPCStub(channel)

if args.mode == 'train':
Expand Down
4 changes: 2 additions & 2 deletions gnes/client/http.py
Expand Up @@ -94,8 +94,8 @@ def stub_call(req):

with grpc.insecure_channel(
'%s:%s' % (self.args.grpc_host, self.args.grpc_port),
options=[('grpc.max_send_message_length', 100 * 1024 * 1024),
('grpc.max_receive_message_length', 100 * 1024 * 1024),
options=[('grpc.max_send_message_length', self.args.max_message_size * 1024 * 1024),
('grpc.max_receive_message_length', self.args.max_message_size * 1024 * 1024),
('grpc.keepalive_timeout_ms', 100 * 1000)]) as channel:
stub = gnes_pb2_grpc.GnesRPCStub(channel)
loop.run_until_complete(init(loop))
Expand Down
1 change: 1 addition & 0 deletions gnes/service/base.py
Expand Up @@ -114,6 +114,7 @@ def build_socket(ctx: 'zmq.Context', host: str, port: int, socket_type: 'SocketT
}[socket_type]()

if socket_type.is_bind:
host = BaseService.default_host
if port is None:
sock.bind_to_random_port('tcp://%s' % host)
else:
Expand Down
4 changes: 2 additions & 2 deletions gnes/service/grpc.py
Expand Up @@ -146,8 +146,8 @@ def __init__(self, args):
self.logger = set_logger(self.__class__.__name__, args.verbose)
self.server = grpc.server(
futures.ThreadPoolExecutor(max_workers=args.max_concurrency),
options=[('grpc.max_send_message_length', args.max_send_size * 1024 * 1024),
('grpc.max_receive_message_length', args.max_receive_size * 1024 * 1024)])
options=[('grpc.max_send_message_length', args.max_message_size * 1024 * 1024),
('grpc.max_receive_message_length', args.max_message_size * 1024 * 1024)])
self.logger.info('start a grpc server with %d workers' % args.max_concurrency)
gnes_pb2_grpc.add_GnesRPCServicer_to_server(GNESServicer(args), self.server)

Expand Down

0 comments on commit e516646

Please sign in to comment.