Skip to content

Commit

Permalink
Update CLI configuration handling and unit tests (#178)
Browse files Browse the repository at this point in the history
# Description
Update cli module to set default envvars
Remove references to deprecated `init_config_dir` function
Update Python versions used in unit tests
Update license notices for 2025
Patch `lang` handling for backwards-compat.

# Issues
<!-- If this is related to or closes an issue/other PR, please note them
here -->

# Other Notes
<!-- Note any breaking changes, WIP changes, requests for input, etc.
here -->
  • Loading branch information
NeonDaniel authored Feb 7, 2025
1 parent 4267fa2 commit 8d17328
Show file tree
Hide file tree
Showing 18 changed files with 33 additions and 30 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/license_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@ on:
- master
jobs:
license_tests:
uses: neongeckocom/.github/.github/workflows/license_tests.yml@master
with:
packages-exclude: '^(precise-runner|fann2|tqdm|bs4|ovos-phal-plugin|ovos-ocp|bitstruct|audioread).*'
uses: neongeckocom/.github/.github/workflows/license_tests.yml@master
6 changes: 3 additions & 3 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ jobs:
timeout-minutes: 15
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, '3.10']
python-version: [3.9, '3.10', '3.11']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 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.
# Copyright 2008-2025 Neongecko.com Inc.
# BSD-3 License

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
Expand Down
2 changes: 1 addition & 1 deletion docker_overlay/root/run.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Copyright 2008-2025 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
Expand Down
2 changes: 1 addition & 1 deletion neon_audio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Copyright 2008-2025 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
Expand Down
2 changes: 1 addition & 1 deletion neon_audio/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Copyright 2008-2025 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
Expand Down
10 changes: 6 additions & 4 deletions neon_audio/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Copyright 2008-2025 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
Expand Down Expand Up @@ -28,14 +28,17 @@

import click
import sys
from typing import List

from os import environ
from typing import List
from click_default_group import DefaultGroup
from neon_utils.packaging_utils import get_package_version_spec
from neon_utils.configuration_utils import init_config_dir
from ovos_config.config import Configuration
from ovos_utils.log import LOG, log_deprecation

environ.setdefault("OVOS_CONFIG_BASE_FOLDER", "neon")
environ.setdefault("OVOS_CONFIG_FILENAME", "neon.yaml")


@click.group("neon-audio", cls=DefaultGroup,
no_args_is_help=True, invoke_without_command=True,
Expand All @@ -56,7 +59,6 @@ def neon_audio_cli(version: bool = False):
@click.option("--force-install", "-f", default=False, is_flag=True,
help="Force pip installation of configured module")
def run(module, package, force_install):
init_config_dir()
from neon_audio.__main__ import main
if force_install or module or package:
install_plugin(module, package, force_install)
Expand Down
2 changes: 1 addition & 1 deletion neon_audio/service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Copyright 2008-2025 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
Expand Down
2 changes: 1 addition & 1 deletion neon_audio/tts/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Copyright 2008-2025 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
Expand Down
10 changes: 7 additions & 3 deletions neon_audio/tts/neon.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Copyright 2008-2025 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
Expand Down Expand Up @@ -210,6 +210,7 @@ def __new__(cls, base_engine, *args, **kwargs):
# TODO: Below method is only to bridge compatibility
base_engine._get_tts = cls._get_tts
base_engine._init_playback = cls._init_playback
base_engine.lang = cls.lang
return cls._init_neon(base_engine, *args, **kwargs)

@staticmethod
Expand All @@ -223,8 +224,6 @@ def _init_neon(base_engine, *args, **kwargs):
base_engine.keys = {}

base_engine.language_config = language_config
base_engine.lang = base_engine.lang or language_config.get("user",
"en-us")
try:
if language_config.get('detection_module'):
# Prevent loading a detector if not configured
Expand All @@ -247,6 +246,11 @@ def _init_neon(base_engine, *args, **kwargs):

return base_engine

@property
def lang(self):
# Patch breaking change in OVOS that normalizes en-US instead of en-us
return TTS.lang.fget(self).lower()

def _init_playback(self, playback_thread: NeonPlaybackThread = None):
# shutdown any previous thread
if TTS.playback:
Expand Down
2 changes: 1 addition & 1 deletion neon_audio/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Copyright 2008-2025 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ovos-utils~=0.0,>=0.0.35
ovos-config~=0.0,>=0.0.10
phoneme-guesser~=0.1
ovos-plugin-manager~=0.0,>=0.0.26a16
neon-utils[network]~=1.9
neon-utils[network,sentry,signal]~=1.9,>=1.12.1a2
click~=8.0
click-default-group~=1.2
ovos-bus-client~=0.0,>=0.0.3
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Copyright 2008-2025 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
Expand Down
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Copyright 2008-2025 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
Expand Down
2 changes: 1 addition & 1 deletion tests/api_method_tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Copyright 2008-2025 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
Expand Down
2 changes: 1 addition & 1 deletion tests/test_objects/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Copyright 2008-2025 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
Expand Down
7 changes: 3 additions & 4 deletions tests/unit_tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Copyright 2008-2025 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
Expand Down Expand Up @@ -196,6 +196,7 @@ def test_install_tts_plugin(self):
self.assertTrue(install_tts_plugin("neon-tts-plugin-coqui"))
self.assertFalse(install_tts_plugin("neon-tts-plugin-invalid"))

@skip("Configuration patching is deprecated")
def test_patch_config(self):
import json
from neon_audio.utils import use_neon_audio
Expand Down Expand Up @@ -229,12 +230,10 @@ def test_patch_config(self):
class TestCLI(unittest.TestCase):
runner = CliRunner()

@patch("neon_audio.cli.init_config_dir")
@patch("neon_audio.__main__.main")
def test_run(self, main, init_config):
def test_run(self, main):
from neon_audio.cli import run
self.runner.invoke(run)
init_config.assert_called_once()
main.assert_called_once()


Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Copyright 2008-2025 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
Expand Down

0 comments on commit 8d17328

Please sign in to comment.