Skip to content
Permalink
Browse files

fix(compose): fix import

  • Loading branch information...
hanxiao committed Jul 19, 2019
1 parent 9bbb3c0 commit 69a486e5092d0e5b7b0e84a907cd5a9294dc01b9
Showing with 12 additions and 13 deletions.
  1. +8 −8 gnes/cli/parser.py
  2. +4 −5 gnes/composer/base.py
@@ -116,12 +116,12 @@ def _set_client_parser(parser=None):
def set_loadable_service_parser(parser=None):
if not parser:
parser = set_base_parser()
import pkg_resources
from pkg_resources import resource_stream
from ..service.base import SocketType
set_service_parser(parser)

parser.add_argument('--yaml_path', type=argparse.FileType('r'),
default=pkg_resources.resource_stream(
default=resource_stream(
'gnes', '/'.join(('resources', 'config', 'encoder', 'default.yml'))),
help='yaml config of the service')

@@ -133,21 +133,21 @@ def set_loadable_service_parser(parser=None):
def set_preprocessor_service_parser(parser=None):
if not parser:
parser = set_base_parser()
import pkg_resources
from pkg_resources import resource_stream
set_loadable_service_parser(parser)
parser.set_defaults(yaml_path=pkg_resources.resource_stream(
parser.set_defaults(yaml_path=resource_stream(
'gnes', '/'.join(('resources', 'config', 'preprocessor', 'default.yml'))))

parser.set_defaults(read_only=True)
return parser


def set_router_service_parser(parser=None):
import pkg_resources
from pkg_resources import resource_stream
if not parser:
parser = set_base_parser()
set_loadable_service_parser(parser)
parser.set_defaults(yaml_path=pkg_resources.resource_stream(
parser.set_defaults(yaml_path=resource_stream(
'gnes', '/'.join(('resources', 'config', 'router', 'default.yml'))))

parser.set_defaults(read_only=True)
@@ -156,12 +156,12 @@ def set_router_service_parser(parser=None):

def set_indexer_service_parser(parser=None):
from ..service.base import SocketType
import pkg_resources
from pkg_resources import resource_stream

if not parser:
parser = set_base_parser()
set_loadable_service_parser(parser)
parser.set_defaults(yaml_path=pkg_resources.resource_stream(
parser.set_defaults(yaml_path=resource_stream(
'gnes', '/'.join(('resources', 'config', 'indexer', 'default.yml'))))

# encoder's port_out is indexer's port_in
@@ -4,7 +4,7 @@
from collections import defaultdict
from typing import Dict, List

import pkg_resources
from pkg_resources import resource_stream
from ruamel.yaml import YAML, StringIO
from ruamel.yaml.comments import CommentedMap
from termcolor import colored
@@ -140,7 +140,7 @@ def build_layers(self) -> List['YamlGraph.Layer']:
@staticmethod
def build_dockerswarm(all_layers: List['YamlGraph.Layer'], docker_img: str = 'gnes/gnes:latest',
volumes: Dict = None, networks: Dict = None) -> str:
with pkg_resources.resource_stream('gnes', '/'.join(('resources', 'compose', 'gnes-swarm.yml'))) as r:
with resource_stream('gnes', '/'.join(('resources', 'compose', 'gnes-swarm.yml'))) as r:
swarm_lines = _yaml.load(r)
taboo = {'name', 'replicas', 'yaml_path'}
config_dict = {}
@@ -233,8 +233,7 @@ def build_shell(all_layers: List['YamlGraph.Layer'], log_redirect: str = None) -
shell_lines.append('gnes %s %s %s &' % (
cmd, args, '>> %s 2>&1' % log_redirect if log_redirect else ''))

r = pkg_resources.resource_stream('gnes', '/'.join(('resources', 'compose', 'gnes-shell.sh')))
with r:
with resource_stream('gnes', '/'.join(('resources', 'compose', 'gnes-shell.sh'))) as r:
return r.read().decode().replace('{{gnes-template}}', '\n'.join(shell_lines))

@staticmethod
@@ -282,7 +281,7 @@ def build_mermaid(all_layers: List['YamlGraph.Layer'], mermaid_leftright: bool =

@staticmethod
def build_html(generate_dict: Dict[str, str]) -> str:
with pkg_resources.resource_stream('gnes', '/'.join(('resources', 'compose', 'gnes-board.html'))) as r:
with resource_stream('gnes', '/'.join(('resources', 'compose', 'gnes-board.html'))) as r:
html = r.read().decode()
for k, v in generate_dict.items():
if v:

0 comments on commit 69a486e

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