Skip to content

Commit

Permalink
refactor/merge BaseSkill and OVOSSkill (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl authored Sep 29, 2023
1 parent f19fb3f commit f2a5f93
Show file tree
Hide file tree
Showing 13 changed files with 2,191 additions and 2,420 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ dist

# Created by unit tests
.pytest_cache/
/.gtm/
4 changes: 2 additions & 2 deletions ovos_workshop/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ def __init__(self, skill_id: str, bus: Optional[MessageBusClient] = None,
**kwargs)

if settings:
log_deprecation(f"Settings should be set in {self._settings_path}. "
log_deprecation(f"Settings should be set in {self.settings_path}. "
f"Passing `settings` to __init__ is not supported.",
"0.1.0")
self.settings.merge(settings)

@property
def _settings_path(self) -> str:
def settings_path(self) -> str:
"""
Overrides the default path to put settings in `apps` subdirectory.
"""
Expand Down
10 changes: 6 additions & 4 deletions ovos_workshop/decorators/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from ovos_bus_client import MessageBusClient
from ovos_utils.log import LOG
from ovos_workshop.skills.base import BaseSkill


def dig_for_skill(max_records: int = 10) -> Optional[object]:
Expand All @@ -13,17 +12,20 @@ def dig_for_skill(max_records: int = 10) -> Optional[object]:
@param max_records: maximum number of records in the stack to check
@return: Skill or AbstractApplication instance if found
"""

from ovos_workshop.skills.ovos import OVOSSkill

stack = inspect.stack()[1:] # First frame will be this function call
stack = stack if len(stack) <= max_records else stack[:max_records]
for record in stack:
args = inspect.getargvalues(record.frame)
if args.locals.get("self"):
obj = args.locals["self"]
if isinstance(obj, BaseSkill):
if isinstance(obj, OVOSSkill):
return obj
elif args.locals.get("args"):
for obj in args.locals["args"]:
if isinstance(obj, BaseSkill):
if isinstance(obj, OVOSSkill):
return obj
return None

Expand Down Expand Up @@ -170,7 +172,7 @@ def bind(self, skill: object):
return self

@property
def skill(self) -> BaseSkill:
def skill(self):
return self._skill

@property
Expand Down
2 changes: 1 addition & 1 deletion ovos_workshop/skill_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ def _create_skill_instance(self,
log_deprecation("This initialization is deprecated. Update skill to"
"handle passed `skill_id` and `bus` kwargs",
"0.1.0")
if not self.instance._is_fully_initialized:
if not self.instance.is_fully_initialized:
self.instance._startup(self.bus, self.skill_id)
except Exception as e:
LOG.exception(f'Skill __init__ failed with {e}')
Expand Down
6 changes: 4 additions & 2 deletions ovos_workshop/skills/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from ovos_workshop.skills.ovos import MycroftSkill, OVOSSkill, OVOSFallbackSkill
from ovos_workshop.skills.idle_display_skill import IdleDisplaySkill
from ovos_workshop.decorators.layers import IntentLayers
from ovos_workshop.skills.ovos import OVOSSkill, OVOSFallbackSkill
from ovos_workshop.skills.idle_display_skill import IdleDisplaySkill
from ovos_workshop.skills.mycroft_skill import MycroftSkill

Loading

0 comments on commit f2a5f93

Please sign in to comment.