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

Update tests for neon-utils and GHA compat. #710

Merged
merged 13 commits into from
Sep 13, 2024
20 changes: 10 additions & 10 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ jobs:
env:
GITHUB_TOKEN: ${{secrets.neon_token}}
- name: Upload Skill Utils test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: skill-utils-test-results
name: skill-utils-test-results-${{ matrix.python-version }}
path: tests/skill-utils-test-results.xml

- name: Test Diagnostic Utils
Expand All @@ -52,9 +52,9 @@ jobs:
env:
GITHUB_TOKEN: ${{secrets.neon_token}}
- name: Upload Diagnostic Utils test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: diagnostic-utils-test-results
name: diagnostic-utils-test-results-${{ matrix.python-version }}
path: tests/diagnostic-utils-test-results.xml

unit_tests:
Expand Down Expand Up @@ -82,25 +82,25 @@ jobs:
run: |
pytest test/test_configuration.py --doctest-modules --junitxml=tests/configuration-test-results.xml
- name: Upload Configuration test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: configuration-test-results
name: configuration-test-results-${{ matrix.python-version }}
path: tests/configuration-test-results.xml

- name: Test Language
run: |
pytest test/test_language.py --doctest-modules --junitxml=tests/language-test-results.xml
- name: Upload Language test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: language-test-results
name: language-test-results-${{ matrix.python-version }}
path: tests/language-test-results.xml

- name: Test Skills Module
run: |
pytest test/test_skills_module.py --doctest-modules --junitxml=tests/skills-module-test-results.xml
- name: Upload Language test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: skills-module-test-results
name: skills-module-test-results-${{ matrix.python-version }}
path: tests/skills-module-test-results.xml
6 changes: 6 additions & 0 deletions neon_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,9 @@
# 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.

from os import environ
from os.path import join, dirname

environ["OVOS_DEFAULT_CONFIG"] = join(dirname(__file__),
"configuration", "neon.yaml")
5 changes: 5 additions & 0 deletions neon_core/util/runtime_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from ovos_utils.log import deprecated


@deprecated("ovos.conf meta configuration is deprecated. Use envvars "
"`OVOS_CONFIG_FILENAME`, `OVOS_CONFIG_BASE_FOLDER`, and "
"`OVOS_DEFAULT_CONFIG`.", "24.11.0")
def use_neon_core(func):
"""
Wrapper to ensure call originates from neon_core for stack checks.
Expand Down
4 changes: 2 additions & 2 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
ovos-core[mycroft,lgpl]>=0.0.8a95
# padacioso==0.1.3a2

neon-utils[network,audio]~=1.11,>=1.11.1a1
neon-utils[network,audio]~=1.11,>=1.11.1a3
# TODO: `audio` extra for dependency resolution
ovos-utils~=0.0,>=0.0.38
ovos-bus-client~=0.0.8,>=0.0.9a25
neon-transformers~=0.2,>=0.2.1a4
ovos-config~=0.0.12
ovos-config~=0.0.12,>=0.0.13a27
ovos-plugin-manager~=0.0.25,>=0.0.26a19
# TODO: ovos-backend-client pinned for stable release
ovos-backend-client==0.1.1a5
Expand Down
42 changes: 21 additions & 21 deletions test/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import yaml

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


class ConfigurationTests(unittest.TestCase):
Expand All @@ -42,24 +42,24 @@ class ConfigurationTests(unittest.TestCase):
@classmethod
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)()
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"))
# 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']
# 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:
Expand Down Expand Up @@ -100,11 +100,11 @@ def test_patch_config(self):
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)
# 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}}
Expand Down
34 changes: 27 additions & 7 deletions test/test_skills_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,13 @@ class TestSkillService(unittest.TestCase):

@classmethod
def setUpClass(cls) -> None:
from neon_core.util.runtime_utils import use_neon_core
from neon_utils.configuration_utils import init_config_dir
# from neon_core.util.runtime_utils import use_neon_core
# from neon_utils.configuration_utils import init_config_dir
os.environ["XDG_CONFIG_HOME"] = cls.config_dir
use_neon_core(init_config_dir)()
assert os.path.isdir(cls.config_dir)
os.environ["OVOS_CONFIG_BASE_FOLDER"] = "neon"
os.environ["OVOS_CONFIG_FILENAME"] = "neon.yaml"
# use_neon_core(init_config_dir)()
# assert os.path.isdir(cls.config_dir)

@classmethod
def tearDownClass(cls) -> None:
Expand Down Expand Up @@ -184,19 +186,34 @@ class TestIntentService(unittest.TestCase):

@classmethod
def setUpClass(cls) -> None:
from neon_core.util.runtime_utils import use_neon_core
from neon_utils.configuration_utils import init_config_dir
# from neon_core.util.runtime_utils import use_neon_core
# from neon_utils.configuration_utils import init_config_dir

# Import to set default config path
import neon_core

os.environ["XDG_CONFIG_HOME"] = cls.test_config_dir
os.environ["OVOS_CONFIG_BASE_FOLDER"] = "neon"
os.environ["OVOS_CONFIG_FILENAME"] = "neon.yaml"
use_neon_core(init_config_dir)()
# use_neon_core(init_config_dir)()
import ovos_config
import importlib
importlib.reload(ovos_config.meta)
meta = ovos_config.meta.get_ovos_config()
assert meta['default_config_path'].endswith('neon.yaml')
importlib.reload(ovos_config.locations)
assert ovos_config.locations.DEFAULT_CONFIG == meta['default_config_path']
import ovos_config.models
importlib.reload(ovos_config.models)
importlib.reload(ovos_config.config)
importlib.reload(ovos_config)
assert ovos_config.config.Configuration.default.path == meta['default_config_path']

from neon_core.skills.intent_service import NeonIntentService
cls.intent_service = NeonIntentService(cls.bus)
assert set(cls.intent_service.config['utterance_transformers'].keys()) \
== {"neon_utterance_translator_plugin",
"neon_utterance_normalizer_plugin"}

@classmethod
def tearDownClass(cls) -> None:
Expand Down Expand Up @@ -305,6 +322,9 @@ def _handle_languages_response(msg):

# Patch things
real_config = self.intent_service.language_config
self.assertIn("neon_utterance_translator_plugin",
self.intent_service.transformers.loaded_modules,
self.intent_service.transformers.loaded_modules)
translator = self.intent_service.transformers.loaded_modules.get(
'neon_utterance_translator_plugin')
real_plug = translator.translator
Expand Down
Loading