From e6e333fa9118cc2c761bdc88871030966093ca05 Mon Sep 17 00:00:00 2001 From: miro Date: Mon, 9 Dec 2024 15:36:27 +0000 Subject: [PATCH] feat:delayed_padatious_training --- ovos_core/intent_services/__init__.py | 2 ++ ovos_core/skill_manager.py | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ovos_core/intent_services/__init__.py b/ovos_core/intent_services/__init__.py index a22c518b333..6feb82eab8f 100644 --- a/ovos_core/intent_services/__init__.py +++ b/ovos_core/intent_services/__init__.py @@ -92,6 +92,8 @@ def _load_pipeline_plugins(self): LOG.info("padatious forcefully disabled in config") else: from ovos_padatious.opm import PadatiousPipeline + # TODO - read from config once default value has been added to ovos-config + self.config["padatious"]["instant_train"] = False self._padatious_service = PadatiousPipeline(self.bus, self.config["padatious"]) except ImportError: LOG.error(f'Failed to create padatious intent handlers, padatious not installed') diff --git a/ovos_core/skill_manager.py b/ovos_core/skill_manager.py index 50fe0c39050..9ebfb847bd2 100644 --- a/ovos_core/skill_manager.py +++ b/ovos_core/skill_manager.py @@ -288,6 +288,7 @@ def load_plugin_skills(self, network=None, internet=None): network (bool): Network connection status. internet (bool): Internet connection status. """ + loaded_new = False if network is None: network = self._network_event.is_set() if internet is None: @@ -309,6 +310,8 @@ def load_plugin_skills(self, network=None, internet=None): if not internet and requirements.internet_before_load: continue self._load_plugin_skill(skill_id, plug) + loaded_new = True + return loaded_new def _get_internal_skill_bus(self): """Get a dedicated skill bus connection per skill. @@ -473,7 +476,7 @@ def _load_new_skills(self, network=None, internet=None, gui=None): # There is a possible race condition where this handler would be executing several times otherwise. with self._lock: - self.load_plugin_skills(network=network, internet=internet) + loaded_new = self.load_plugin_skills(network=network, internet=internet) for skill_dir in self._get_skill_directories(): replaced_skills = [] @@ -505,6 +508,14 @@ def _load_new_skills(self, network=None, internet=None, gui=None): if skill_dir not in self.skill_loaders: self._load_skill(skill_dir) + loaded_new = True + + if loaded_new: + LOG.info("Requesting padatious intent training") + self.bus.wait_for_response(Message("padatious:train"), + "mycroft.skills.trained") + else: + LOG.debug("Nothing new to train") def _get_skill_loader(self, skill_directory, init_bus=True): """Get a skill loader instance.