Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ovos_utils config update compat #218

Merged
merged 7 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 0 additions & 1 deletion neon_core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

from os.path import join, dirname
from ovos_utils.json_helper import merge_dict
from ovos_utils.system import set_root_path
from ovos_utils.xdg_utils import xdg_config_home

from neon_utils.logger import LOG
Expand Down
34 changes: 34 additions & 0 deletions neon_core/util/runtime_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# # NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System
# # All trademark and other rights reserved by their respective owners
# # Copyright 2008-2021 Neongecko.com Inc.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from this
# software without specific prior written permission.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


def use_neon_core(func):
"""
Wrapper to ensure call originates from neon_core for stack checks
NeonDaniel marked this conversation as resolved.
Show resolved Hide resolved
"""
def wrapper(*args, **kwargs):
return func(*args, **kwargs)
return wrapper

4 changes: 2 additions & 2 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
ovos-core[skills_lgpl]~=0.0.2a10

# utils
neon-utils~=0.12,>=0.15.1a7
ovos_utils~=0.0.18
neon-utils~=0.12,>=0.15.1a10
ovos_utils~=0.0.19,>=0.0.19a3
ovos-skills-manager~=0.0.10a20
ovos-plugin-manager~=0.0.4,>=0.0.7a0
# TODO: Update to stable versions
Expand Down
29 changes: 19 additions & 10 deletions test/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,31 @@
class ConfigurationTests(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
from ovos_config_assistant import config_helpers

from ovos_config_assistant.config_helpers import \
get_ovos_config, get_ovos_default_config_paths
ovos_config = os.path.expanduser("~/.config/OpenVoiceOS/ovos.conf")
if os.path.isfile(ovos_config):
os.remove(ovos_config)
assert config_helpers.get_ovos_default_config_paths() == []
assert get_ovos_default_config_paths() == []

import neon_core
from neon_core.util.runtime_utils import use_neon_core

assert isinstance(neon_core.CORE_VERSION_STR, str)
assert len(config_helpers.get_ovos_default_config_paths()) == 1
LOG.info(config_helpers.get_ovos_default_config_paths())
ovos_config = config_helpers.get_ovos_config()
assert len(use_neon_core(get_ovos_default_config_paths)()) == 1
LOG.info(use_neon_core(get_ovos_default_config_paths)())
ovos_config = use_neon_core(get_ovos_config)()
LOG.info(pformat(ovos_config))
assert ovos_config['config_filename'] == 'neon.conf'

def test_neon_core_config_init(self):
from neon_utils.configuration_utils import \
get_mycroft_compatible_config
from neon_core.configuration import Configuration
from neon_core.util.runtime_utils import use_neon_core

neon_compat_config = Configuration.get()
neon_config = get_mycroft_compatible_config()
neon_config = use_neon_core(get_mycroft_compatible_config)()
for key, val in neon_config.items():
if isinstance(val, dict):
for k, v in val.items():
Expand All @@ -69,8 +73,10 @@ def test_ovos_core_config_init(self):
from neon_utils.configuration_utils import \
get_mycroft_compatible_config
from mycroft.configuration import Configuration as MycroftConfig
from neon_core.util.runtime_utils import use_neon_core

mycroft_config = MycroftConfig.get()
neon_config = get_mycroft_compatible_config()
neon_config = use_neon_core(get_mycroft_compatible_config)()
JarbasAl marked this conversation as resolved.
Show resolved Hide resolved
for key, val in neon_config.items():
if isinstance(val, dict):
for k, v in val.items():
Expand All @@ -86,8 +92,11 @@ def test_signal_dir(self):
from ovos_utils.signal import get_ipc_directory as ovos_ipc_dir
from mycroft.util.signal import get_ipc_directory as mycroft_ipc_dir

self.assertEqual(neon_ipc_dir, ovos_ipc_dir())
self.assertEqual(neon_ipc_dir, mycroft_ipc_dir())
from neon_core.util.runtime_utils import use_neon_core

self.assertEqual(neon_ipc_dir, use_neon_core(ovos_ipc_dir)())
self.assertEqual(neon_ipc_dir,
use_neon_core(mycroft_ipc_dir)())


if __name__ == '__main__':
Expand Down