Skip to content

Commit 4e95204

Browse files
authored
fix:delayed_padatious_training (#627)
* fix:delay_padatious_training * only set instant_train to False if not present in config * rename padatious:train to mycroft.skills.train to keep things intent engine agnostic * require padatious 1.1.0
1 parent 308b85e commit 4e95204

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

ovos_core/intent_services/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@
1515
from collections import defaultdict
1616
from typing import Tuple, Callable, Union
1717

18-
from ocp_pipeline.opm import OCPPipelineMatcher
1918
from ovos_adapt.opm import AdaptPipeline
19+
from ovos_commonqa.opm import CommonQAService
20+
from padacioso.opm import PadaciosoPipeline as PadaciosoService
21+
22+
from ocp_pipeline.opm import OCPPipelineMatcher
2023
from ovos_bus_client.message import Message
2124
from ovos_bus_client.session import SessionManager
2225
from ovos_bus_client.util import get_message_lang
23-
from ovos_commonqa.opm import CommonQAService
2426
from ovos_config.config import Configuration
25-
from ovos_config.locale import setup_locale, get_valid_languages
27+
from ovos_config.locale import get_valid_languages
2628
from ovos_core.intent_services.converse_service import ConverseService
2729
from ovos_core.intent_services.fallback_service import FallbackService
2830
from ovos_core.intent_services.stop_service import StopService
@@ -31,7 +33,6 @@
3133
from ovos_utils.lang import standardize_lang_tag
3234
from ovos_utils.log import LOG, log_deprecation, deprecated
3335
from ovos_utils.metrics import Stopwatch
34-
from padacioso.opm import PadaciosoPipeline as PadaciosoService
3536

3637

3738
class IntentService:
@@ -92,6 +93,8 @@ def _load_pipeline_plugins(self):
9293
LOG.info("padatious forcefully disabled in config")
9394
else:
9495
from ovos_padatious.opm import PadatiousPipeline
96+
if "instant_train" not in self.config["padatious"]:
97+
self.config["padatious"]["instant_train"] = False
9598
self._padatious_service = PadatiousPipeline(self.bus, self.config["padatious"])
9699
except ImportError:
97100
LOG.error(f'Failed to create padatious intent handlers, padatious not installed')

ovos_core/skill_manager.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import os
1717
from os.path import basename
1818
from threading import Thread, Event, Lock
19-
2019
from time import monotonic
2120

2221
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
118117
self._logged_skill_warnings = list()
119118
self._detected_installed_skills = bool(find_skill_plugins())
120119
if not self._detected_installed_skills:
121-
LOG.warning("No installed skills detected! if you are running skills in standalone mode ignore this warning,"
122-
" otherwise you probably want to install skills first!")
120+
LOG.warning(
121+
"No installed skills detected! if you are running skills in standalone mode ignore this warning,"
122+
" otherwise you probably want to install skills first!")
123123

124124
self.config = Configuration()
125125

@@ -288,6 +288,7 @@ def load_plugin_skills(self, network=None, internet=None):
288288
network (bool): Network connection status.
289289
internet (bool): Internet connection status.
290290
"""
291+
loaded_new = False
291292
if network is None:
292293
network = self._network_event.is_set()
293294
if internet is None:
@@ -310,6 +311,8 @@ def load_plugin_skills(self, network=None, internet=None):
310311
if not internet and requirements.internet_before_load:
311312
continue
312313
self._load_plugin_skill(skill_id, plug)
314+
loaded_new = True
315+
return loaded_new
313316

314317
def _get_internal_skill_bus(self):
315318
"""Get a dedicated skill bus connection per skill.
@@ -477,7 +480,7 @@ def _load_new_skills(self, network=None, internet=None, gui=None):
477480
# There is a possible race condition where this handler would be executing several times otherwise.
478481
with self._lock:
479482

480-
self.load_plugin_skills(network=network, internet=internet)
483+
loaded_new = self.load_plugin_skills(network=network, internet=internet)
481484

482485
for skill_dir in self._get_skill_directories():
483486
replaced_skills = []
@@ -509,6 +512,20 @@ def _load_new_skills(self, network=None, internet=None, gui=None):
509512

510513
if skill_dir not in self.skill_loaders:
511514
self._load_skill(skill_dir)
515+
loaded_new = True
516+
517+
if loaded_new:
518+
LOG.info("Requesting padatious intent training")
519+
try:
520+
response = self.bus.wait_for_response(Message("mycroft.skills.train"),
521+
"mycroft.skills.trained",
522+
timeout=60) # 60 second timeout
523+
if not response:
524+
LOG.error("Padatious training timed out")
525+
elif response.data.get('error'):
526+
LOG.error(f"Padatious training failed: {response.data['error']}")
527+
except Exception as e:
528+
LOG.exception(f"Error during padatious training: {e}")
512529

513530
def _get_skill_loader(self, skill_directory, init_bus=True):
514531
"""Get a skill loader instance.

requirements/lgpl.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
ovos_padatious>=1.0.5, <2.0.0
1+
ovos_padatious>=1.1.0, <2.0.0
22
fann2>=1.0.7, < 1.1.0

0 commit comments

Comments
 (0)