提交 a61b5c3d 编写于 作者: W wuzewu

Fix python2 compatibility issues

上级 048a9ec6
......@@ -62,5 +62,5 @@ class BaseCommand(object):
def print_args(self):
print_arguments(self.args)
def exec(self, argv):
def execute(self, argv):
raise NotImplementedError("Base Command should not be execute!")
......@@ -54,7 +54,7 @@ class ClearCommand(BaseCommand):
def cache_dir(self):
return CACHE_HOME
def exec(self, argv):
def execute(self, argv):
result = True
total_file_size = 0
total_file_count = 0
......
......@@ -43,7 +43,7 @@ class DownloadCommand(BaseCommand):
self.add_arg('--uncompress', bool, False, "uncompress the download package or not" )
# yapf: enable
def exec(self, argv):
def execute(self, argv):
if not argv:
print("ERROR: Please provide the model/module name\n")
self.help()
......
......@@ -30,7 +30,7 @@ class HelpCommand(BaseCommand):
def get_all_commands(self):
return BaseCommand.command_dict
def exec(self, argv):
def execute(self, argv):
hub_command = BaseCommand.command_dict["hub"]
help_text = "\n"
help_text += "Usage:\n"
......
......@@ -34,30 +34,30 @@ class HubCommand(BaseCommand):
super(HubCommand, self).__init__(name)
self.show_in_help = False
def exec(self, argv):
def execute(self, argv):
logger.setLevel("NOLOG")
if not argv:
help.command.exec(argv)
help.command.execute(argv)
exit(1)
return False
sub_command = argv[0]
if not sub_command in BaseCommand.command_dict:
print("ERROR: unknown command '%s'" % sub_command)
help.command.exec(argv)
help.command.execute(argv)
exit(1)
return False
command = BaseCommand.command_dict[sub_command]
return command.exec(argv[1:])
return command.execute(argv[1:])
command = HubCommand.instance()
def main():
command.exec(sys.argv[1:])
command.execute(sys.argv[1:])
if __name__ == "__main__":
command.exec(sys.argv[1:])
command.execute(sys.argv[1:])
......@@ -37,7 +37,7 @@ class InstallCommand(BaseCommand):
add_help=False)
#TODO(wuzewu): add --upgrade option
def exec(self, argv):
def execute(self, argv):
if not argv:
print("ERROR: Please specify a module name.\n")
self.help()
......
......@@ -31,7 +31,7 @@ class ListCommand(BaseCommand):
self.show_in_help = True
self.description = "List all installed PaddleHub modules."
def exec(self, argv):
def execute(self, argv):
all_modules = default_module_manager.all_modules()
if utils.is_windows():
placeholders = [20, 40]
......
......@@ -75,7 +75,7 @@ class RunCommand(BaseCommand):
demo = "%s %s %s" % (entry, self.name, module.name)
return demo
def exec(self, argv):
def execute(self, argv):
if not argv:
print("ERROR: Please specify a module name.\n")
self.help()
......
......@@ -37,7 +37,7 @@ class SearchCommand(BaseCommand):
usage='%(prog)s',
add_help=False)
def exec(self, argv):
def execute(self, argv):
if not argv:
argv = ['.*']
......
......@@ -108,7 +108,7 @@ class ShowCommand(BaseCommand):
print(tp.get_text())
return True
def exec(self, argv):
def execute(self, argv):
if not argv:
print("ERROR: Please specify a module or a model\n")
self.help()
......
......@@ -36,7 +36,7 @@ class UninstallCommand(BaseCommand):
usage='%(prog)s',
add_help=False)
def exec(self, argv):
def execute(self, argv):
if not argv:
print("ERROR: Please specify a module\n")
self.help()
......
......@@ -28,7 +28,7 @@ class VersionCommand(BaseCommand):
self.show_in_help = True
self.description = "Show PaddleHub's version."
def exec(self, argv):
def execute(self, argv):
print("hub %s" % version.hub_version)
return True
......
......@@ -239,14 +239,14 @@ class Module(object):
continue
var = global_block.var(param['name'])
global_block.create_parameter(
**param,
shape=var.shape,
dtype=var.dtype,
type=var.type,
lod_level=var.lod_level,
error_clip=var.error_clip,
stop_gradient=var.stop_gradient,
is_data=var.is_data)
is_data=var.is_data,
**param)
def _recover_variable_info(self, program):
var_infos = self.desc.attr.map.data['var_infos']
......@@ -422,8 +422,7 @@ class Module(object):
self.check_processor()
def _get_reader_and_feeder(data_format, data, place):
def _reader():
nonlocal process_data
def _reader(process_data):
for item in zip(*process_data):
yield item
......@@ -433,7 +432,7 @@ class Module(object):
process_data.append([value['processed'] for value in data[key]])
feed_name_list.append(data_format[key]['feed_key'])
feeder = fluid.DataFeeder(feed_list=feed_name_list, place=place)
return _reader, feeder
return functools.partial(_reader, process_data=process_data), feeder
feed_dict, fetch_dict, program = self.context(sign_name, for_test=True)
#TODO(wuzewu): more option
......
......@@ -12,5 +12,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.
""" PaddleHub version string """
hub_version = "0.4.0.alpha"
module_proto_version = "0.1.0"
hub_version = "0.4.2.alpha"
module_proto_version = "1.0.0"
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册