Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions neon_core/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from threading import Thread
from click_default_group import DefaultGroup
from neon_utils.packaging_utils import get_neon_core_version
from ovos_utils.log import deprecated

_DEFAULT_CONFIG_FILE = join(dirname(__file__), "configuration", "neon.yaml")
environ.setdefault("OVOS_CONFIG_BASE_FOLDER", "neon")
Expand All @@ -61,6 +62,10 @@ def neon_core_cli(version: bool = False):
click.echo(f"Neon version {get_neon_core_version()}")


@deprecated(
"start_neon is deprecated; use containers or start services individually",
"25.10.0",
)
@neon_core_cli.command(help="Start Neon Core")
def start_neon():
from neon_core.run_neon import start_neon
Expand All @@ -70,6 +75,10 @@ def start_neon():
click.echo("Neon Started")


@deprecated(
"stop_neon is deprecated; use containers or start services individually",
"25.10.0",
)
@neon_core_cli.command(help="Stop Neon Core")
def stop_neon():
from neon_core.run_neon import stop_neon
Expand Down
5 changes: 3 additions & 2 deletions neon_core/configuration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@
from ovos_config.config import Configuration
from os.path import exists, isdir, dirname
from os import makedirs
from ovos_utils.log import LOG
from ovos_utils.log import LOG, deprecated

"""
Neon modules should import config from this module since module_overrides will
result in different configurations depending on originating module.
"""


@deprecated("get_private_keys is deprecated without replacement", "25.10.0")
def get_private_keys():
return Configuration().get("keys", {})

Expand All @@ -61,4 +62,4 @@ def patch_config(config: dict = None):
local_config.store()
Configuration().reload()
import mycroft.configuration
mycroft.configuration.Configuration().reload()
mycroft.configuration.Configuration().reload()
7 changes: 3 additions & 4 deletions neon_core/language/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@

import os

from ovos_plugin_manager.language import OVOSLangDetectionFactory as DetectorFactory
from ovos_plugin_manager.language import OVOSLangTranslationFactory as TranslatorFactory

from neon_core.configuration import Configuration
from ovos_utils.log import deprecated
from ovos_config.config import Configuration


def get_lang_config():
Expand All @@ -44,6 +42,7 @@ def get_lang_config():
return lang_config


@deprecated("get_language_dir is deprecated without replacement", "25.10.0")
def get_language_dir(base_path, lang="en-us"):
""" checks for all language variations and returns best path """
lang_path = os.path.join(base_path, lang)
Expand Down
3 changes: 3 additions & 0 deletions neon_core/run_neon.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
from ovos_utils.gui import is_gui_running
from neon_utils.log_utils import remove_old_logs, archive_logs, LOG, \
get_log_file_for_module
from ovos_utils.log import log_deprecation

log_deprecation("This script is deprecated. Recommended method is to use containers", "25.10.0")

LOG_FILES = {}
PROCESSES = {}
Expand Down
97 changes: 1 addition & 96 deletions test/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@
import os
import shutil
import unittest
import yaml

from copy import deepcopy
# from pprint import pformat
# from ovos_utils.log import LOG


class ConfigurationTests(unittest.TestCase):
Expand All @@ -44,106 +39,16 @@ def setUpClass(cls) -> None:
os.environ["XDG_CONFIG_HOME"] = cls.CONFIG_PATH
os.environ["OVOS_CONFIG_BASE_FOLDER"] = "neon"
os.environ["OVOS_CONFIG_FILENAME"] = "neon.yaml"
# from neon_core.util.runtime_utils import use_neon_core
# from neon_utils.configuration_utils import init_config_dir
# use_neon_core(init_config_dir)()

# import neon_core
# assert isinstance(neon_core.CORE_VERSION_STR, str)
# assert os.path.isfile(os.path.join(cls.CONFIG_PATH,
# "OpenVoiceOS", "ovos.conf"))

# from ovos_config.meta import get_ovos_config
# from neon_core.configuration import Configuration
# ovos_config = use_neon_core(get_ovos_config)()
# LOG.info(pformat(ovos_config))
# assert ovos_config['config_filename'] == 'neon.yaml'
# assert os.path.basename(ovos_config['default_config_path']) == "neon.yaml"
# assert Configuration.default.path == ovos_config['default_config_path']

@classmethod
def tearDownClass(cls) -> None:
if os.path.exists(cls.CONFIG_PATH):
shutil.rmtree(cls.CONFIG_PATH)
os.environ.pop("XDG_CONFIG_HOME")
# os.environ.pop("OVOS_CONFIG_BASE_FOLDER")
# os.environ.pop("OVOS_CONFIG_FILENAME")

