Skip to content

Commit

Permalink
Merge pull request #267 from OpenVoiceOS/release-2.1.0a1
Browse files Browse the repository at this point in the history
Release 2.1.0a1
  • Loading branch information
JarbasAl authored Nov 6, 2024
2 parents 4276b7b + 398fea3 commit 38046a8
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 12 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Changelog

## [2.0.1a1](https://github.com/OpenVoiceOS/OVOS-workshop/tree/2.0.1a1) (2024-11-05)
## [2.1.0a1](https://github.com/OpenVoiceOS/OVOS-workshop/tree/2.1.0a1) (2024-11-06)

[Full Changelog](https://github.com/OpenVoiceOS/OVOS-workshop/compare/2.0.0...2.0.1a1)
[Full Changelog](https://github.com/OpenVoiceOS/OVOS-workshop/compare/2.0.1...2.1.0a1)

**Merged pull requests:**

- fix: allow latest bus client version [\#264](https://github.com/OpenVoiceOS/OVOS-workshop/pull/264) ([JarbasAl](https://github.com/JarbasAl))
- feat: status [\#266](https://github.com/OpenVoiceOS/OVOS-workshop/pull/266) ([JarbasAl](https://github.com/JarbasAl))



Expand Down
38 changes: 32 additions & 6 deletions ovos_workshop/skills/ovos.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import binascii
import datetime
import os
import re
Expand All @@ -13,6 +12,7 @@
from threading import Event, RLock
from typing import Dict, Callable, List, Optional, Union

import binascii
from json_database import JsonStorage
from langcodes import closest_match
from lingua_franca.format import pronounce_number, join_list
Expand All @@ -37,6 +37,7 @@
from ovos_utils.lang import standardize_lang_tag
from ovos_utils.log import LOG
from ovos_utils.parse import match_one
from ovos_utils.process_utils import ProcessStatus, StatusCallbackMap, ProcessState
from ovos_utils.process_utils import RuntimeRequirements
from ovos_utils.skills import get_non_properties
from ovos_workshop.decorators.killable import AbortEvent, killable_event, \
Expand Down Expand Up @@ -441,7 +442,7 @@ def enclosure(self) -> EnclosureAPI:
self.log.warning('Skill not fully initialized.'
f"to correct this add kwargs "
f"__init__(bus=None, skill_id='') "
f"to skill class {self.__class__.__name__}."
f"to skill class {self.__class__.__name__}."
"You can only use self.enclosure after the call to 'super()'")
self.log.error(simple_trace(traceback.format_stack()))
raise Exception('Accessed OVOSSkill.enclosure in __init__')
Expand All @@ -458,7 +459,7 @@ def file_system(self) -> FileSystemAccess:
else:
self.log.warning('Skill not fully initialized.'
f"to correct this add kwargs __init__(bus=None, skill_id='') "
f"to skill class {self.__class__.__name__} "
f"to skill class {self.__class__.__name__} "
"You can only use self.file_system after the call to 'super()'")
self.log.error(simple_trace(traceback.format_stack()))
raise Exception('Accessed OVOSSkill.file_system in __init__')
Expand Down Expand Up @@ -751,6 +752,21 @@ def _check_for_first_run(self):
self.settings["__mycroft_skill_firstrun"] = False
self.settings.store()

def on_ready_status(self):
LOG.info(f'{self.skill_id} is ready.')

def on_error_status(self, e='Unknown'):
LOG.exception(f'{self.skill_id} initialization failed')

def on_stopping_status(self):
LOG.info(f'{self.skill_id} is shutting down...')

def on_alive_status(self):
LOG.debug(f'{self.skill_id} is alive.')

def on_started_status(self):
LOG.debug(f'{self.skill_id} started.')

def _startup(self, bus: MessageBusClient, skill_id: str = ""):
"""
Startup the skill. Connects the skill to the messagebus, loads resources
Expand All @@ -764,11 +780,18 @@ def _startup(self, bus: MessageBusClient, skill_id: str = ""):
f"times, ignoring")
return

callbacks = StatusCallbackMap(on_ready=self.on_ready_status,
on_error=self.on_error_status,
on_stopping=self.on_stopping_status,
on_alive=self.on_alive_status,
on_started=self.on_started_status)

# NOTE: this method is called by SkillLoader
# it is private to make it clear to skill devs they should not touch it
try:
# set the skill_id
self.skill_id = skill_id or basename(self.root_dir)

self.intent_service.set_id(self.skill_id)
self.event_scheduler.set_id(self.skill_id)
self.enclosure.set_id(self.skill_id)
Expand All @@ -779,6 +802,8 @@ def _startup(self, bus: MessageBusClient, skill_id: str = ""):

# initialize anything that depends on the messagebus
self.bind(bus)
self.status = ProcessStatus(self.skill_id, self.bus, callback_map=callbacks)
self.status.set_alive()
if not self.gui:
self._init_skill_gui()
if self._enable_settings_manager:
Expand All @@ -787,12 +812,14 @@ def _startup(self, bus: MessageBusClient, skill_id: str = ""):
self._register_decorated()
self.register_resting_screen()

self.status.set_started()
# run skill developer initialization code
self.initialize()
self._check_for_first_run()
self._init_event.set()
self.status.set_ready()
except Exception as e:
self.log.exception('Skill initialization failed')
self.status.set_error(str(e))
# If an exception occurs, attempt to clean up the skill
try:
self.default_shutdown()
Expand Down Expand Up @@ -1249,7 +1276,7 @@ def default_shutdown(self):
5) Call skill.shutdown() to allow skill to do any other shutdown tasks
6) Emit `detach_skill` Message to notify skill is shut down
"""

self.status.set_stopping()
try:
# Allow skill to handle `stop` actions before shutting things down
self.stop()
Expand Down Expand Up @@ -2475,4 +2502,3 @@ def __init__(self, skill: OVOSSkill):
ui_directories = get_ui_directories(skill.root_dir)
GUIInterface.__init__(self, skill_id=skill_id, bus=bus, config=config,
ui_directories=ui_directories)

6 changes: 3 additions & 3 deletions ovos_workshop/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# START_VERSION_BLOCK
VERSION_MAJOR = 2
VERSION_MINOR = 0
VERSION_BUILD = 1
VERSION_ALPHA = 0
VERSION_MINOR = 1
VERSION_BUILD = 0
VERSION_ALPHA = 1
# END_VERSION_BLOCK

0 comments on commit 38046a8

Please sign in to comment.