From 4c09642b8d13ac61264b4726e3c6ce01067e5e0d Mon Sep 17 00:00:00 2001 From: Daniel McKnight <34697904+NeonDaniel@users.noreply.github.com> Date: Wed, 11 Sep 2024 18:52:40 -0700 Subject: [PATCH] Update configuration handling (#99) * Update warning log to use log_deprecation Update config handling to support `api_services` config outside of `keys` since #98 enabled more configuration options * Address review feedback * Update unit test GHA to resolve failure * Troubleshooting breaking changes in artifact upload action --------- Co-authored-by: Daniel McKnight --- .github/workflows/unit_tests.yml | 24 ++++++++++++------------ neon_api_proxy/controller.py | 12 +++++++++--- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 82911d3..b18fdf4 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -54,36 +54,36 @@ jobs: run: | pytest tests/test_cached_api.py --doctest-modules --junitxml=tests/cached-api-test-results.xml - name: Upload cached API test results - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: - name: cached-api-test-results + name: cached-api-test-results-${{matrix.python-version}} path: tests/cached-api-test-results.xml - name: Test Wolfram API run: | pytest tests/test_wolfram_api.py --doctest-modules --junitxml=tests/wolfram-api-test-results.xml - name: Upload Wolfram API test results - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: - name: wolfram-api-test-results + name: wolfram-api-test-results-${{matrix.python-version}} path: tests/wolfram-api-test-results.xml - name: Test Alpha Vantage API run: | pytest tests/test_alpha_vantage_api.py --doctest-modules --junitxml=tests/alphavantage-api-test-results.xml - name: Upload Alpha Vantage API test results - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: - name: alphavantage-api-test-results + name: alphavantage-api-test-results-${{matrix.python-version}} path: tests/alphavantage-api-test-results.xml - name: Test OWM API run: | pytest tests/test_owm_api.py --doctest-modules --junitxml=tests/owm-api-test-results.xml - name: Upload Open Weather Map API test results - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: - name: owm-api-test-results + name: owm-api-test-results-${{matrix.python-version}} path: tests/owm-api-test-results.xml - name: Test Map Maker API @@ -92,16 +92,16 @@ jobs: env: MAP_MAKER_KEY: ${{secrets.map_maker_key}} - name: Upload Map Maker API test results - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: - name: map-maker-api-test-results + name: map-maker-api-test-results-${{matrix.python-version}} path: tests/map-maker-api-test-results.xml - name: Test Generic API run: | pytest tests/test_generic_controller.py --doctest-modules --junitxml=tests/generic-controller-test-results.xml - name: Upload Generic API test results - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: - name: generic-controller-test-results + name: generic-controller-test-results-${{matrix.python-version}} path: tests/generic-controller-test-results.xml \ No newline at end of file diff --git a/neon_api_proxy/controller.py b/neon_api_proxy/controller.py index 9e6414a..8f6f560 100644 --- a/neon_api_proxy/controller.py +++ b/neon_api_proxy/controller.py @@ -27,7 +27,7 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. from os.path import join, isfile -from ovos_utils.log import LOG +from ovos_utils.log import LOG, log_deprecation from ovos_config.config import Configuration from neon_utils.configuration_utils import NGIConfig from ovos_config.locations import get_xdg_config_save_path @@ -70,10 +70,16 @@ def _init_config() -> dict: legacy_config_file = join(get_xdg_config_save_path(), "ngi_auth_vars.yml") if isfile(legacy_config_file): - LOG.warning(f"Legacy configuration found at: {legacy_config_file}") + log_deprecation(f"Legacy configuration found at: {legacy_config_file}. " + f"This will be ignored in future versions. " + f"Default configuration handling will use " + f"~/.config/neon/diana.yaml.", + "1.0.0") return NGIConfig("ngi_auth_vars").get("api_services") or dict() else: - return Configuration().get("keys", {}).get("api_services") or dict() + config = Configuration() + return config.get("keys", {}).get("api_services") or \ + config.get("api_services") or dict() def init_service_instances(self, service_class_mapping: dict) -> dict: """