From 86d412f0c769a62a1231f33776a0a5fa20f5dfdc Mon Sep 17 00:00:00 2001 From: miro Date: Mon, 9 Dec 2024 15:36:27 +0000 Subject: [PATCH 1/4] optimize: dont load padacioso if not needed by default --- ovos_core/intent_services/__init__.py | 39 +++++++++++++++++++-------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/ovos_core/intent_services/__init__.py b/ovos_core/intent_services/__init__.py index 9831b9511e47..f97e3cfd5e05 100644 --- a/ovos_core/intent_services/__init__.py +++ b/ovos_core/intent_services/__init__.py @@ -99,7 +99,14 @@ def _load_pipeline_plugins(self): except ImportError: LOG.error(f'Failed to create padatious intent handlers, padatious not installed') - self._padacioso_service = PadaciosoService(self.bus, self.config["padatious"]) + # by default only load padacioso is padatious is not available + # save memory if padacioso isnt needed + disable_padacioso = self.config.get("disable_padacioso", self._padatious_service is not None) + if not disable_padacioso: + self._padacioso_service = PadaciosoService(self.bus, self.config["padatious"]) + elif "disable_padacioso" not in self.config: + LOG.debug("Padacioso pipeline is disabled, only padatious is loaded. " + "set 'disable_padacioso': false in mycroft.conf if you want it to load alongside padatious") self._fallback = FallbackService(self.bus) self._converse = ConverseService(self.bus) self._common_qa = CommonQAService(self.bus, self.config.get("common_query")) @@ -171,11 +178,13 @@ def get_pipeline(self, skips=None, session=None) -> Tuple[str, Callable]: # Create matchers # TODO - from plugins + padatious_matcher = None if self._padatious_service is None: - if any("padatious" in p for p in session.pipeline): - LOG.warning("padatious is not available! using padacioso in it's place, " - "intent matching will be extremely slow in comparison") - padatious_matcher = self._padacioso_service + if self._padacioso_service is not None: + if any("padatious" in p for p in session.pipeline): + LOG.warning("padatious is not available! using padacioso in it's place, " + "intent matching will be extremely slow in comparison") + padatious_matcher = self._padacioso_service else: padatious_matcher = self._padatious_service @@ -184,20 +193,28 @@ def get_pipeline(self, skips=None, session=None) -> Tuple[str, Callable]: "stop_high": self._stop.match_stop_high, "stop_medium": self._stop.match_stop_medium, "stop_low": self._stop.match_stop_low, - "padatious_high": padatious_matcher.match_high, - "padacioso_high": self._padacioso_service.match_high, "adapt_high": self._adapt_service.match_high, "common_qa": self._common_qa.match, "fallback_high": self._fallback.high_prio, - "padatious_medium": padatious_matcher.match_medium, - "padacioso_medium": self._padacioso_service.match_medium, "adapt_medium": self._adapt_service.match_medium, "fallback_medium": self._fallback.medium_prio, - "padatious_low": padatious_matcher.match_low, - "padacioso_low": self._padacioso_service.match_low, "adapt_low": self._adapt_service.match_low, "fallback_low": self._fallback.low_prio } + if self._padacioso_service is not None: + matchers.update({ + "padacioso_high": self._padacioso_service.match_high, + "padacioso_medium": self._padacioso_service.match_medium, + "padacioso_low": self._padacioso_service.match_low, + + }) + if self._padatious_service is not None: + matchers.update({ + "padatious_high": padatious_matcher.match_high, + "padatious_medium": padatious_matcher.match_medium, + "padatious_low": padatious_matcher.match_low, + + }) if self._ocp is not None: matchers.update({ "ocp_high": self._ocp.match_high, From e95457666cfeb173654d12efcbbf25201a59a8a2 Mon Sep 17 00:00:00 2001 From: miro Date: Tue, 10 Dec 2024 20:24:33 +0000 Subject: [PATCH 2/4] fix shutdown --- ovos_core/intent_services/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ovos_core/intent_services/__init__.py b/ovos_core/intent_services/__init__.py index f97e3cfd5e05..c91b0cc06031 100644 --- a/ovos_core/intent_services/__init__.py +++ b/ovos_core/intent_services/__init__.py @@ -495,7 +495,8 @@ def shutdown(self): self.utterance_plugins.shutdown() self.metadata_plugins.shutdown() self._adapt_service.shutdown() - self._padacioso_service.shutdown() + if self._padacioso_service: + self._padacioso_service.shutdown() if self._padatious_service: self._padatious_service.shutdown() self._common_qa.shutdown() From a26ea924235d56abbfa0bcf8a3e35c1db2f8a3c2 Mon Sep 17 00:00:00 2001 From: miro Date: Tue, 10 Dec 2024 21:11:05 +0000 Subject: [PATCH 3/4] error handling --- ovos_core/intent_services/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ovos_core/intent_services/__init__.py b/ovos_core/intent_services/__init__.py index c91b0cc06031..af0d89ce90b4 100644 --- a/ovos_core/intent_services/__init__.py +++ b/ovos_core/intent_services/__init__.py @@ -208,7 +208,7 @@ def get_pipeline(self, skips=None, session=None) -> Tuple[str, Callable]: "padacioso_low": self._padacioso_service.match_low, }) - if self._padatious_service is not None: + if padatious_matcher is not None: matchers.update({ "padatious_high": padatious_matcher.match_high, "padatious_medium": padatious_matcher.match_medium, From 9a872273629ed5e04447963d3f5fa0b4d0c9c159 Mon Sep 17 00:00:00 2001 From: miro Date: Tue, 10 Dec 2024 21:27:22 +0000 Subject: [PATCH 4/4] logs --- ovos_core/intent_services/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ovos_core/intent_services/__init__.py b/ovos_core/intent_services/__init__.py index af0d89ce90b4..b468559ca4a7 100644 --- a/ovos_core/intent_services/__init__.py +++ b/ovos_core/intent_services/__init__.py @@ -180,11 +180,14 @@ def get_pipeline(self, skips=None, session=None) -> Tuple[str, Callable]: # TODO - from plugins padatious_matcher = None if self._padatious_service is None: + needs_pada = any("padatious" in p for p in session.pipeline) if self._padacioso_service is not None: - if any("padatious" in p for p in session.pipeline): + if needs_pada: LOG.warning("padatious is not available! using padacioso in it's place, " "intent matching will be extremely slow in comparison") padatious_matcher = self._padacioso_service + elif needs_pada: + LOG.warning("padatious is not available! only adapt (keyword based) intents will match!") else: padatious_matcher = self._padatious_service