未验证 提交 df15dd14 编写于 作者: S Steffy-zxf 提交者: GitHub

fix load module in py2 (#441)

* fix load module in py2
上级 36d7d800
...@@ -74,8 +74,9 @@ class LocalModuleManager(object): ...@@ -74,8 +74,9 @@ class LocalModuleManager(object):
_item = _module.__dict__[_item] _item = _module.__dict__[_item]
_file = os.path.realpath( _file = os.path.realpath(
sys.modules[_item.__module__].__file__) sys.modules[_item.__module__].__file__)
if issubclass(_item, if issubclass(
hub.Module) and _file == module_file: _item,
hub.Module) and _file.startwith(module_file):
version = _item._version version = _item._version
break break
sys.path.pop(0) sys.path.pop(0)
......
...@@ -194,7 +194,7 @@ class Module(object): ...@@ -194,7 +194,7 @@ class Module(object):
_file = os.path.realpath(sys.modules[_item.__module__].__file__) _file = os.path.realpath(sys.modules[_item.__module__].__file__)
_module_path = os.path.realpath( _module_path = os.path.realpath(
os.path.join(directory, "module.py")) os.path.join(directory, "module.py"))
if issubclass(_item, Module) and _file == _module_path: if issubclass(_item, Module) and _file.startswith(_module_path):
user_module = _item(directory=directory, **kwargs) user_module = _item(directory=directory, **kwargs)
break break
sys.path.pop(0) sys.path.pop(0)
......
...@@ -124,8 +124,8 @@ class NLPPredictionModule(NLPBaseModule): ...@@ -124,8 +124,8 @@ class NLPPredictionModule(NLPBaseModule):
Run as a command Run as a command
""" """
self.parser = argparse.ArgumentParser( self.parser = argparse.ArgumentParser(
description='Run the %s module.' % self.module_name, description='Run the %s module.' % self.name,
prog='hub run %s' % self.module_name, prog='hub run %s' % self.name,
usage='%(prog)s', usage='%(prog)s',
add_help=True) add_help=True)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册