Skip to content

Commit

Permalink
0.7.0 (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel authored Sep 24, 2024
2 parents fe7acf2 + 97475d9 commit 7b1d915
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 51 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
29 changes: 6 additions & 23 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,20 @@
# Changelog

## [0.6.0](https://github.com/NeonGeckoCom/neon_api_proxy/tree/0.6.0) (2024-06-17)
## [0.6.1a2](https://github.com/NeonGeckoCom/neon_api_proxy/tree/0.6.1a2) (2024-09-12)

[Full Changelog](https://github.com/NeonGeckoCom/neon_api_proxy/compare/0.5.1a3...0.6.0)

**Implemented enhancements:**

- \[FEAT\] Add Daily and Hourly Weather API calls [\#71](https://github.com/NeonGeckoCom/neon_api_proxy/issues/71)
- Handle requests for unauthenticated APIs [\#21](https://github.com/NeonGeckoCom/neon_api_proxy/issues/21)

## [0.5.1a3](https://github.com/NeonGeckoCom/neon_api_proxy/tree/0.5.1a3) (2024-05-07)

[Full Changelog](https://github.com/NeonGeckoCom/neon_api_proxy/compare/0.5.1a2...0.5.1a3)

**Merged pull requests:**

- Update W|A and OWM wrappers to match upstream APIs [\#96](https://github.com/NeonGeckoCom/neon_api_proxy/pull/96) ([NeonDaniel](https://github.com/NeonDaniel))

## [0.5.1a2](https://github.com/NeonGeckoCom/neon_api_proxy/tree/0.5.1a2) (2024-04-25)

[Full Changelog](https://github.com/NeonGeckoCom/neon_api_proxy/compare/0.5.1a1...0.5.1a2)
[Full Changelog](https://github.com/NeonGeckoCom/neon_api_proxy/compare/0.6.1a1...0.6.1a2)

**Merged pull requests:**

- feat: allow ovos-utils 0.1.0 [\#94](https://github.com/NeonGeckoCom/neon_api_proxy/pull/94) ([mikejgray](https://github.com/mikejgray))
- Update configuration handling [\#99](https://github.com/NeonGeckoCom/neon_api_proxy/pull/99) ([NeonDaniel](https://github.com/NeonDaniel))

## [0.5.1a1](https://github.com/NeonGeckoCom/neon_api_proxy/tree/0.5.1a1) (2024-04-09)
## [0.6.1a1](https://github.com/NeonGeckoCom/neon_api_proxy/tree/0.6.1a1) (2024-08-08)

[Full Changelog](https://github.com/NeonGeckoCom/neon_api_proxy/compare/0.5.0...0.5.1a1)
[Full Changelog](https://github.com/NeonGeckoCom/neon_api_proxy/compare/0.6.0...0.6.1a1)

**Merged pull requests:**

- OWM language handling [\#93](https://github.com/NeonGeckoCom/neon_api_proxy/pull/93) ([NeonDaniel](https://github.com/NeonDaniel))
- Refactor backend services to accept more configuration params in init [\#98](https://github.com/NeonGeckoCom/neon_api_proxy/pull/98) ([NeonDaniel](https://github.com/NeonDaniel))



Expand Down
22 changes: 14 additions & 8 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}")
return NGIConfig("ngi_auth_vars").get("api_services", {})
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", {})
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 All @@ -86,14 +92,14 @@ def init_service_instances(self, service_class_mapping: dict) -> dict:
"""
service_mapping = dict()
for item in service_class_mapping:
api_key = self.config.get(item, {}).get("api_key") if self.config \
else None
service_config = self.config.get(item) or dict()
try:
if api_key is None and item != 'api_test_endpoint':
if service_config.get("api_key") is None and item not in \
('api_test_endpoint', "ip_api"):
LOG.warning(f"No API key for {item} in "
f"{list(self.config.keys())}")
service_mapping[item] = \
service_class_mapping[item](api_key=api_key)
service_class_mapping[item](**service_config)
except Exception as e:
LOG.error(e)
return service_mapping
Expand Down
4 changes: 2 additions & 2 deletions neon_api_proxy/services/alpha_vantage_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ class AlphaVantageAPI(CachedAPI):
API for querying Alpha Vantage.
"""

def __init__(self, api_key: str = None):
def __init__(self, api_key: str = None, cache_seconds: int = 300, **_):
super().__init__("alpha_vantage")
self._api_key = api_key or find_neon_alpha_vantage_key()
self.quote_timeout = timedelta(minutes=5)
self.quote_timeout = timedelta(seconds=cache_seconds)

def _search_symbol(self, query: str) -> dict:
if not query:
Expand Down
2 changes: 1 addition & 1 deletion neon_api_proxy/services/map_maker_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class MapMakerAPI(CachedAPI):
API for querying My Maps API (geocoder.maps.co).
"""

def __init__(self, api_key: str = None, cache_seconds=604800): # Cache week
def __init__(self, api_key: str = None, cache_seconds: int = 604800, **_): # Cache week
super().__init__("map_maker")
self._api_key = api_key or getenv("MAP_MAKER_KEY")
if not self._api_key:
Expand Down
2 changes: 1 addition & 1 deletion neon_api_proxy/services/owm_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class OpenWeatherAPI(CachedAPI):
API for querying Open Weather Map.
"""

def __init__(self, api_key: str = None, cache_seconds=180):
def __init__(self, api_key: str = None, cache_seconds: int = 900, **_):
super().__init__("open_weather_map")
self._api_key = api_key or find_neon_owm_key()
self.cache_timeout = timedelta(seconds=cache_seconds)
Expand Down
2 changes: 1 addition & 1 deletion neon_api_proxy/services/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@


class TestAPI(CachedAPI):
def __init__(self, api_key: str = None):
def __init__(self, api_key: str = None, **_):
super().__init__("Test")

def handle_query(self, **kwargs) -> dict:
Expand Down
4 changes: 2 additions & 2 deletions neon_api_proxy/services/wolfram_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ class WolframAPI(CachedAPI):
API for querying Wolfram|Alpha.
"""

def __init__(self, api_key: str = None):
def __init__(self, api_key: str = None, cache_seconds: int = 3600, **_):
super().__init__("wolfram")
self._api_key = api_key or find_neon_wolfram_key()
self.session.allowable_codes = (200, 501)
self.cache_time = timedelta(minutes=60)
self.cache_time = timedelta(seconds=cache_seconds)

def _build_query_url(self, query_type: QueryUrl, query_arg: str) -> str:
"""
Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

__version__ = "0.6.0"
__version__ = "0.7.0"

0 comments on commit 7b1d915

Please sign in to comment.