Remove create_module func
@@ -54,72 +54,6 @@ PYTHON_DIR = "python"
PROCESSOR_NAME = "processor"
# PaddleHub var prefix
HUB_VAR_PREFIX = "@HUB_%s@"
-# PaddleHub Module package suffix
-HUB_PACKAGE_SUFFIX = "phm"
-
-
-def create_module(directory, name, author, email, module_type, summary,
- version):
- save_file = "{}-{}.{}".format(name, version, HUB_PACKAGE_SUFFIX)
-
- with tmp_dir() as base_dir:
- # package the module
- with tarfile.open(save_file, "w:gz") as tar:
- module_dir = os.path.join(base_dir, name)
- shutil.copytree(directory, module_dir)
-
- # record module info and serialize
- desc = module_desc_pb2.ModuleDesc()
- attr = desc.attr
- attr.type = module_desc_pb2.MAP
- module_info = attr.map.data['module_info']
- module_info.type = module_desc_pb2.MAP
- utils.from_pyobj_to_module_attr(name, module_info.map.data['name'])
- utils.from_pyobj_to_module_attr(author,
- module_info.map.data['author'])
- utils.from_pyobj_to_module_attr(
- email, module_info.map.data['author_email'])
- utils.from_pyobj_to_module_attr(module_type,
- module_info.map.data['type'])
- utils.from_pyobj_to_module_attr(summary,
- module_info.map.data['summary'])
- utils.from_pyobj_to_module_attr(version,
- module_info.map.data['version'])
- module_desc_path = os.path.join(module_dir, "module_desc.pb")
- with open(module_desc_path, "wb") as f:
- f.write(desc.SerializeToString())
-
- # generate check info
- checker = ModuleChecker(module_dir)
- checker.generate_check_info()
-
- # add __init__
- module_init = os.path.join(module_dir, "__init__.py")
- with open(module_init, "a") as file:
- file.write("")
-
- _cwd = os.getcwd()
- os.chdir(base_dir)
- module_dir = module_dir.replace(base_dir, ".")
- tar.add(module_dir, recursive=False)
- files = []
- for dirname, _, subfiles in os.walk(module_dir):
- for file in subfiles:
- # if file.startswith("."):
- # continue
- files.append(os.path.join(dirname, file))
-
- total_length = len(files)
- print("Create Module {}-{}".format(name, version))
- for index, file in enumerate(files):
- done = int(float(index) / total_length * 50)
- progress("[%-50s] %.2f%%" % ('=' * done,
- float(index / total_length * 100)))
- tar.add(file)
- progress("[%-50s] %.2f%%" % ('=' * 50, 100), end=True)
- print("Module package saved as {}".format(save_file))
- os.chdir(_cwd)
-
_module_runnable_func = {}
