From 1ce61a02b5de916971d99627589ff4a1f621618c Mon Sep 17 00:00:00 2001 From: miro Date: Tue, 15 Oct 2024 23:10:55 +0100 Subject: [PATCH 1/5] fix:log_spam --- ovos_core/intent_services/__init__.py | 74 ++++++++++++++------------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/ovos_core/intent_services/__init__.py b/ovos_core/intent_services/__init__.py index da3e3ccaa4f..67b11cc530f 100644 --- a/ovos_core/intent_services/__init__.py +++ b/ovos_core/intent_services/__init__.py @@ -14,11 +14,13 @@ # from typing import Tuple, Callable -from ocp_pipeline.opm import OCPPipelineMatcher -from ovos_adapt.opm import AdaptPipeline as AdaptService 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_workshop.intents import open_intent_envelope + +from ocp_pipeline.opm import OCPPipelineMatcher +from ovos_adapt.opm import AdaptPipeline as AdaptService from ovos_commonqa.opm import CommonQAService from ovos_config.config import Configuration from ovos_config.locale import setup_locale, get_valid_languages, get_full_lang_code @@ -29,7 +31,6 @@ from ovos_plugin_manager.templates.pipeline import IntentMatch from ovos_utils.log import LOG, deprecated, log_deprecation from ovos_utils.metrics import Stopwatch -from ovos_workshop.intents import open_intent_envelope from padacioso.opm import PadaciosoPipeline as PadaciosoService @@ -89,99 +90,100 @@ def __init__(self, bus, config=None): self.bus.on('intent.service.padatious.entities.manifest.get', self.handle_entity_manifest) @property - @deprecated("direct access to self.adapt_service is deprecated, " - "pipelines are in the progress of being replaced with plugins", "1.0.0") def adapt_service(self): + log_deprecation("direct access to self.adapt_service is deprecated, " + "pipelines are in the progress of being replaced with plugins", "1.0.0") return self._adapt_service @property - @deprecated("direct access to self.padatious_service is deprecated, " - "pipelines are in the progress of being replaced with plugins", "1.0.0") def padatious_service(self): + log_deprecation("direct access to self.padatious_service is deprecated, " + "pipelines are in the progress of being replaced with plugins", "1.0.0") return self._padatious_service @property - @deprecated("direct access to self.padacioso_service is deprecated, " - "pipelines are in the progress of being replaced with plugins", "1.0.0") def padacioso_service(self): + log_deprecation("direct access to self.padacioso_service is deprecated, " + "pipelines are in the progress of being replaced with plugins", "1.0.0") return self._padacioso_service @property - @deprecated("direct access to self.fallback is deprecated, " - "pipelines are in the progress of being replaced with plugins", "1.0.0") def fallback(self): + + log_deprecation("direct access to self.fallback is deprecated, " + "pipelines are in the progress of being replaced with plugins", "1.0.0") return self._fallback @property - @deprecated("direct access to self.converse is deprecated, " - "pipelines are in the progress of being replaced with plugins", "1.0.0") def converse(self): + log_deprecation("direct access to self.converse is deprecated, " + "pipelines are in the progress of being replaced with plugins", "1.0.0") return self._converse @property - @deprecated("direct access to self.common_qa is deprecated, " - "pipelines are in the progress of being replaced with plugins", "1.0.0") def common_qa(self): + log_deprecation("direct access to self.common_qa is deprecated, " + "pipelines are in the progress of being replaced with plugins", "1.0.0") return self._common_qa @property - @deprecated("direct access to self.stop is deprecated, " - "pipelines are in the progress of being replaced with plugins", "1.0.0") def stop(self): + log_deprecation("direct access to self.stop is deprecated, " + "pipelines are in the progress of being replaced with plugins", "1.0.0") return self._stop @property - @deprecated("direct access to self.ocp is deprecated, " - "pipelines are in the progress of being replaced with plugins", "1.0.0") def ocp(self): + log_deprecation("direct access to self.ocp is deprecated, " + "pipelines are in the progress of being replaced with plugins", "1.0.0") return self._ocp @adapt_service.setter - @deprecated("direct access to self.adapt_service is deprecated, " - "pipelines are in the progress of being replaced with plugins", "1.0.0") def adapt_service(self, value): + log_deprecation("direct access to self.adapt_service is deprecated, " + "pipelines are in the progress of being replaced with plugins", "1.0.0") self._adapt_service = value @padatious_service.setter - @deprecated("direct access to self.padatious_service is deprecated, " - "pipelines are in the progress of being replaced with plugins", "1.0.0") def padatious_service(self, value): + log_deprecation("direct access to self.padatious_service is deprecated, " + "pipelines are in the progress of being replaced with plugins", "1.0.0") self._padatious_service = value @padacioso_service.setter - @deprecated("direct access to self.padacioso_service is deprecated, " - "pipelines are in the progress of being replaced with plugins", "1.0.0") def padacioso_service(self, value): + log_deprecation("direct access to self.padacioso_service is deprecated, " + "pipelines are in the progress of being replaced with plugins", "1.0.0") self._padacioso_service = value @fallback.setter - @deprecated("direct access to self.fallback is deprecated, " - "pipelines are in the progress of being replaced with plugins", "1.0.0") def fallback(self, value): + log_deprecation("direct access to self.fallback is deprecated, " + "pipelines are in the progress of being replaced with plugins", "1.0.0") self._fallback = value @converse.setter - @deprecated("direct access to self.converse is deprecated, " - "pipelines are in the progress of being replaced with plugins", "1.0.0") def converse(self, value): + log_deprecation("direct access to self.converse is deprecated, " + "pipelines are in the progress of being replaced with plugins", "1.0.0") self._converse = value @common_qa.setter - @deprecated("direct access to self.common_qa is deprecated, " - "pipelines are in the progress of being replaced with plugins", "1.0.0") def common_qa(self, value): + log_deprecation("direct access to self.common_qa is deprecated, " + "pipelines are in the progress of being replaced with plugins", "1.0.0") self._common_qa = value @stop.setter - @deprecated("direct access to self.stop is deprecated, " - "pipelines are in the progress of being replaced with plugins", "1.0.0") def stop(self, value): + log_deprecation("direct access to self.stop is deprecated, " + "pipelines are in the progress of being replaced with plugins", "1.0.0") self._stop = value @ocp.setter - @deprecated("direct access to self.ocp is deprecated, " - "pipelines are in the progress of being replaced with plugins", "1.0.0") def ocp(self, value): + log_deprecation("direct access to self.ocp is deprecated, " + "pipelines are in the progress of being replaced with plugins", "1.0.0") self._ocp = value def _load_pipeline_plugins(self): @@ -454,7 +456,7 @@ def handle_utterance(self, message: Message): # tag language of this utterance lang = self.disambiguate_lang(message) - try: + try: # TODO - uncouple lingua franca from core, up to skills to ensure locale is loaded if needed setup_locale(lang) except Exception as e: LOG.exception(f"Failed to set lingua_franca default lang to {lang}") From c37b85658d98927995bcfa37ab8eefaaf5789aec Mon Sep 17 00:00:00 2001 From: miro Date: Tue, 15 Oct 2024 23:15:30 +0100 Subject: [PATCH 2/5] fix:log_spam --- ovos_core/intent_services/__init__.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ovos_core/intent_services/__init__.py b/ovos_core/intent_services/__init__.py index 67b11cc530f..f60d3f6870e 100644 --- a/ovos_core/intent_services/__init__.py +++ b/ovos_core/intent_services/__init__.py @@ -211,7 +211,7 @@ def _load_pipeline_plugins(self): def registered_intents(self): lang = get_message_lang() return [parser.__dict__ - for parser in self.adapt_service.engines[lang].intent_parsers] + for parser in self._adapt_service.engines[lang].intent_parsers] def update_skill_name_dict(self, message): """Messagebus handler, updates dict of id to skill name conversions.""" @@ -526,7 +526,7 @@ def handle_register_vocab(self, message): regex_str = message.data.get('regex') alias_of = message.data.get('alias_of') lang = get_message_lang(message) - self.adapt_service.register_vocabulary(entity_value, entity_type, + self._adapt_service.register_vocabulary(entity_value, entity_type, alias_of, regex_str, lang) self.registered_vocab.append(message.data) @@ -537,7 +537,7 @@ def handle_register_intent(self, message): message (Message): message containing intent info """ intent = open_intent_envelope(message) - self.adapt_service.register_intent(intent) + self._adapt_service.register_intent(intent) def handle_detach_intent(self, message): """Remover adapt intent. @@ -546,7 +546,7 @@ def handle_detach_intent(self, message): message (Message): message containing intent info """ intent_name = message.data.get('intent_name') - self.adapt_service.detach_intent(intent_name) + self._adapt_service.detach_intent(intent_name) def handle_detach_skill(self, message): """Remove all intents registered for a specific skill. @@ -555,7 +555,7 @@ def handle_detach_skill(self, message): message (Message): message containing intent info """ skill_id = message.data.get('skill_id') - self.adapt_service.detach_skill(skill_id) + self._adapt_service.detach_skill(skill_id) def handle_add_context(self, message): """Add context @@ -654,7 +654,7 @@ def handle_get_adapt(self, message: Message): """ utterance = message.data["utterance"] lang = get_message_lang(message) - intent = self.adapt_service.match_intent((utterance,), lang, message.serialize()) + intent = self._adapt_service.match_intent((utterance,), lang, message.serialize()) intent_data = intent.intent_data if intent else None self.bus.emit(message.reply("intent.service.adapt.reply", {"intent": intent_data})) @@ -716,7 +716,7 @@ def handle_entity_manifest(self, message): def shutdown(self): self.utterance_plugins.shutdown() self.metadata_plugins.shutdown() - self.adapt_service.shutdown() + self._adapt_service.shutdown() self.padacioso_service.shutdown() if self.padatious_service: self.padatious_service.shutdown() From 9e75e84b378460ad335aac2deadc099c7f65d050 Mon Sep 17 00:00:00 2001 From: miro Date: Tue, 15 Oct 2024 23:20:15 +0100 Subject: [PATCH 3/5] fix:log_spam --- ovos_core/intent_services/__init__.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ovos_core/intent_services/__init__.py b/ovos_core/intent_services/__init__.py index f60d3f6870e..7e51f9fbd44 100644 --- a/ovos_core/intent_services/__init__.py +++ b/ovos_core/intent_services/__init__.py @@ -717,14 +717,14 @@ def shutdown(self): self.utterance_plugins.shutdown() self.metadata_plugins.shutdown() self._adapt_service.shutdown() - self.padacioso_service.shutdown() - if self.padatious_service: - self.padatious_service.shutdown() - self.common_qa.shutdown() - self.converse.shutdown() - self.fallback.shutdown() - if self.ocp: - self.ocp.shutdown() + self._padacioso_service.shutdown() + if self._padatious_service: + self._padatious_service.shutdown() + self._common_qa.shutdown() + self._converse.shutdown() + self._fallback.shutdown() + if self._ocp: + self._ocp.shutdown() self.bus.remove('register_vocab', self.handle_register_vocab) self.bus.remove('register_intent', self.handle_register_intent) From 15d0420fa1f3091ad367c6a6ee438fcc4318989a Mon Sep 17 00:00:00 2001 From: miro Date: Tue, 15 Oct 2024 23:21:20 +0100 Subject: [PATCH 4/5] fix:log_spam --- ovos_core/skill_manager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ovos_core/skill_manager.py b/ovos_core/skill_manager.py index e1e2cfb2c78..b66f041aec8 100644 --- a/ovos_core/skill_manager.py +++ b/ovos_core/skill_manager.py @@ -29,7 +29,7 @@ from ovos_utils.file_utils import FileWatcher from ovos_utils.gui import is_gui_connected from ovos_utils.log import LOG, deprecated -from ovos_utils.network_utils import is_connected +from ovos_utils.network_utils import is_connected_http from ovos_utils.process_utils import ProcessStatus, StatusCallbackMap, ProcessState from ovos_workshop.skill_launcher import SKILL_MAIN_MODULE from ovos_workshop.skill_launcher import SkillLoader, PluginSkillLoader @@ -181,7 +181,7 @@ def _sync_skill_loading_state(self): network = True else: LOG.debug("ovos-phal-plugin-connectivity-events not detected, performing direct network checks") - network = internet = is_connected() + network = internet = is_connected_http() if internet and not self._connected_event.is_set(): LOG.debug("Notify internet connected") From 7219a13345df215bef4354e08d975f7d494700ed Mon Sep 17 00:00:00 2001 From: miro Date: Tue, 15 Oct 2024 23:24:12 +0100 Subject: [PATCH 5/5] fix:log_spam --- test/unittests/test_manager.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/unittests/test_manager.py b/test/unittests/test_manager.py index f9f55d43efc..4f67d073a56 100644 --- a/test/unittests/test_manager.py +++ b/test/unittests/test_manager.py @@ -49,7 +49,7 @@ def test_handle_gui_disconnected(self, mock_is_gui_connected): self.assertFalse(self.skill_manager._gui_event.is_set()) self.assertTrue(self.skill_manager._unload_on_gui_disconnect.called) - @patch('ovos_core.skill_manager.is_connected', return_value=True) + @patch('ovos_core.skill_manager.is_connected_http', return_value=True) def test_handle_internet_connected(self, mock_is_connected): self.skill_manager._connected_event.clear() self.skill_manager._network_event.clear() @@ -60,7 +60,7 @@ def test_handle_internet_connected(self, mock_is_connected): self.assertTrue(self.skill_manager._network_loaded.is_set()) self.assertTrue(self.skill_manager._load_on_internet.called) - @patch('ovos_core.skill_manager.is_connected', return_value=False) + @patch('ovos_core.skill_manager.is_connected_http', return_value=False) def test_handle_internet_disconnected(self, mock_is_connected): self.skill_manager._allow_state_reloads = True self.skill_manager._connected_event.set() @@ -70,7 +70,7 @@ def test_handle_internet_disconnected(self, mock_is_connected): self.assertFalse(self.skill_manager._connected_event.is_set()) self.assertTrue(self.skill_manager._unload_on_internet_disconnect.called) - @patch('ovos_core.skill_manager.is_connected', return_value=True) + @patch('ovos_core.skill_manager.is_connected_http', return_value=True) def test_handle_network_connected(self, mock_is_connected): self.skill_manager._network_event.clear() self.skill_manager._load_on_network = MagicMock() @@ -78,7 +78,7 @@ def test_handle_network_connected(self, mock_is_connected): self.assertTrue(self.skill_manager._network_event.is_set()) self.assertTrue(self.skill_manager._load_on_network.called) - @patch('ovos_core.skill_manager.is_connected', return_value=False) + @patch('ovos_core.skill_manager.is_connected_http', return_value=False) def test_handle_network_disconnected(self, mock_is_connected): self.skill_manager._allow_state_reloads = True self.skill_manager._network_event.set() @@ -88,7 +88,7 @@ def test_handle_network_disconnected(self, mock_is_connected): self.assertTrue(self.skill_manager._unload_on_network_disconnect.called) @patch('ovos_core.skill_manager.is_gui_connected', return_value=True) - @patch('ovos_core.skill_manager.is_connected', return_value=True) + @patch('ovos_core.skill_manager.is_connected_http', return_value=True) def test_sync_skill_loading_state_no_phal_plugin(self, mock_is_connected, mock_is_gui_connected): self.bus.wait_for_response.return_value = None