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

Commit

Permalink
ci(torchvision): install torchvision dependency to enable tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hanhxiao committed Jul 25, 2019
1 parent ac55cec commit 7fcd50d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions gnes/cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def set_preprocessor_service_parser(parser=None):
parser = set_base_parser()
from pkg_resources import resource_stream
set_loadable_service_parser(parser)
parser.get_default('yaml_path').close()
parser.set_defaults(yaml_path=resource_stream(
'gnes', '/'.join(('resources', 'config', 'preprocessor', 'default.yml'))))

Expand All @@ -166,6 +167,7 @@ def set_router_service_parser(parser=None):
if not parser:
parser = set_base_parser()
set_loadable_service_parser(parser)
parser.get_default('yaml_path').close()
parser.set_defaults(yaml_path=resource_stream(
'gnes', '/'.join(('resources', 'config', 'router', 'default.yml'))))

Expand All @@ -180,6 +182,7 @@ def set_indexer_service_parser(parser=None):
if not parser:
parser = set_base_parser()
set_loadable_service_parser(parser)
parser.get_default('yaml_path').close()
parser.set_defaults(yaml_path=resource_stream(
'gnes', '/'.join(('resources', 'config', 'indexer', 'default.yml'))))

Expand Down
16 changes: 13 additions & 3 deletions tests/test_preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import unittest

from gnes.cli.parser import set_preprocessor_service_parser, _set_client_parser
from gnes.composer.base import YamlComposer
from gnes.proto import gnes_pb2
from gnes.service.grpc import ZmqClient
from gnes.service.preprocessor import PreprocessorService
Expand All @@ -15,12 +16,18 @@ def setUp(self):
self.dirname = os.path.dirname(__file__)

def test_preprocessor_service_empty(self):
args = set_preprocessor_service_parser().parse_args([])
args = set_preprocessor_service_parser().parse_args([
'--port_in', str(YamlComposer._get_random_port()),
'--port_out', str(YamlComposer._get_random_port())
])
with PreprocessorService(args):
pass

def test_preprocessor_service_echo(self):
args = set_preprocessor_service_parser().parse_args([])
args = set_preprocessor_service_parser().parse_args([
'--port_in', str(YamlComposer._get_random_port()),
'--port_out', str(YamlComposer._get_random_port())
])
c_args = _set_client_parser().parse_args([
'--port_in', str(args.port_out),
'--port_out', str(args.port_in)
Expand All @@ -37,7 +44,10 @@ def test_preprocessor_service_echo(self):
print(r)

def test_preprocessor_service_realdata(self):
args = set_preprocessor_service_parser().parse_args([])
args = set_preprocessor_service_parser().parse_args([
'--port_in', str(YamlComposer._get_random_port()),
'--port_out', str(YamlComposer._get_random_port())
])
c_args = _set_client_parser().parse_args([
'--port_in', str(args.port_out),
'--port_out', str(args.port_in)
Expand Down

0 comments on commit 7fcd50d

Please sign in to comment.