Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:delayed_padatious_training #627

Merged
merged 4 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions ovos_core/intent_services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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')
Expand Down
25 changes: 21 additions & 4 deletions ovos_core/skill_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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:
Expand All @@ -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.
Expand Down Expand Up @@ -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 = []
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion requirements/lgpl.txt
Original file line number Diff line number Diff line change
@@ -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
Loading