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

Commit

Permalink
feat(frontend): dump route in the frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
hanhxiao committed Sep 24, 2019
1 parent 0492512 commit fe7025f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
13 changes: 6 additions & 7 deletions Dockerfiles/alpine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@ LABEL maintainer="[email protected]" \
org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="GNES is Generic Nerual Elastic Search"

RUN apk add --no-cache \
--virtual=.build-dependencies \
build-base g++ gfortran file binutils zeromq-dev \
musl-dev python3-dev py-pgen cython openblas-dev && \
apk add --no-cache libstdc++ openblas libzmq

WORKDIR /gnes/

ADD setup.py MANIFEST.in requirements.txt README.md ./
ADD gnes ./gnes/

RUN ln -s locale.h /usr/include/xlocale.h && \
RUN apk add --no-cache \
--virtual=.build-dependencies \
build-base g++ gfortran file binutils zeromq-dev \
musl-dev python3-dev py-pgen cython openblas-dev && \
apk add --no-cache libstdc++ openblas libzmq && \
ln -s locale.h /usr/include/xlocale.h && \
pip install . --no-cache-dir --compile && \
find /usr/lib/python3.7/ -name 'tests' -exec rm -r '{}' + && \
find /usr/lib/python3.7/site-packages/ -name '*.so' -print -exec sh -c 'file "{}" | grep -q "not stripped" && strip -s "{}"' \; && \
Expand Down
3 changes: 2 additions & 1 deletion gnes/cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ def set_frontend_parser(parser=None):
read_only=True)
parser.add_argument('--max_concurrency', type=int, default=10,
help='maximum concurrent connections allowed')

parser.add_argument('--dump_route', type=argparse.FileType('w', encoding='utf8'),
help='dumping route information to a file')
return parser


Expand Down
7 changes: 5 additions & 2 deletions gnes/service/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from concurrent.futures import ThreadPoolExecutor

import grpc
from google.protobuf.json_format import MessageToJson

from .. import __version__, __proto_version__
from ..client.base import ZmqClient
Expand Down Expand Up @@ -80,7 +81,8 @@ def remove_envelope(self, m: 'gnes_pb2.Message'):
if self.args.route_table:
self.logger.info('route: %s' % router2str(m))
self.logger.info('route table: \n%s' % make_route_table(m.envelope.routes, exclude_frontend=True))

if self.args.dump_route:
self.args.dump_route.write(MessageToJson(m.envelope, indent=0).replace('\n', '') + '\n')
return resp

def Call(self, request, context):
Expand Down Expand Up @@ -115,7 +117,8 @@ def StreamCall(self, request_iterator, context):
num_request -= 1
except TimeoutError:
if num_request > max_outstanding:
self.logger.warning("the network traffic exceed max outstanding (%d > %d)" % (num_request, max_outstanding))
self.logger.warning("the network traffic exceed max outstanding (%d > %d)" % (
num_request, max_outstanding))
continue
break
zmq_client.send_message(self.add_envelope(request, zmq_client), -1)
Expand Down
4 changes: 3 additions & 1 deletion tests/test_dict_indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ def setUp(self):
def test_pymode(self):
os.unsetenv('http_proxy')
os.unsetenv('https_proxy')
args = set_frontend_parser().parse_args([])
args = set_frontend_parser().parse_args([
'--dump_route', 'test.json'
])

p_args = set_preprocessor_parser().parse_args([
'--port_in', str(args.port_out),
Expand Down

0 comments on commit fe7025f

Please sign in to comment.