From ed8f5ba94466747379099a360b63122a3c476fd1 Mon Sep 17 00:00:00 2001 From: Daniel McKnight <34697904+NeonDaniel@users.noreply.github.com> Date: Thu, 6 Feb 2025 17:08:46 -0800 Subject: [PATCH] Update default configuration handling in CLI module (#97) * Update cli module to set default envvars Remove references to deprecated `init_config_dir` function Update License notices to 2025 * Update unit test Python versions * Update unit tests to account for config handling change * Add `signal` extra to `neon-utils` to resolve container deployment bug --- .github/workflows/unit_tests.yml | 4 ++-- LICENSE.md | 2 +- docker_overlay/root/run.sh | 2 +- neon_enclosure/__init__.py | 2 +- neon_enclosure/__main__.py | 2 +- neon_enclosure/admin/__init__.py | 2 +- neon_enclosure/admin/__main__.py | 2 +- neon_enclosure/admin/service.py | 2 +- neon_enclosure/cli.py | 14 ++++++++++---- neon_enclosure/service.py | 2 +- neon_enclosure/utils.py | 2 +- requirements/requirements.txt | 2 +- setup.py | 2 +- tests/test_enclosure_service.py | 11 +++-------- version.py | 2 +- 15 files changed, 27 insertions(+), 26 deletions(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 357f6f1..8dc8a24 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -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@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 diff --git a/LICENSE.md b/LICENSE.md index 0f84944..cbec999 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -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 diff --git a/docker_overlay/root/run.sh b/docker_overlay/root/run.sh index b7b3000..314a8c0 100755 --- a/docker_overlay/root/run.sh +++ b/docker_overlay/root/run.sh @@ -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 diff --git a/neon_enclosure/__init__.py b/neon_enclosure/__init__.py index 718d1b0..5694901 100644 --- a/neon_enclosure/__init__.py +++ b/neon_enclosure/__init__.py @@ -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 diff --git a/neon_enclosure/__main__.py b/neon_enclosure/__main__.py index 8cd7b50..889f7f4 100644 --- a/neon_enclosure/__main__.py +++ b/neon_enclosure/__main__.py @@ -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 diff --git a/neon_enclosure/admin/__init__.py b/neon_enclosure/admin/__init__.py index 98aeae1..b39409f 100644 --- a/neon_enclosure/admin/__init__.py +++ b/neon_enclosure/admin/__init__.py @@ -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 diff --git a/neon_enclosure/admin/__main__.py b/neon_enclosure/admin/__main__.py index 5e3d9f2..449a789 100644 --- a/neon_enclosure/admin/__main__.py +++ b/neon_enclosure/admin/__main__.py @@ -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 diff --git a/neon_enclosure/admin/service.py b/neon_enclosure/admin/service.py index 661440f..069fc85 100644 --- a/neon_enclosure/admin/service.py +++ b/neon_enclosure/admin/service.py @@ -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 diff --git a/neon_enclosure/cli.py b/neon_enclosure/cli.py index 64abc82..adef0fd 100644 --- a/neon_enclosure/cli.py +++ b/neon_enclosure/cli.py @@ -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 @@ -25,16 +25,22 @@ # 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. + import click import sys +from os import environ 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_utils.log import LOG from ovos_config.config import Configuration from typing import List + +environ.setdefault("OVOS_CONFIG_BASE_FOLDER", "neon") +environ.setdefault("OVOS_CONFIG_FILENAME", "neon.yaml") + + @click.group("neon-enclosure", cls=DefaultGroup, no_args_is_help=True, invoke_without_command=True, help="Neon Enclosure Commands\n\n" @@ -46,6 +52,7 @@ def neon_enclosure_cli(version: bool = False): click.echo(f"neon_enclosure version " f"{get_package_version_spec('neon_enclosure')}") + @neon_enclosure_cli.command(help="Install neon-enclosure module dependencies from config & cli") @click.option("--package", "-p", default=[], multiple=True, help="Additional package to install (can be repeated)") @@ -58,9 +65,9 @@ def install_dependencies(package: List[str]): LOG.info(f"pip exit code: {result}") sys.exit(result) + @neon_enclosure_cli.command(help="Start Neon Enclosure module") def run(): - init_config_dir() from neon_enclosure.__main__ import main click.echo("Starting Enclosure Service") main() @@ -73,7 +80,6 @@ def run_admin(): if geteuid() != 0: click.echo("Admin enclosure must be started as `root`") exit(1) - init_config_dir() from neon_enclosure.admin.__main__ import main click.echo("Starting Admin Enclosure Service") main() diff --git a/neon_enclosure/service.py b/neon_enclosure/service.py index 82ce5cb..b7f554e 100644 --- a/neon_enclosure/service.py +++ b/neon_enclosure/service.py @@ -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 diff --git a/neon_enclosure/utils.py b/neon_enclosure/utils.py index 8c15d8b..c27132e 100644 --- a/neon_enclosure/utils.py +++ b/neon_enclosure/utils.py @@ -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 diff --git a/requirements/requirements.txt b/requirements/requirements.txt index bfbc4e5..d85df8f 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -1,5 +1,5 @@ ovos-phal~=0.0,>=0.0.5 -neon-utils[network]~=1.9 +neon-utils[network,signal]~=1.9,>=1.12.1a1 ovos-utils~=0.0,>=0.0.32 click~=8.0 click-default-group~=1.2 diff --git a/setup.py b/setup.py index 2a8e9ad..20fac7d 100644 --- a/setup.py +++ b/setup.py @@ -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. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/test_enclosure_service.py b/tests/test_enclosure_service.py index b6ede37..2162ab3 100644 --- a/tests/test_enclosure_service.py +++ b/tests/test_enclosure_service.py @@ -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 @@ -101,29 +101,24 @@ def test_enclosure_service(self): class TestCLI(unittest.TestCase): runner = CliRunner() - @patch("neon_enclosure.cli.init_config_dir") @patch("neon_enclosure.__main__.main") - def test_run(self, main, init_config): + def test_run(self, main): from neon_enclosure.cli import run self.runner.invoke(run) - init_config.assert_called_once() main.assert_called_once() @patch("os.geteuid") - @patch("neon_enclosure.cli.init_config_dir") @patch("neon_enclosure.admin.__main__.main") - def test_run_admin(self, main, init_config, get_id): + def test_run_admin(self, main, get_id): from neon_enclosure.cli import run_admin # Non-root get_id.return_value = 100 self.runner.invoke(run_admin) - init_config.assert_not_called() main.assert_not_called() # Root get_id.return_value = 0 self.runner.invoke(run_admin) - init_config.assert_called_once() main.assert_called_once() diff --git a/version.py b/version.py index e05aade..cc2ae7e 100644 --- a/version.py +++ b/version.py @@ -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. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License.