Skip to content

Commit

Permalink
Update for ovos-workshop compat (#495)
Browse files Browse the repository at this point in the history
* Update ovos-workshop dependency
Resolve and patch deprecation warnings

* Remove deprecated patches
Add log to troubleshoot test failure

* Fix skill settings init error

---------

Co-authored-by: Daniel McKnight <daniel@neon.ai>
  • Loading branch information
NeonDaniel and NeonDaniel authored Dec 29, 2023
1 parent a61da61 commit 81b0a1b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 47 deletions.
13 changes: 0 additions & 13 deletions neon_utils/skills/mycroft_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,6 @@ def __init__(self, name=None, bus=None, *args, **kwargs):
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 @@ -90,11 +82,6 @@ def _init_settings(self):
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)

def _read_default_settings(self):
yaml_path = os.path.join(self.root_dir, "settingsmeta.yml")
json_path = os.path.join(self.root_dir, "settingsmeta.json")
Expand Down
51 changes: 18 additions & 33 deletions neon_utils/skills/neon_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,6 @@ def initialize(self):
self.schedule_event(self._write_cache_on_disk, CACHE_TIME_OFFSET,
name="neon.load_cache_on_disk")

@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 resources(self):
# TODO: Deprecate backwards-compat. wrapper after ovos-workshop 0.0.13
try:
return super().resources
except AttributeError:
return super()._resources

@property
# @deprecated("Call `dateutil.tz.gettz` directly", "2.0.0")
def sys_tz(self):
Expand Down Expand Up @@ -545,23 +529,24 @@ def _init_settings(self):
Extends the default method to handle settingsmeta defaults locally
"""
from neon_utils.configuration_utils import dict_update_keys
super()._init_settings()
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:
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)
BaseSkill._init_settings(self)
settings_from_disk = dict(self.settings)
dict_update_keys(self._settings, self._read_default_settings())
if self._settings != settings_from_disk:
LOG.info("Updated default settings from skill metadata")
self._settings.store()
self._initial_settings = dict(self._settings)
LOG.info(f"Skill initialized with settings: {self.settings}")

def _handle_converse_request(self, message: Message):
# TODO: Remove patch after ovos-core 0.0.8
if message.msg_type == "skill.converse.request" and \
message.data.get('skill_id') != self.skill_id:
# Legacy request not for Neon
return
if message.msg_type == "skill.converse.request":
message.msg_type = "neon.converse.request"
BaseSkill._handle_converse_request(self, message)

def _read_default_settings(self):
from neon_utils.configuration_utils import parse_skill_default_settings
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ ovos-lingua-franca~=0.4
ovos_utils~=0.0.35
geopy~=2.1
ovos-config~=0.0.9
ovos-workshop~=0.0.12
ovos-workshop~=0.0.15

0 comments on commit 81b0a1b

Please sign in to comment.