From fc546b2393761801c41b2355fe874328ec419959 Mon Sep 17 00:00:00 2001 From: Daniel McKnight <34697904+NeonDaniel@users.noreply.github.com> Date: Tue, 2 Nov 2021 11:51:00 -0700 Subject: [PATCH] Handle no plugin in Translator and Detector factory methods (#164) Add default libretranslate plugin to base requirements.txt --- neon_core/language/__init__.py | 16 +++++++++++----- requirements/requirements.txt | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/neon_core/language/__init__.py b/neon_core/language/__init__.py index 7133aa415..204d6a2d3 100644 --- a/neon_core/language/__init__.py +++ b/neon_core/language/__init__.py @@ -22,12 +22,13 @@ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from neon_core.configuration import Configuration, get_private_keys -from ovos_plugin_manager.language import load_lang_detect_plugin, \ - load_tx_plugin + import os -from neon_utils.configuration_utils import get_neon_lang_config +from ovos_plugin_manager.language import load_lang_detect_plugin, \ + load_tx_plugin +from neon_utils.configuration_utils import get_neon_lang_config, LOG +from neon_core.configuration import Configuration, get_private_keys def get_lang_config(): @@ -75,6 +76,9 @@ def create(module=None): clazz = load_tx_plugin(module) else: clazz = TranslatorFactory.CLASSES.get(module) + if not clazz: + LOG.error(f"Configured translation module not found ({module})") + return None config["keys"] = get_private_keys() return clazz(config) @@ -92,6 +96,8 @@ def create(module=None): clazz = load_lang_detect_plugin(module) else: clazz = DetectorFactory.CLASSES.get(module) - + if not clazz: + LOG.error(f"Configured detection module not found ({module})") + return None config["keys"] = get_private_keys() return clazz(config) diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 5277d8607..3497c6f12 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -16,6 +16,7 @@ ovos-skills-manager>=0.0.2 # plugins ovos-plugin-manager==0.0.1 +neon-lang-plugin-libretranslate>=0.1.2 # text parser modules RAKEkeywords>=0.2.0