Skip to content

Commit

Permalink
1.10.0 (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel authored Apr 23, 2024
2 parents 1de4cc3 + ca72863 commit 96ab4f4
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 9 deletions.
50 changes: 47 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,56 @@
# Changelog

## [1.9.1a1](https://github.com/NeonGeckoCom/neon-utils/tree/1.9.1a1) (2024-03-01)
## [1.10.0](https://github.com/NeonGeckoCom/neon-utils/tree/1.10.0) (2024-04-23)

[Full Changelog](https://github.com/NeonGeckoCom/neon-utils/compare/1.9.0...1.9.1a1)
[Full Changelog](https://github.com/NeonGeckoCom/neon-utils/compare/1.9.2a5...1.10.0)

**Implemented enhancements:**

- \[FEAT\] Allows ovos-utils \<0.2.0 [\#506](https://github.com/NeonGeckoCom/neon-utils/issues/506)

## [1.9.2a5](https://github.com/NeonGeckoCom/neon-utils/tree/1.9.2a5) (2024-04-18)

[Full Changelog](https://github.com/NeonGeckoCom/neon-utils/compare/1.9.2a4...1.9.2a5)

**Fixed bugs:**

- \[BUG\] "hamlet" not handled as "city" [\#511](https://github.com/NeonGeckoCom/neon-utils/issues/511)

**Merged pull requests:**

- Treat 'hamlet' location as a 'city' [\#512](https://github.com/NeonGeckoCom/neon-utils/pull/512) ([NeonDaniel](https://github.com/NeonDaniel))

## [1.9.2a4](https://github.com/NeonGeckoCom/neon-utils/tree/1.9.2a4) (2024-04-09)

[Full Changelog](https://github.com/NeonGeckoCom/neon-utils/compare/1.9.2a3...1.9.2a4)

**Merged pull requests:**

- Update stopwatch to include error handling with unit tests [\#510](https://github.com/NeonGeckoCom/neon-utils/pull/510) ([NeonDaniel](https://github.com/NeonDaniel))

## [1.9.2a3](https://github.com/NeonGeckoCom/neon-utils/tree/1.9.2a3) (2024-04-04)

[Full Changelog](https://github.com/NeonGeckoCom/neon-utils/compare/1.9.2a2...1.9.2a3)

**Merged pull requests:**

- Add ovos-core 0.0.8 compat. for CommonQuery skills [\#508](https://github.com/NeonGeckoCom/neon-utils/pull/508) ([NeonDaniel](https://github.com/NeonDaniel))

## [1.9.2a2](https://github.com/NeonGeckoCom/neon-utils/tree/1.9.2a2) (2024-04-02)

[Full Changelog](https://github.com/NeonGeckoCom/neon-utils/compare/1.9.2a1...1.9.2a2)

**Merged pull requests:**

- Loosen ovos-utils dependency to allow 0.1 [\#507](https://github.com/NeonGeckoCom/neon-utils/pull/507) ([NeonDaniel](https://github.com/NeonDaniel))

## [1.9.2a1](https://github.com/NeonGeckoCom/neon-utils/tree/1.9.2a1) (2024-03-07)

[Full Changelog](https://github.com/NeonGeckoCom/neon-utils/compare/1.9.1...1.9.2a1)

**Merged pull requests:**

- Resovle optional dependency import error in skills module [\#503](https://github.com/NeonGeckoCom/neon-utils/pull/503) ([NeonDaniel](https://github.com/NeonDaniel))
- Mark `neon_must_respond` method as deprecated [\#505](https://github.com/NeonGeckoCom/neon-utils/pull/505) ([NeonDaniel](https://github.com/NeonDaniel))



Expand Down
3 changes: 2 additions & 1 deletion neon_utils/location_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ def get_location(lat, lng) -> (str, str, str, str):
LOG.debug(f"{location.raw.get('address')}")
city = location.raw.get('address').get('city') or \
location.raw.get('address').get('town') or \
location.raw.get('address').get('village')
location.raw.get('address').get('village') or \
location.raw.get('address').get('hamlet')
county = location.raw.get('address').get('county')
state = location.raw.get('address').get('state')
country = location.raw.get('address').get('country')
Expand Down
3 changes: 3 additions & 0 deletions neon_utils/message_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
from time import time
from typing import Optional, Union
from ovos_bus_client import Message
from ovos_utils.log import deprecated

from neon_utils.logger import LOG


Expand Down Expand Up @@ -263,6 +265,7 @@ def build_message(kind: Union[MessageKind, str], utt: str, message: Message,
**added_context})


@deprecated("Neon will always provide a response to API inputs.", "2.0.0")
@resolve_message
def neon_must_respond(message: Message = None) -> bool:
"""
Expand Down
6 changes: 5 additions & 1 deletion neon_utils/metrics_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ def start(self):
self.start_time = time()

def stop(self):
self.time = time() - self.start_time
try:
self.time = time() - self.start_time
except TypeError:
LOG.error("stop called before start!")
self.time = None
return self.time

def report(self):
Expand Down
31 changes: 29 additions & 2 deletions neon_utils/skills/common_query_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@
from ovos_workshop.decorators.layers import IntentLayers
from ovos_workshop.skills.common_query_skill import CQSMatchLevel, CQSVisualMatchLevel
from ovos_workshop.skills.common_query_skill import CommonQuerySkill as _CQS
from ovos_workshop.decorators.compat import backwards_compat
from ovos_utils.file_utils import resolve_resource_file
from ovos_utils.log import log_deprecation
from ovos_utils.log import log_deprecation, LOG
from neon_utils.skills.neon_skill import NeonSkill


Expand Down Expand Up @@ -76,6 +77,9 @@ class CommonQuerySkill(NeonSkill, _CQS):
answers from several skills presenting the best one available.
"""
def __init__(self, *args, **kwargs):
log_deprecation("This base class is deprecated. Implement "
"`ovos_workshop.skills.common_query_skill."
"CommonQuerySkill`", "2.0.0")
# these should probably be configurable
self.level_confidence = {
CQSMatchLevel.EXACT: 0.9,
Expand Down Expand Up @@ -130,7 +134,7 @@ def __calc_confidence(self, match, phrase, level):
else:
return 0.0 # should never happen

def __handle_query_action(self, message):
def __handle_query_classic(self, message):
"""Message handler for question:action.
Extracts phrase and data from message forward this to the skills
Expand All @@ -139,13 +143,36 @@ def __handle_query_action(self, message):
if message.data["skill_id"] != self.skill_id:
# Not for this skill!
return
LOG.debug(f"handling for ovos-core 0.0.7")
phrase = message.data["phrase"]
data = message.data.get("callback_data")
# Invoke derived class to provide playback data
self.CQS_action(phrase, data)
self.bus.emit(message.forward("mycroft.skill.handler.complete",
{"handler": "common_query"}))

@backwards_compat(classic_core=__handle_query_classic,
pre_008=__handle_query_classic)
def __handle_query_action(self, message):
"""
If this skill's response was spoken to the user, this method is called.
Phrase and callback data from `CQS_match_query_phrase` will be passed
to the `CQS_action` method.
@param message: `question:action` message
"""
if message.data["skill_id"] != self.skill_id:
# Not for this skill!
return
LOG.debug(f"handling for ovos-core 0.0.8")
phrase = message.data["phrase"]
data = message.data.get("callback_data") or {}
if data.get("answer"):
self.speak(data["answer"])
# Invoke derived class to provide playback data
self.CQS_action(phrase, data)
self.bus.emit(message.forward("mycroft.skill.handler.complete",
{"handler": "common_query"}))

def __handle_question_query(self, message):
# Override ovos-workshop implementation that doesn't pass `message`
search_phrase = message.data["phrase"]
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ timezonefinder~=5.2
nltk~=3.5
pyyaml>=5.4,<7.0
ovos-lingua-franca~=0.4
ovos_utils~=0.0.35
ovos_utils~=0.0,>=0.0.35
geopy~=2.1
ovos-config~=0.0.9
ovos-workshop~=0.0.15
4 changes: 4 additions & 0 deletions tests/location_util_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ def test_get_location_from_coords(self):
self.assertEqual(location, ("Seattle", "King County", "Washington",
"United States"))

# Test 'hamlet' location
location = get_location(34.46433387046654, -81.99487538579375)
self.assertIsInstance(location[0], str)

def test_get_timezone_from_coords(self):
from neon_utils.location_utils import get_timezone
lat = 47.6038321
Expand Down
4 changes: 4 additions & 0 deletions tests/metric_util_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ def test_stopwatch_simple(self):
sleep(sleep_time)
self.assertEqual(round(stopwatch.time, 2), sleep_time)

stopwatch = Stopwatch()
stopwatch.stop()
self.assertIsNone(stopwatch.time)

def test_stopwatch_reuse(self):
sleep_time = 0.5
stopwatch = Stopwatch()
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__ = "1.9.1"
__version__ = "1.10.0"

0 comments on commit 96ab4f4

Please sign in to comment.