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

fix/skillmanager_api #222

Merged
merged 1 commit into from
Jul 16, 2024
Merged
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
22 changes: 22 additions & 0 deletions ovos_workshop/skill_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,25 @@ def __init__(self, skill_id: str, skill_directory: Optional[str] = None,
self.skill_directory = skill_directory
self.skill_loader = None

def do_unload(self, message):
"""compat with legacy api from skill manager in core"""
if message.msg_type == 'skillmanager.keep':
if message.data['skill'] == self.skill_id:
return
elif message.data['skill'] != self.skill_id:
return
if self.skill_loader:
LOG.info("unloading skill")
self.skill_loader._unload()

def do_load(self, message):
"""compat with legacy api from skill manager in core"""
if message.data['skill'] != self.skill_id:
return
if self.skill_loader:
LOG.info("reloading skill")
self.skill_loader._load()

def _connect_to_core(self):
"""
Initialize messagebus connection and register event to load skill once
Expand All @@ -589,6 +608,9 @@ def _connect_to_core(self):
LOG.warning("Skills service not ready yet. Load on ready event.")

self.bus.on("mycroft.ready", self.load_skill)
self.bus.on("skillmanager.activate", self.do_load)
self.bus.on("skillmanager.deactivate", self.do_unload)
self.bus.on("skillmanager.keep", self.do_unload)

def load_skill(self, message: Optional[Message] = None):
"""
Expand Down
Loading