Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for ovos-workshop compat #495

Merged
merged 3 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading