Skip to content

Commit

Permalink
Update configuration handling (#99)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
NeonDaniel and NeonDaniel authored Sep 12, 2024
1 parent d6bf6bd commit 4c09642
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
12 changes: 9 additions & 3 deletions neon_api_proxy/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
"""
Expand Down

0 comments on commit 4c09642

Please sign in to comment.