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

feat/skill_launcher #65

Merged
merged 8 commits into from
Apr 20, 2023
Merged

feat/skill_launcher #65

merged 8 commits into from
Apr 20, 2023

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Apr 20, 2023

move some logic out of core, add helpers to launch skills standalone

if skills provide skill_id and bus in their kwargs / create_skill method they will initialize like regular python objects as soon as possible, this removes the issues around skill_id not being available before initialize

new cli entrypoints allow running skills fully standalone, eg, in docker

companion PR in core imports from here and deprecates mycroft.skills.skill_loader.py

USAGE: ovos-skill-launcher {skill_id} [path/to/my/skill_id]

supports passing a full path to a local skill to help in development

move some logic out of core, add helpers to launch skills standalone
@JarbasAl JarbasAl added the enhancement New feature or request label Apr 20, 2023
@JarbasAl JarbasAl requested review from goldyfruit, NeonDaniel and a team April 20, 2023 00:08
move some logic out of core, add helpers to launch skills standalone
@codecov
Copy link

codecov bot commented Apr 20, 2023

Codecov Report

❗ No coverage uploaded for pull request base (dev@a2f754c). Click here to learn what that means.
The diff coverage is n/a.

@@          Coverage Diff          @@
##             dev     #65   +/-   ##
=====================================
  Coverage       ?   0.00%           
=====================================
  Files          ?      32           
  Lines          ?    2731           
  Branches       ?       0           
=====================================
  Hits           ?       0           
  Misses         ?    2731           
  Partials       ?       0           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

ovos_workshop/skills/base.py Outdated Show resolved Hide resolved
ovos_workshop/skills/base.py Show resolved Hide resolved
ovos_workshop/skills/base.py Show resolved Hide resolved
ovos_workshop/skill_launcher.py Show resolved Hide resolved
ovos_workshop/skill_launcher.py Outdated Show resolved Hide resolved
ovos_workshop/skill_launcher.py Outdated Show resolved Hide resolved
BaseSkill, MycroftSkill, OVOSSkill, OVOSFallbackSkill,
OVOSCommonPlaybackSkill, OVOSFallbackSkill, CommonQuerySkill, ActiveSkill,
FallbackSkill, UniversalSkill, UniversalFallback
]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has been introduced to fix the check below for finding skill class in a python file, it is used to ensure we dont return the base class, previously checked for MycroftSkill only

def get_default_skills_directory():
""" return default directory to scan for skills

data_dir is always XDG_DATA_DIR
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note, this used to check mycroft.conf and was marked for deprecation in 0.0.3, removed now

for name, obj in skill_module.__dict__.items():
if isclass(obj):
if any(issubclass(obj, c) for c in SKILL_BASE_CLASSES) and \
not any(obj is c for c in SKILL_BASE_CLASSES):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated as mentioned in comment above

JarbasAl added a commit to OpenVoiceOS/ovos-core that referenced this pull request Apr 20, 2023
JarbasAl added a commit to OpenVoiceOS/ovos-core that referenced this pull request Apr 20, 2023
# in __init__ we need to manually call _startup
self.instance = skill_creator(bus=self.bus,
skill_id=self.skill_id)
# skills will have bus and skill_id available as soon as they call super()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this try: except: block is the main change in this PR compared with core

@JarbasAl JarbasAl requested a review from NeonDaniel April 20, 2023 01:15
setup.py Outdated Show resolved Hide resolved
self._enable_settings_manager = enable_settings_manager
self._init_event = Event()
self.name = name or self.__class__.__name__
self.resting_name = None
self.skill_id = '' # will be set by SkillLoader, guaranteed unique
self.skill_id = skill_id # will be set by SkillLoader, guaranteed unique
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the skill_id is not unique?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by definition it needs to be, if it isnt you are loading the same skill twice.

core ensures it wont load skills twice, the priority is:

  • plugin skills, skill_id in setup.py
  • all xdg skills directories, folder name is skill_id
  • empty folder disables skill from stack above (ie, folder named after a plugin skill_id disables that plugin skill)

if you are loading skills externally then you may get skills loaded twice, there is no protection against that

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is something we need to consider in core, will revisit this later, getting fallback skills working with the new entrypoints is higher priority :)

@JarbasAl JarbasAl merged commit 347f237 into dev Apr 20, 2023
@JarbasAl JarbasAl deleted the feat/skill_launcher branch April 20, 2023 02:25
JarbasAl added a commit to OpenVoiceOS/ovos-core that referenced this pull request Apr 22, 2023
JarbasAl added a commit to OpenVoiceOS/ovos-core that referenced this pull request Apr 22, 2023
JarbasAl added a commit to OpenVoiceOS/ovos-core that referenced this pull request Apr 22, 2023
@github-actions github-actions bot mentioned this pull request Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants