diff --git a/ovos_core/intent_services/__init__.py b/ovos_core/intent_services/__init__.py index a22c518b333..9831b9511e4 100644 --- a/ovos_core/intent_services/__init__.py +++ b/ovos_core/intent_services/__init__.py @@ -15,14 +15,16 @@ from collections import defaultdict from typing import Tuple, Callable, Union -from ocp_pipeline.opm import OCPPipelineMatcher from ovos_adapt.opm import AdaptPipeline +from ovos_commonqa.opm import CommonQAService +from padacioso.opm import PadaciosoPipeline as PadaciosoService + +from ocp_pipeline.opm import OCPPipelineMatcher from ovos_bus_client.message import Message from ovos_bus_client.session import SessionManager from ovos_bus_client.util import get_message_lang -from ovos_commonqa.opm import CommonQAService from ovos_config.config import Configuration -from ovos_config.locale import setup_locale, get_valid_languages +from ovos_config.locale import get_valid_languages from ovos_core.intent_services.converse_service import ConverseService from ovos_core.intent_services.fallback_service import FallbackService from ovos_core.intent_services.stop_service import StopService @@ -31,7 +33,6 @@ from ovos_utils.lang import standardize_lang_tag from ovos_utils.log import LOG, log_deprecation, deprecated from ovos_utils.metrics import Stopwatch -from padacioso.opm import PadaciosoPipeline as PadaciosoService class IntentService: @@ -92,6 +93,8 @@ def _load_pipeline_plugins(self): LOG.info("padatious forcefully disabled in config") else: from ovos_padatious.opm import PadatiousPipeline + if "instant_train" not in self.config["padatious"]: + 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 eb333bda6ae..b2d2cb89884 100644 --- a/ovos_core/skill_manager.py +++ b/ovos_core/skill_manager.py @@ -16,7 +16,6 @@ import os from os.path import basename from threading import Thread, Event, Lock - from time import monotonic from ovos_bus_client.apis.enclosure import EnclosureAPI @@ -118,8 +117,9 @@ def __init__(self, bus, watchdog=None, alive_hook=on_alive, started_hook=on_star self._logged_skill_warnings = list() self._detected_installed_skills = bool(find_skill_plugins()) if not self._detected_installed_skills: - LOG.warning("No installed skills detected! if you are running skills in standalone mode ignore this warning," - " otherwise you probably want to install skills first!") + LOG.warning( + "No installed skills detected! if you are running skills in standalone mode ignore this warning," + " otherwise you probably want to install skills first!") self.config = Configuration() @@ -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: @@ -310,6 +311,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. @@ -477,7 +480,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 = [] @@ -509,6 +512,20 @@ 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") + try: + response = self.bus.wait_for_response(Message("mycroft.skills.train"), + "mycroft.skills.trained", + timeout=60) # 60 second timeout + if not response: + LOG.error("Padatious training timed out") + elif response.data.get('error'): + LOG.error(f"Padatious training failed: {response.data['error']}") + except Exception as e: + LOG.exception(f"Error during padatious training: {e}") def _get_skill_loader(self, skill_directory, init_bus=True): """Get a skill loader instance. diff --git a/requirements/lgpl.txt b/requirements/lgpl.txt index f7e2afcd74f..a69b6b849b6 100644 --- a/requirements/lgpl.txt +++ b/requirements/lgpl.txt @@ -1,2 +1,2 @@ -ovos_padatious>=1.0.5, <2.0.0 +ovos_padatious>=1.1.0, <2.0.0 fann2>=1.0.7, < 1.1.0