Skip to content

Commit

Permalink
refactor!:drop mycroft (#235)
Browse files Browse the repository at this point in the history
* refactor!:drop mycroft

* tests

* port extra tests from ovos-core
  • Loading branch information
JarbasAl authored Oct 15, 2024
1 parent a096b41 commit 2d684a1
Show file tree
Hide file tree
Showing 57 changed files with 654 additions and 2,353 deletions.
5 changes: 0 additions & 5 deletions ovos_workshop/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +0,0 @@
from ovos_workshop.app import OVOSAbstractApplication
from ovos_workshop.decorators import *
from ovos_workshop.decorators.killable import killable_event, \
AbortEvent, AbortQuestion
from ovos_workshop.decorators.layers import IntentLayers
44 changes: 0 additions & 44 deletions ovos_workshop/decorators/compat.py

This file was deleted.

2 changes: 1 addition & 1 deletion ovos_workshop/decorators/ocp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ovos_workshop.backwards_compat import MediaType, PlayerState, MediaState, MatchConfidence, \
from ovos_utils.ocp import MediaType, PlayerState, MediaState, MatchConfidence, \
PlaybackType, PlaybackMode, LoopState, TrackState


Expand Down
3 changes: 1 addition & 2 deletions ovos_workshop/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@

class SkillSettingsManager:
def __init__(self, skill):
from ovos_workshop.skills.base import BaseSkill
self.download_timer: Optional[Timer] = None
self.skill: BaseSkill = skill
self.skill = skill
self.api = DeviceApi()
self.remote_settings = \
RemoteSkillSettings(self.skill_id,
Expand Down
14 changes: 5 additions & 9 deletions ovos_workshop/skill_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,19 @@

from ovos_workshop.skills.active import ActiveSkill
from ovos_workshop.skills.auto_translatable import UniversalSkill, UniversalFallback
from ovos_workshop.skills.base import BaseSkill
from ovos_workshop.skills.common_play import OVOSCommonPlaybackSkill
from ovos_workshop.skills.common_query_skill import CommonQuerySkill
from ovos_workshop.skills.fallback import FallbackSkill
from ovos_workshop.skills.mycroft_skill import MycroftSkill
from ovos_workshop.skills.ovos import OVOSSkill, OVOSFallbackSkill
from ovos_workshop.skills.ovos import OVOSSkill

SKILL_BASE_CLASSES = [
BaseSkill, MycroftSkill, OVOSSkill, OVOSFallbackSkill,
OVOSCommonPlaybackSkill, OVOSFallbackSkill, CommonQuerySkill, ActiveSkill,
OVOSSkill, OVOSCommonPlaybackSkill, CommonQuerySkill, ActiveSkill,
FallbackSkill, UniversalSkill, UniversalFallback
]

SKILL_MAIN_MODULE = '__init__.py'



def remove_submodule_refs(module_name: str):
"""
Ensure submodules are reloaded by removing the refs from sys.modules.
Expand Down Expand Up @@ -85,13 +81,13 @@ def load_skill_module(path: str, skill_id: str) -> ModuleType:

def get_skill_class(skill_module: ModuleType) -> Optional[callable]:
"""
Find MycroftSkill based class in skill module.
Find OVOSSkill based class in skill module.
Arguments:
skill_module (module): module to search for Skill class
Returns:
(MycroftSkill): Found subclass of MycroftSkill or None.
(OVOSSkill): Found subclass of OVOSSkill or None.
"""
if not skill_module:
raise ValueError("Expected module and got None")
Expand Down Expand Up @@ -156,7 +152,7 @@ def __init__(self, bus: MessageBusClient,
self._loaded = None
self.load_attempted = False
self.last_loaded = 0
self.instance: Optional[BaseSkill] = None
self.instance: Optional[OVOSSkill] = None
self.active = True
self._watchdog = None
self.config = Configuration()
Expand Down
7 changes: 4 additions & 3 deletions ovos_workshop/skills/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from ovos_workshop.decorators.layers import IntentLayers
from ovos_workshop.skills.ovos import OVOSSkill, OVOSFallbackSkill
from ovos_workshop.skills.ovos import OVOSSkill
from ovos_workshop.skills.idle_display_skill import IdleDisplaySkill
from ovos_workshop.skills.mycroft_skill import MycroftSkill

from ovos_workshop.skills.fallback import FallbackSkill
from ovos_workshop.skills.common_query_skill import CommonQuerySkill
from ovos_workshop.skills.common_play import OVOSCommonPlaybackSkill
4 changes: 2 additions & 2 deletions ovos_workshop/skills/active.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ def bind(self, bus):
super(ActiveSkill, self).bind(bus)
if bus:
""" insert skill in active skill list on load """
self.make_active()
self.activate()

def handle_skill_deactivated(self, message=None):
"""
skill is always in active skill list, ie, converse is always called
"""
self.make_active()
self.activate()


6 changes: 3 additions & 3 deletions ovos_workshop/skills/auto_translatable.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from ovos_utils.log import LOG
from ovos_workshop.resource_files import SkillResources
from ovos_workshop.skills.common_query_skill import CommonQuerySkill
from ovos_workshop.skills.fallback import FallbackSkillV2
from ovos_workshop.skills.fallback import FallbackSkill
from ovos_workshop.skills.ovos import OVOSSkill


Expand Down Expand Up @@ -311,7 +311,7 @@ def _handle_converse_request(self, message: Message):
super()._handle_converse_request(message)


class UniversalFallback(UniversalSkill, FallbackSkillV2):
class UniversalFallback(UniversalSkill, FallbackSkill):
"""
Fallback Skill that auto translates input/output from any language.
Expand Down Expand Up @@ -373,7 +373,7 @@ def register_fallback(self, handler, priority: int):
- `create_universal_fallback_handler` method for creating universal fallback handlers.
"""
handler = self.create_universal_fallback_handler(handler)
FallbackSkillV2.register_fallback(self, handler, priority)
FallbackSkill.register_fallback(self, handler, priority)


class UniversalCommonQuerySkill(UniversalSkill, CommonQuerySkill, ABC):
Expand Down
17 changes: 0 additions & 17 deletions ovos_workshop/skills/base.py

This file was deleted.

2 changes: 1 addition & 1 deletion ovos_workshop/skills/common_play.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# backwards compat imports, do not delete, skills import from here
from ovos_workshop.decorators.ocp import ocp_play, ocp_next, ocp_pause, ocp_resume, ocp_search, \
ocp_previous, ocp_featured_media
from ovos_workshop.backwards_compat import MediaType, MediaState, MatchConfidence, \
from ovos_utils.ocp import MediaType, MediaState, MatchConfidence, \
PlaybackType, PlaybackMode, PlayerState, LoopState, TrackState, Playlist, PluginStream, MediaEntry


Expand Down
16 changes: 0 additions & 16 deletions ovos_workshop/skills/common_query_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from ovos_utils.file_utils import resolve_resource_file
from ovos_utils.log import LOG, log_deprecation

from ovos_workshop.decorators.compat import backwards_compat
from ovos_workshop.skills.ovos import OVOSSkill


Expand Down Expand Up @@ -233,21 +232,6 @@ def __calc_confidence(self, match: str, phrase: str, level: CQSMatchLevel,

return confidence

def __handle_query_classic(self, message):
"""
does not perform self.speak, < 0.0.8 this is done by core itself
"""
if message.data["skill_id"] != self.skill_id:
# Not for this skill!
return
self.activate()
phrase = message.data["phrase"]
data = message.data.get("callback_data") or {}
# Invoke derived class to provide playback data
self.CQS_action(phrase, data)

@backwards_compat(classic_core=__handle_query_classic,
pre_008=__handle_query_classic)
def __handle_query_action(self, message: Message):
"""
If this skill's response was spoken to the user, this method is called.
Expand Down
4 changes: 0 additions & 4 deletions ovos_workshop/skills/decorators/__init__.py

This file was deleted.

4 changes: 0 additions & 4 deletions ovos_workshop/skills/decorators/converse.py

This file was deleted.

4 changes: 0 additions & 4 deletions ovos_workshop/skills/decorators/fallback_handler.py

This file was deleted.

4 changes: 0 additions & 4 deletions ovos_workshop/skills/decorators/killable.py

This file was deleted.

4 changes: 0 additions & 4 deletions ovos_workshop/skills/decorators/layers.py

This file was deleted.

4 changes: 0 additions & 4 deletions ovos_workshop/skills/decorators/ocp.py

This file was deleted.

Loading

0 comments on commit 2d684a1

Please sign in to comment.