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

fix:usage without skills installed #555

merged 2 commits into from
Oct 14, 2024

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Oct 10, 2024

in setups without skills installed the trained event was never emitted, causing OVOS to hang forever and never reporting ready, but we have no need to wait here, it was only there to delay padatious training to after all skills loaded, but this no longer happens at once on boot in OVOS like it did in mycroft

noticed in docker when running skills in standalone mode (individual container per skill)

adds a check to see if any skills are installed, to make logs more informative

relates to #554

Summary by CodeRabbit

  • New Features
    • Enhanced skill loading logic to efficiently detect and load installed skills.
  • Bug Fixes
    • Removed unnecessary loading attempts when no skills are available.
  • Refactor
    • Streamlined the startup process by eliminating the waiting for initial training completion.
    • Removed the handle_initial_training method for improved clarity.
  • Style
    • Minor formatting adjustments for improved code clarity.

Copy link

coderabbitai bot commented Oct 10, 2024

Walkthrough

The changes in ovos_core/skill_manager.py enhance the SkillManager class by improving skill loading logic based on the detection of installed skills. A new boolean attribute _detected_installed_skills is introduced to track installed skills, affecting the execution of loading methods. The run method is streamlined by removing the waiting for initial training completion, leading to the deletion of the handle_initial_training method. Minor formatting adjustments have also been made to improve code clarity.

Changes

File Change Summary
ovos_core/skill_manager.py Added _detected_installed_skills attribute; updated loading methods to check for installed skills; removed handle_initial_training method; modified run method to streamline startup process; minor formatting adjustments.
test/unittests/skills/test_skill_manager.py Removed 'mycroft.skills.trained' event from expected results in test_instantiate method.

Poem

In the burrow where skills reside,
A new way to load, we take in stride.
No more waiting, just hop right in,
With skills detected, let the fun begin!
🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

JarbasAl added a commit that referenced this pull request Oct 10, 2024
@github-actions github-actions bot added fix and removed fix labels Oct 10, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
ovos_core/skill_manager.py (3)

119-122: LGTM! Consider adding a debug log for when skills are detected.

The addition of the _detected_installed_skills attribute and the warning log for when no skills are detected is a good improvement. It will help with debugging, especially in standalone mode.

Consider adding a debug log when skills are detected, for consistency:

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!")
+else:
+    LOG.debug(f"Detected {len(find_skill_plugins())} installed skills")

618-620: LGTM! Consistent improvement for offline skill loading.

The addition of the _detected_installed_skills check before loading offline skills is consistent with the changes made to other loading methods. This optimization prevents unnecessary processing when no skills are installed.

For consistency with the other loading methods, consider updating the log message:

-            LOG.info('Loading offline skills...')
+            LOG.info('Loading skills that do not require network or internet...')

Line range hint 119-620: Great improvements! Consider adding a method to check for installed skills.

The addition of the _detected_installed_skills attribute and its usage across different loading methods effectively addresses the issue of unnecessary processing when no skills are installed. This change aligns well with the PR objectives and improves the overall efficiency of the SkillManager.

To further improve code maintainability and reduce duplication, consider extracting the skill detection logic into a separate method:

def _has_installed_skills(self):
    if not hasattr(self, '_detected_installed_skills'):
        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!")
        else:
            LOG.debug(f"Detected {len(find_skill_plugins())} installed skills")
    return self._detected_installed_skills

Then, you can use this method in the loading functions:

if self._has_installed_skills():
    LOG.info('Loading skills that ...')
    self._load_new_skills(...)

This approach would centralize the skill detection logic and make it easier to modify or extend in the future.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6e81054 and ce178c0.

📒 Files selected for processing (1)
  • ovos_core/skill_manager.py (4 hunks)
🧰 Additional context used
🔇 Additional comments (2)
ovos_core/skill_manager.py (2)

567-569: LGTM! Good optimization for network-dependent skill loading.

The addition of the _detected_installed_skills check before loading network-dependent skills is a good optimization. It prevents unnecessary processing when no skills are installed.


574-576: LGTM! Consistent improvement for internet-dependent skill loading.

The addition of the _detected_installed_skills check before loading internet-dependent skills is consistent with the changes made to _load_on_network. This optimization prevents unnecessary processing when no skills are installed.

in setups without skills installed the trained event was never emitted, causing OVOS to hang forever and never reporting ready

noticed in docker when running skills in standalone mode (individual container per skill)

adds a check to see if any skills are installed, to make logs more informative
Copy link

codecov bot commented Oct 13, 2024

Codecov Report

Attention: Patch coverage is 23.07692% with 10 lines in your changes missing coverage. Please review.

Project coverage is 74.82%. Comparing base (23f0bab) to head (575e725).
Report is 12 commits behind head on dev.

Files with missing lines Patch % Lines
ovos_core/skill_manager.py 23.07% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #555      +/-   ##
==========================================
- Coverage   75.33%   74.82%   -0.52%     
==========================================
  Files          15       15              
  Lines        3094     3043      -51     
==========================================
- Hits         2331     2277      -54     
- Misses        763      766       +3     
Flag Coverage Δ
end2end 56.62% <23.07%> (?)
unittests 53.92% <23.07%> (-21.42%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot added fix and removed fix labels Oct 14, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ce178c0 and 575e725.

📒 Files selected for processing (2)
  • ovos_core/skill_manager.py (4 hunks)
  • test/unittests/skills/test_skill_manager.py (0 hunks)
💤 Files with no reviewable changes (1)
  • test/unittests/skills/test_skill_manager.py
🧰 Additional context used
🔇 Additional comments (4)
ovos_core/skill_manager.py (4)

200-200: Registration of device readiness handler is appropriate

The addition of the event handler handle_check_device_readiness improves the system's ability to verify device readiness upon skill initialization. This change enhances the startup process.


567-569: Conditionally load network-dependent skills

Adding the condition if self._detected_installed_skills before loading network-dependent skills ensures that the system attempts to load these skills only if they are installed. This prevents unnecessary operations and potential errors when no skills are present.


574-576: Conditionally load internet-dependent skills

The inclusion of if self._detected_installed_skills before loading skills that require internet access is appropriate. It ensures that the system efficiently handles scenarios where no skills are installed by avoiding redundant loading attempts.


618-620: Conditionally load skills on startup

The check for self._detected_installed_skills before loading skills on startup is a good addition. It prevents the system from attempting to load skills when none are installed, improving startup efficiency and avoiding unnecessary processing.

ovos_core/skill_manager.py Show resolved Hide resolved
@JarbasAl JarbasAl merged commit cf23664 into dev Oct 14, 2024
4 of 5 checks passed
@JarbasAl JarbasAl deleted the fix/noskills branch October 14, 2024 00:22
JarbasAl added a commit that referenced this pull request Oct 14, 2024
@coderabbitai coderabbitai bot mentioned this pull request Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant