Skip to content
Permalink
Browse files

feat(frontend): dump route in the frontend

  • Loading branch information...
hanxiao committed Sep 24, 2019
1 parent 0492512 commit fe7025f5a2041602b4e6df04faa33a03ad9ad4b3
Showing with 16 additions and 11 deletions.
  1. +6 −7 Dockerfiles/alpine.Dockerfile
  2. +2 −1 gnes/cli/parser.py
  3. +5 −2 gnes/service/frontend.py
  4. +3 −1 tests/test_dict_indexer.py
@@ -9,18 +9,17 @@ LABEL maintainer="team@gnes.ai" \
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 "{}"' \; && \
@@ -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


@@ -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
@@ -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):
@@ -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)
@@ -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),

0 comments on commit fe7025f

Please sign in to comment.
You can’t perform that action at this time.