Skip to content

Commit

Permalink
Emit handler complete event for CommonQuery skills (#477)
Browse files Browse the repository at this point in the history
* Back-port OpenVoiceOS/OVOS-workshop#142

* Resolve license test failure
Refactor for upstream ovos-workshop compat.

* Troubleshooting compat. with upstream `settings_path` changes

* More test failure troubleshooting

* Fix bad references to inherited properties

* More settings_path troubleshooting

---------

Co-authored-by: Daniel McKnight <[email protected]>
  • Loading branch information
NeonDaniel and NeonDaniel authored Oct 10, 2023
1 parent 7c7bacf commit d0deade
Show file tree
Hide file tree
Showing 5 changed files with 355 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/license_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ jobs:
uses: neongeckocom/.github/.github/workflows/license_tests.yml@master
with:
package-extras: audio,configuration,networking
packages-exclude: '^(precise-runner|fann2|tqdm|bs4|ovos-phal-plugin|ovos-skill|neon-core|nvidia|neon-phal-plugin|bitstruct|audioread).*'
2 changes: 2 additions & 0 deletions neon_utils/skills/common_query_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ def __handle_query_action(self, message):
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"}))

@abstractmethod
def CQS_match_query_phrase(self, phrase, message):
Expand Down
16 changes: 14 additions & 2 deletions neon_utils/skills/mycroft_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from typing import Optional
from json_database import JsonStorage
from ovos_bus_client.message import Message
from ovos_utils.log import log_deprecation
from ovos_workshop.skills.mycroft_skill import MycroftSkill
from ovos_utils.skills.settings import get_local_settings

Expand All @@ -49,11 +50,21 @@
class PatchedMycroftSkill(MycroftSkill):
def __init__(self, name=None, bus=None, *args, **kwargs):
MycroftSkill.__init__(self, name, bus, *args, **kwargs)
log_deprecation("This base class is deprecated. Implement either"
"`NeonSkill` or `OVOSSkill`", "2.0.0")
# TODO: Should below defaults be global config?
# allow skills to specify timeout overrides per-skill
self._speak_timeout = 30
self._get_response_timeout = 15 # 10 for listener, 5 for STT, then timeout

@property
def settings_path(self):
# TODO: Deprecate backwards-compat. wrapper after ovos-workshop 0.0.13
try:
return super().settings_path
except AttributeError:
return super()._settings_path

@property
def location(self):
"""
Expand All @@ -67,19 +78,20 @@ def _init_settings(self):
Extends the default method to handle settingsmeta defaults locally
"""
super()._init_settings()
skill_settings = get_local_settings(self._settings_path)
skill_settings = get_local_settings(self.settings_path)
settings_from_disk = dict(skill_settings)
self.settings = dict_update_keys(skill_settings,
self._read_default_settings())
if self.settings != settings_from_disk:
if isinstance(self.settings, JsonStorage):
self.settings.store()
else:
with open(self._settings_path, "w+") as f:
with open(self.settings_path, "w+") as f:
json.dump(self.settings, f, indent=4)
self._initial_settings = dict(self.settings)

def _init_settings_manager(self):
# TODO: Same as upstream implementation?
from ovos_workshop.settings import SkillSettingsManager
self.settings_manager = SkillSettingsManager(self)

Expand Down
Loading

0 comments on commit d0deade

Please sign in to comment.