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:usage without skills installed #555

Merged
merged 2 commits into from
Oct 14, 2024
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
38 changes: 14 additions & 24 deletions ovos_core/skill_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,16 @@ def __init__(self, bus, watchdog=None, alive_hook=on_alive, started_hook=on_star
self._network_skill_timeout = 300
self._allow_state_reloads = True
self._logged_skill_warnings = list()
self._detected_installed_skills = bool(find_skill_plugins())
if not self._detected_installed_skills:
LOG.warning("No installed skills detected! if you are running skills in standalone mode ignore this warning,"
" otherwise you probably want to install skills first!")
JarbasAl marked this conversation as resolved.
Show resolved Hide resolved

self.config = Configuration()

self.skill_loaders = {}
self.plugin_skills = {}
self.enclosure = EnclosureAPI(bus)
self.initial_load_complete = False
self.num_install_retries = 0
self.empty_skill_dirs = set() # Save a record of empty skill dirs.

Expand Down Expand Up @@ -194,9 +197,7 @@ def _define_message_bus_events(self):
self.bus.on('skillmanager.deactivate', self.deactivate_skill)
self.bus.on('skillmanager.keep', self.deactivate_except)
self.bus.on('skillmanager.activate', self.activate_skill)
self.bus.once('mycroft.skills.initialized',
self.handle_check_device_readiness)
self.bus.once('mycroft.skills.trained', self.handle_initial_training)
self.bus.once('mycroft.skills.initialized', self.handle_check_device_readiness)

# Load skills waiting for connectivity
self.bus.on("mycroft.network.connected", self.handle_network_connected)
Expand Down Expand Up @@ -497,16 +498,6 @@ def network_requirements(self):
else:
LOG.error(f'Priority skill {skill_id} can\'t be found')

def handle_initial_training(self, message):
"""Handle the initial intent training completion event.

This usually only includes offline skills

Args:
message: Message containing information about the initial training completion.
"""
self.initial_load_complete = True

def run(self):
"""Run the skill manager thread."""
self.load_priority()
Expand Down Expand Up @@ -550,10 +541,6 @@ def run(self):
'network_loaded': self._network_loaded.is_set()}))
self.bus.emit(Message('mycroft.skills.initialized'))

# wait for initial intents training
LOG.debug("Waiting for initial training")
while not self.initial_load_complete:
sleep(0.5)
self.status.set_ready()

if self._gui_event.is_set() and self._connected_event.is_set():
Expand All @@ -577,14 +564,16 @@ def run(self):

def _load_on_network(self):
"""Load skills that require a network connection."""
LOG.info('Loading skills that require network...')
self._load_new_skills(network=True, internet=False)
if self._detected_installed_skills: # ensure we have skills is installed
LOG.info('Loading skills that require network...')
self._load_new_skills(network=True, internet=False)
self._network_loaded.set()

def _load_on_internet(self):
"""Load skills that require both internet and network connections."""
LOG.info('Loading skills that require internet (and network)...')
self._load_new_skills(network=True, internet=True)
if self._detected_installed_skills: # ensure we have skills is installed
LOG.info('Loading skills that require internet (and network)...')
self._load_new_skills(network=True, internet=True)
self._internet_loaded.set()
self._network_loaded.set()

Expand Down Expand Up @@ -626,8 +615,9 @@ def _unload_on_gui_disconnect(self):

def _load_on_startup(self):
"""Handle offline skills load on startup."""
LOG.info('Loading offline skills...')
self._load_new_skills(network=False, internet=False)
if self._detected_installed_skills: # ensure we have skills is installed
LOG.info('Loading offline skills...')
self._load_new_skills(network=False, internet=False)

def _load_new_skills(self, network=None, internet=None, gui=None):
"""Handle loading of skills installed since startup.
Expand Down
1 change: 0 additions & 1 deletion test/unittests/skills/test_skill_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ def test_instantiate(self):
'skillmanager.keep',
'skillmanager.activate',
'mycroft.skills.initialized',
'mycroft.skills.trained',
'mycroft.network.connected',
'mycroft.internet.connected',
'mycroft.gui.available',
Expand Down
Loading