@unittest.skip("mycroft.configuration is deprecated")
def test_neon_core_config_init(self):
from neon_core.configuration import Configuration
from mycroft.configuration import Configuration as MycroftConfig
from neon_core.util.runtime_utils import use_neon_core

configuration = Configuration()
self.assertEqual(os.path.basename(Configuration.default.path),
"neon.yaml")
self.assertIsInstance(configuration, dict)
self.assertEqual(configuration, use_neon_core(MycroftConfig)())

from ovos_config.config import read_mycroft_config
self.assertEqual(configuration, use_neon_core(read_mycroft_config)())

@unittest.skip("mycroft.configuration is deprecated")
def test_patch_config(self):
test_config_dir = os.path.join(os.path.dirname(__file__), "config")
os.makedirs(test_config_dir, exist_ok=True)
os.environ["XDG_CONFIG_HOME"] = test_config_dir

from neon_core.util.runtime_utils import use_neon_core
from neon_utils.configuration_utils import init_config_dir
use_neon_core(init_config_dir)()
from mycroft.configuration import Configuration
from mycroft.configuration.locations import DEFAULT_CONFIG
self.assertTrue(DEFAULT_CONFIG.endswith("neon.yaml"))
self.assertTrue(Configuration.default.path == DEFAULT_CONFIG,
Configuration.default.path)
# with open(join(test_config_dir, "OpenVoiceOS", 'ovos.conf')) as f:
# ovos_conf = json.load(f)
# self.assertEqual(ovos_conf['submodule_mappings']['neon_core'],
# "neon_core")
# self.assertIsInstance(ovos_conf['module_overrides']['neon_core'], dict)

from neon_core.configuration import patch_config
test_config = {"new_key": {'val': True}}
patch_config(test_config)
self.assertEqual(Configuration(), use_neon_core(Configuration)())
conf_file = os.path.join(test_config_dir, 'neon',
'neon.yaml')
self.assertTrue(os.path.isfile(conf_file))
with open(conf_file) as f:
config = yaml.safe_load(f)
for k in config:
if isinstance(k, dict):
for s in k:
self.assertEqual(config[k][s], Configuration()[k][s],
Configuration()[k][s])
else:
self.assertEqual(config[k], Configuration()[k],
Configuration()[k])

self.assertTrue(config['new_key']['val'])

test_config = deepcopy(config)
test_config["new_key"]["val"] = False
test_config['skills'] = \
{'auto_update': not Configuration()['skills']['auto_update']}
valid_val = test_config['skills']['auto_update']
self.assertNotEqual(config, test_config)
patch_config(test_config)
conf_file = os.path.join(test_config_dir, 'neon',
'neon.yaml')
with open(conf_file) as f:
config = yaml.safe_load(f)
self.assertEqual(config, test_config)
self.assertEqual(config['skills']['auto_update'], valid_val)
self.assertFalse(config['new_key']['val'])
self.assertEqual(config['skills']['auto_update'],
Configuration()['skills']['auto_update'])

shutil.rmtree(test_config_dir)
# os.environ.pop("XDG_CONFIG_HOME")

# TODO

if __name__ == '__main__':
unittest.main()
17 changes: 0 additions & 17 deletions test/test_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,5 @@ def test_get_language_dir_invalid(self):
self.assertEqual(get_language_dir(base_dir, "ru-ru"),
os.path.join(base_dir, "ru-ru"))

def test_translator(self):
from neon_core.language import TranslatorFactory
translator = TranslatorFactory.create(
{"translation_module": "libretranslate_plug"})
self.assertIsInstance(translator, LanguageTranslator)
output = translator.translate("hello", "es-es", "en-us")
self.assertEqual(output.lower(), "hola")

def test_detector(self):
from neon_core.language import DetectorFactory
detector = DetectorFactory.create(
{"detection_module": "libretranslate_detection_plug"})
self.assertIsInstance(detector, LanguageDetector)
lang = detector.detect("hello")
self.assertEqual(lang, "en")


if __name__ == '__main__':
unittest.main()
106 changes: 0 additions & 106 deletions test/test_run_modules.py

This file was deleted.

2 changes: 1 addition & 1 deletion test/test_run_neon.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def test_speech_module(self):
i = 0
response = self.bus.wait_for_response(Message('mycroft.voice.is_ready'))
while not response.data['status'] and i < 10:
LOG.warning(f"Speech not ready when core reported ready!")
LOG.warning("Speech not ready when core reported ready!")
sleep(5)
response = self.bus.wait_for_response(Message('mycroft.voice.is_ready'))
i += 1
Expand Down
Loading