Beispiel #1
0
    def execute(self, argv):
        if not argv:
            print("ERROR: Please specify a module or a model\n")
            self.help()
            return False

        module_name = argv[0]
        CacheUpdater("hub_show", module_name).start()

        # nlp model
        model_info_file = os.path.join(module_name, "info.yml")
        if os.path.exists(model_info_file):
            self.show_model_info(model_info_file)
            return True

        cwd = os.getcwd()
        module_dir = default_module_manager.search_module(module_name)
        module_dir = (os.path.join(cwd, module_name),
                      None) if not module_dir else module_dir
        if not module_dir or not os.path.exists(module_dir[0]):
            print("%s is not existed!" % module_name)
            return True

        self.show_module_info(module_dir)
        return True
Beispiel #2
0
    def find_module(self, module_name):
        module_dir = default_module_manager.search_module(module_name)
        if not module_dir:
            if os.path.exists(module_name):
                module_dir = (module_name, None)
            else:
                print("Install Module %s" % module_name)
                result, tips, module_dir = default_module_manager.install_module(
                    module_name)
                print(tips)
                if not result:
                    return None

        return hub.Module(module_dir=module_dir)
Beispiel #3
0
    def find_module(self, module_name):
        module_dir = default_module_manager.search_module(module_name)
        if not module_dir:
            if os.path.exists(module_name):
                module_dir = (module_name, None)
            else:
                print("Install Module %s" % module_name)
                extra = {"command": "install"}
                result, tips, module_dir = default_module_manager.install_module(
                    module_name, extra=extra)
                print(tips)
                if not result:
                    return None

        return hub.Module(directory=module_dir[0])