From 6111fe954d419df87b5d5f3cba6f49eb53c8787b Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Thu, 30 May 2024 18:41:16 -0700 Subject: [PATCH 1/6] Remove deprecated `add_event` override method --- neon_utils/skills/neon_fallback_skill.py | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/neon_utils/skills/neon_fallback_skill.py b/neon_utils/skills/neon_fallback_skill.py index 516857e8..6becaed8 100644 --- a/neon_utils/skills/neon_fallback_skill.py +++ b/neon_utils/skills/neon_fallback_skill.py @@ -875,23 +875,3 @@ def init_dialog(self, root_directory: Optional[str] = None): """ log_deprecation("Use `load_dialog_files`", "2.0.0") self.load_dialog_files(root_directory) - - def add_event(self, name: str, handler: callable, - handler_info: Optional[str] = None, once: bool = False, - speak_errors: bool = True): - # TODO: Remove with ovos-workshop==0.0.13 - try: - # Patching FakeBus compat. with MessageBusClient - if hasattr(self.bus, "ee"): - emitter = self.bus.ee - else: - emitter = self.bus.emitter - if handler_info == "mycroft.skill.handler" and \ - emitter.listeners(name): - LOG.warning(f"Not re-registering intent handler {name}") - return - except Exception as e: - LOG.exception(e) - OVOSSkill.add_event(self, name, handler, handler_info, once, - speak_errors) - From 6ed0eedaca0afef3d92e8f3e60e875b59b511d00 Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Thu, 30 May 2024 18:51:31 -0700 Subject: [PATCH 2/6] Troubleshooting test failures --- neon_utils/skills/kiosk_skill.py | 6 ++---- tests/net_util_tests.py | 10 ++++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/neon_utils/skills/kiosk_skill.py b/neon_utils/skills/kiosk_skill.py index ac8b9793..16247556 100644 --- a/neon_utils/skills/kiosk_skill.py +++ b/neon_utils/skills/kiosk_skill.py @@ -198,8 +198,7 @@ def stop(self): if user in self._active_users: self.end_interaction(message) - def _on_event_error(self, error, message, handler_info, - skill_data, speak_errors): + def _on_event_error(self, error, message, *args, **kwargs): """ Override error handling to speak custom exception for active sessions """ @@ -208,5 +207,4 @@ def _on_event_error(self, error, message, handler_info, LOG.exception(error) self.handle_error(message) else: - super()._on_event_error(error, message, handler_info, - skill_data, speak_errors) + super()._on_event_error(error, message, *args, **kwargs) diff --git a/tests/net_util_tests.py b/tests/net_util_tests.py index 3f6c0048..9be1faa7 100644 --- a/tests/net_util_tests.py +++ b/tests/net_util_tests.py @@ -33,6 +33,8 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) +TCP_TEST = "mq.neonaiservices.com" + class NetUtilTests(unittest.TestCase): @classmethod @@ -119,18 +121,18 @@ def mock_socket(*args, **kwargs): def test_check_url_connection_invalid_url(self): from neon_utils.net_utils import check_url_response - self.assertFalse(check_url_response("https://api.neon.ai")) + self.assertFalse(check_url_response(f"https://{TCP_TEST}")) def test_check_online_valid_online(self): from neon_utils.net_utils import check_online self.assertTrue(check_online()) self.assertTrue(check_online(("google.com", "github.com"))) - self.assertTrue(check_online(("api.neon.ai", "google.com"))) + self.assertTrue(check_online((TCP_TEST, "google.com"))) self.assertTrue(check_online(("", "google.com"))) def test_check_online_invalid_offline(self): from neon_utils.net_utils import check_online - self.assertFalse(check_online(("api.neon.ai",))) + self.assertFalse(check_online((TCP_TEST,))) self.assertFalse(check_online(("",))) def test_check_online_valid_offline(self): @@ -152,7 +154,7 @@ def test_check_online_invalid_params(self): def test_check_port_is_open(self): from neon_utils.net_utils import check_port_is_open - self.assertTrue(check_port_is_open("api.neon.ai", 5672)) + self.assertTrue(check_port_is_open(TCP_TEST, 5672)) self.assertFalse(check_port_is_open("www.neon.ai", 5672)) From 9dfa7fa196ac91753603d76aed1011f3e53a81a5 Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Thu, 30 May 2024 19:28:22 -0700 Subject: [PATCH 3/6] Update default MQ config --- neon_utils/mq_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neon_utils/mq_utils.py b/neon_utils/mq_utils.py index 08163eb5..a598d74f 100644 --- a/neon_utils/mq_utils.py +++ b/neon_utils/mq_utils.py @@ -49,7 +49,7 @@ logging.getLogger("pika").setLevel(logging.CRITICAL) _default_mq_config = { - "server": "api.neon.ai", + "server": "mq.neonaiservices.com", "port": 5672, "users": { "mq_handler": { From d24db79c74a3d2edf2faedbf9112d67e4fac228a Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Fri, 31 May 2024 09:51:37 -0700 Subject: [PATCH 4/6] Retry backend request on 502 return --- neon_utils/hana_utils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/neon_utils/hana_utils.py b/neon_utils/hana_utils.py index 3ed0204f..e113c8b8 100644 --- a/neon_utils/hana_utils.py +++ b/neon_utils/hana_utils.py @@ -162,9 +162,14 @@ def request_backend(endpoint: str, request_data: dict, except ServerException as e: LOG.error(e) _get_token(server_url) - resp = requests.post(f"{server_url}/{endpoint.lstrip('/')}", - json=request_data, headers=_headers) + request_kwargs = {"url": f"{server_url}/{endpoint.lstrip('/')}", + "json": request_data, "headers": _headers} + resp = requests.post(**request_kwargs) + if resp.status_code == 502: + # This is raised occasionally on valid requests. Need to resolve in HANA + resp = requests.post(**request_kwargs) if resp.ok: return resp.json() + else: raise ServerException(f"Error response {resp.status_code}: {resp.text}") From 7ab44dae13af61fa580a04aa5b3d8cfcd5d3c7d9 Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Fri, 31 May 2024 10:07:19 -0700 Subject: [PATCH 5/6] Troubleshoot new test failure --- requirements/requirements.txt | 3 ++- tests/neon_skill_tests.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 69d4432c..206f0a87 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -8,4 +8,5 @@ ovos-lingua-franca~=0.4 ovos_utils~=0.0,>=0.0.35 geopy~=2.1 ovos-config~=0.0.9 -ovos-workshop~=0.0.15 \ No newline at end of file +#ovos-workshop~=0.0.15 +ovos-workshop @ git+https://github.com/openvoiceos/ovos-workshop@FIX_MycroftSkillCompat \ No newline at end of file diff --git a/tests/neon_skill_tests.py b/tests/neon_skill_tests.py index a2c48f3b..514132ab 100644 --- a/tests/neon_skill_tests.py +++ b/tests/neon_skill_tests.py @@ -759,7 +759,7 @@ def is_valid(_): test_results["validator"] = True return False - on_fail = Mock() + on_fail = Mock(return_value="fail") def skill_response_thread(s: MycroftSkill, idx: str): resp = s.get_response(test_dialog, validator=is_valid, From 522283e8744d173db8036afe49e21daf9ac45e80 Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Fri, 31 May 2024 11:34:11 -0700 Subject: [PATCH 6/6] Remove ovos-workshop git spec --- requirements/requirements.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 206f0a87..69d4432c 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -8,5 +8,4 @@ ovos-lingua-franca~=0.4 ovos_utils~=0.0,>=0.0.35 geopy~=2.1 ovos-config~=0.0.9 -#ovos-workshop~=0.0.15 -ovos-workshop @ git+https://github.com/openvoiceos/ovos-workshop@FIX_MycroftSkillCompat \ No newline at end of file +ovos-workshop~=0.0.15 \ No newline at end of file