Skip to content

Commit

Permalink
fix:log_spam (#566)
Browse files Browse the repository at this point in the history
* fix:log_spam

* fix:log_spam

* fix:log_spam

* fix:log_spam

* fix:log_spam
  • Loading branch information
JarbasAl authored Oct 15, 2024
1 parent 21ba8de commit f956666
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 58 deletions.
104 changes: 53 additions & 51 deletions ovos_core/intent_services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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


Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -209,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."""
Expand Down Expand Up @@ -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}")
Expand Down Expand Up @@ -524,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)

Expand All @@ -535,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.
Expand All @@ -544,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.
Expand All @@ -553,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
Expand Down Expand Up @@ -652,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}))
Expand Down Expand Up @@ -714,15 +716,15 @@ def handle_entity_manifest(self, message):
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._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.bus.remove('register_vocab', self.handle_register_vocab)
self.bus.remove('register_intent', self.handle_register_intent)
Expand Down
4 changes: 2 additions & 2 deletions ovos_core/skill_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
10 changes: 5 additions & 5 deletions test/unittests/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -70,15 +70,15 @@ 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()
self.skill_manager.handle_network_connected(Message(""))
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()
Expand All @@ -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

Expand Down

0 comments on commit f956666

Please sign in to comment.