Skip to content

Commit

Permalink
Update to resolve logged deprecation warnings (#719)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel McKnight <daniel@neon.ai>
  • Loading branch information
NeonDaniel and NeonDaniel authored Sep 21, 2024
1 parent 90847d6 commit 1c19a67
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 57 deletions.
5 changes: 4 additions & 1 deletion docker_overlay/etc/neon/neon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,7 @@ play_wav_cmdline: "play %1"
play_mp3_cmdline: "play %1"
play_ogg_cmdline: "play %1"
ready_settings:
- skills
- skills
signal:
use_signal_files: false
patch_imports: false
1 change: 1 addition & 0 deletions neon_core/configuration/mark_2/neon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ gui:
homescreen_supported: true
signal:
use_signal_files: false
patch_imports: false
skills:
common_query:
extension_time: 5
Expand Down
2 changes: 1 addition & 1 deletion neon_core/configuration/neon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ MQ:
hana:
url: "https://hana.neonaiservices.com"
signal:
use_signal_files: true
use_signal_files: false
max_wait_seconds: 300

# Logging Config
Expand Down
11 changes: 7 additions & 4 deletions neon_core/util/diagnostic_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@
from os.path import join, isfile, basename, splitext
from json_database import xdg_data_home, xdg_config_home

from neon_utils import LOG
from neon_utils.metrics_utils import report_metric
from ovos_utils.log import LOG
from neon_utils.configuration_utils import NGIConfig

from ovos_bus_client.message import Message
from ovos_bus_client.util import get_mycroft_bus
from ovos_config.config import Configuration


Expand Down Expand Up @@ -111,10 +112,12 @@ def send_diagnostics(allow_logs=True, allow_transcripts=True, allow_config=True)
# else:
transcripts = None

data = {"host": socket.gethostname(),
data = {"name": "diagnostics",
"host": socket.gethostname(),
"startup": startup_text,
"configurations": json.dumps(configs) if configs else None,
"logs": json.dumps(logs) if logs else None,
"transcripts": transcripts}
report_metric("diagnostics", **data)
bus = get_mycroft_bus()
bus.emit(Message("neon.metric", data=data))
return data
2 changes: 1 addition & 1 deletion requirements/core_modules.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# neon core modules
neon-messagebus~=2.0,>=2.0.2a7
neon-enclosure~=1.7,>=1.7.1a4
neon-enclosure~=1.7,>=1.7.1a5
neon-speech~=4.4,>=4.4.2a4
neon-gui~=1.3,>=1.3.1a3
neon-audio~=1.5,>=1.5.2a10
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
ovos-core[lgpl]~=0.0.8
# padacioso==0.1.3a2

neon-utils[network,audio]~=1.11,>=1.11.1a3
neon-utils[network,audio]~=1.11,>=1.11.1a4
# TODO: `audio` extra for dependency resolution
ovos-utils~=0.0,>=0.0.38
ovos-bus-client~=0.0,>=0.0.10
Expand Down
100 changes: 51 additions & 49 deletions test/test_diagnostic_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
import shutil
import sys
import unittest
from unittest.mock import patch

from ovos_utils.fakebus import FakeBus

import neon_utils.metrics_utils

from mock import Mock
Expand All @@ -41,6 +45,7 @@
class DiagnosticUtilsTests(unittest.TestCase):
config_dir = os.path.join(os.path.dirname(__file__), "test_config")
report_metric = Mock()
bus = FakeBus()

@classmethod
def setUpClass(cls) -> None:
Expand All @@ -52,6 +57,8 @@ def setUpClass(cls) -> None:
from neon_core.configuration import patch_config
patch_config({"log_dir": test_dir})

cls.bus.on("neon.metric", cls.report_metric)

@classmethod
def tearDownClass(cls) -> None:
if os.getenv("NEON_CONFIG_PATH"):
Expand All @@ -62,70 +69,65 @@ def setUp(self) -> None:
self.report_metric.reset_mock()
neon_utils.metrics_utils.report_metric = self.report_metric

def test_send_diagnostics_default(self):
@patch("ovos_bus_client.util.get_mycroft_bus")
def test_send_diagnostics_default(self, get_bus):
get_bus.return_value = self.bus
from neon_core.util.diagnostic_utils import send_diagnostics
send_diagnostics()
self.report_metric.assert_called_once()
args = self.report_metric.call_args
self.assertEqual(args.args, ("diagnostics",))
data = args.kwargs
self.assertIsInstance(data, dict)
self.assertIsInstance(data["host"], str)
self.assertIsInstance(data["configurations"], str)
self.assertIsInstance(data["logs"], str)
# self.assertIsInstance(data["transcripts"], str)

def test_send_diagnostics_no_extras(self):
message = self.report_metric.call_args[0][0]
self.assertEqual(message.data['name'], 'diagnostics')
self.assertEqual(set(message.data.keys()),
{"name", "host", "startup", "configurations", "logs",
"transcripts"})

@patch("ovos_bus_client.util.get_mycroft_bus")
def test_send_diagnostics_no_extras(self, get_bus):
get_bus.return_value = self.bus
from neon_core.util.diagnostic_utils import send_diagnostics
send_diagnostics(False, False, False)
self.report_metric.assert_called_once()
args = self.report_metric.call_args
self.assertEqual(args.args, ("diagnostics",))
data = args.kwargs
self.assertIsInstance(data, dict)
self.assertIsInstance(data["host"], str)
self.assertIsNone(data["configurations"])
self.assertIsNone(data["logs"])
self.assertIsNone(data["transcripts"])

def test_send_diagnostics_allow_logs(self):
message = self.report_metric.call_args[0][0]
self.assertEqual(message.data['name'], 'diagnostics')
self.assertEqual(set(message.data.keys()),
{"name", "host", "startup", "configurations", "logs",
"transcripts"})

@patch("ovos_bus_client.util.get_mycroft_bus")
def test_send_diagnostics_allow_logs(self, get_bus):
get_bus.return_value = self.bus
from neon_core.util.diagnostic_utils import send_diagnostics
send_diagnostics(True, False, False)
self.report_metric.assert_called_once()
args = self.report_metric.call_args
self.assertEqual(args.args, ("diagnostics",))
data = args.kwargs
self.assertIsInstance(data, dict)
self.assertIsInstance(data["host"], str)
self.assertIsNone(data["configurations"])
self.assertIsInstance(data["logs"], str)
self.assertIsNone(data["transcripts"])

def test_send_diagnostics_allow_transcripts(self):
message = self.report_metric.call_args[0][0]
self.assertEqual(message.data['name'], 'diagnostics')
self.assertEqual(set(message.data.keys()),
{"name", "host", "startup", "configurations", "logs",
"transcripts"})

@patch("ovos_bus_client.util.get_mycroft_bus")
def test_send_diagnostics_allow_transcripts(self, get_bus):
get_bus.return_value = self.bus
from neon_core.util.diagnostic_utils import send_diagnostics
send_diagnostics(False, True, False)
self.report_metric.assert_called_once()
args = self.report_metric.call_args
self.assertEqual(args.args, ("diagnostics",))
data = args.kwargs
self.assertIsInstance(data, dict)
self.assertIsInstance(data["host"], str)
self.assertIsNone(data["configurations"])
self.assertIsNone(data["logs"])
# self.assertIsInstance(data["transcripts"], str)

def test_send_diagnostics_allow_config(self):
message = self.report_metric.call_args[0][0]
self.assertEqual(message.data['name'], 'diagnostics')
self.assertEqual(set(message.data.keys()),
{"name", "host", "startup", "configurations", "logs",
"transcripts"})

@patch("ovos_bus_client.util.get_mycroft_bus")
def test_send_diagnostics_allow_config(self, get_bus):
get_bus.return_value = self.bus
from neon_core.util.diagnostic_utils import send_diagnostics
send_diagnostics(False, False, True)
self.report_metric.assert_called_once()
args = self.report_metric.call_args
self.assertEqual(args.args, ("diagnostics",))
data = args.kwargs
self.assertIsInstance(data, dict)
self.assertIsInstance(data["host"], str)
self.assertIsInstance(data["configurations"], str)
self.assertIsNone(data["logs"])
self.assertIsNone(data["transcripts"])
message = self.report_metric.call_args[0][0]
self.assertEqual(message.data['name'], 'diagnostics')
self.assertEqual(set(message.data.keys()),
{"name", "host", "startup", "configurations", "logs",
"transcripts"})


if __name__ == '__main__':
Expand Down

0 comments on commit 1c19a67

Please sign in to comment.