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:fallback_plugins #263

Merged
merged 4 commits into from
Sep 11, 2024
Merged

feat:fallback_plugins #263

merged 4 commits into from
Sep 11, 2024

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Sep 11, 2024

similar to WakeWords, allows defining a plugin to load if the primary fails

this is DIFFERENT from fallback TTS/STT, it isnt loaded at same time but instead when main plugin fails to load for any reason

companion to OpenVoiceOS/ovos-config#153

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced plugin loading mechanisms across various factories (G2P, Microphone, VAD, Language Detection, Language Translation) with fallback options for improved robustness.
    • Updated wake word module configuration to align with a new plugin system.
  • Bug Fixes

    • Streamlined logic for loading plugins by removing unnecessary mappings, reducing complexity, and improving error handling.
  • Refactor

    • Converted several static methods to class methods for better access to class-level properties and improved design principles.

similar to WakeWords, allows defining a plugin to load if the primary fails

this is DIFFERENT from fallback TTS/STT, it isnt loaded at same time but instead when main plugin fails to load for any reason
Copy link

coderabbitai bot commented Sep 11, 2024

Walkthrough

The pull request introduces significant changes across multiple files in the ovos_plugin_manager module. Key modifications include the removal of MAPPINGS dictionaries that previously linked identifiers to plugin names, simplifying the logic for loading plugins. The create methods in various factory classes have been transformed from static methods to class methods, allowing access to class-level properties. Additionally, a fallback mechanism has been implemented to load alternative plugins if the primary ones fail, enhancing the robustness of the plugin loading process.

Changes

Files Grouped Change Summary
g2p.py, microphone.py, vad.py, language.py Removed MAPPINGS dictionaries; altered create methods from static to class methods; introduced fallback mechanisms for loading plugins.
test_g2p.py, test_microphone.py, test_vad.py, test_language.py Added new test methods to validate the behavior of the create method with fallback configurations; introduced _FALLBACK_CONFIG and _TEST_CONFIG for testing.
test_wakewords.py Modified the configuration for the "hey_mycroft" hotword, updating the module name from "precise" to "ovos-ww-plugin-precise".

Possibly related PRs

Suggested labels

enhancement

Poem

🐰 In the meadow where plugins play,
The mappings have hopped away!
Class methods now lead the way,
With fallbacks to save the day.
A simpler path for all to see,
Hooray for change, so wild and free! 🌼


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2c50258 and 7fd0b6f.

Files selected for processing (1)
  • test/unittests/test_wakewords.py (3 hunks)
Additional comments not posted (2)
test/unittests/test_wakewords.py (2)

14-14: LGTM!

The changes to the module name for the "hey_mycroft" hotword in the configuration dictionary and the corresponding assertion update in test_create_hotword are consistent and look good.

Also applies to: 106-106


151-151: LGTM!

The assertion update in test_load_module to use the new module name "ovos-ww-plugin-precise" for the "hey_mycroft" hotword is consistent with the configuration change and looks good.


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

@github-actions github-actions bot added feature and removed feature labels Sep 11, 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 (2)
ovos_plugin_manager/vad.py (1)

Line range hint 85-111: Fallback mechanism looks good, consider a minor refactoring.

The changes to the create method are approved:

  • The change from static method to class method allows the method to call itself recursively to handle the fallback case, which is a good use of the class method.
  • The fallback mechanism enhances the robustness of the plugin loading process by providing an alternative in case the primary plugin fails to load.
  • The check to ensure the fallback plugin is different from the primary plugin avoids unnecessary attempts to reload the same module.

Consider this minor refactoring for consistency:

-clazz = OVOSVADFactory.get_class(vad_config)
+clazz = cls.get_class(vad_config)
ovos_plugin_manager/wakewords.py (1)

Line range hint 114-125: Ensure robust handling of module names after removing MAPPINGS.

The removal of the MAPPINGS dictionary simplifies the code but shifts the responsibility of ensuring valid module names to the hotword_config structure. This change may impact the robustness of the hotword loading process if invalid module names are provided in hotword_config.

Consider adding validation for module names in hotword_config to maintain the reliability of the hotword loading process. For example:

def validate_module_name(module_name):
    # Add validation logic here
    # Raise an exception or log an error if the module name is invalid
    pass

# In get_class method
ww_module = hotword_config[hotword]["module"]
validate_module_name(ww_module)
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fee6afc and 3fd6af1.

Files selected for processing (5)
  • ovos_plugin_manager/g2p.py (3 hunks)
  • ovos_plugin_manager/language.py (5 hunks)
  • ovos_plugin_manager/microphone.py (2 hunks)
  • ovos_plugin_manager/vad.py (4 hunks)
  • ovos_plugin_manager/wakewords.py (2 hunks)
Additional comments not posted (7)
ovos_plugin_manager/microphone.py (1)

52-53: LGTM! The changes enhance flexibility and robustness.

The changes made to the create method are approved for the following reasons:

  1. Changing the method from static to class method:

    • Allows the method to access class-level properties and methods, enhancing its flexibility.
    • Enables the method to utilize class-specific behavior.
  2. Implementing the fallback mechanism:

    • Improves the resilience of the microphone loading process by providing a fallback option.
    • Enhances the overall functionality of the microphone management system by attempting to load an alternative microphone plugin if the primary one fails.

The fallback mechanism is a valuable addition that helps maintain functionality even in the event of a failure with the primary plugin.

Also applies to: 65-65, 73-73, 78-81

ovos_plugin_manager/vad.py (1)

84-84: LGTM!

The change from static method to class method is approved. This allows the method to access class-level properties if needed in the future, providing more flexibility.

ovos_plugin_manager/g2p.py (2)

94-94: LGTM!

The removal of the MAPPINGS dictionary simplifies the logic for determining the G2P module to load. The code now directly checks if the g2p_module is equal to 'dummy', which is a more straightforward approach.


Line range hint 99-124: LGTM!

The changes to the create method enhance its flexibility and improve the robustness of the plugin loading process:

  • Changing the method from a static method to a class method allows it to access class-level properties and methods more effectively.
  • The introduction of a fallback mechanism provides an alternative option if the primary plugin fails to load, improving the overall reliability of the system.

The code changes are well-structured and follow a clear logic flow.

ovos_plugin_manager/wakewords.py (1)

Line range hint 144-155: LGTM!

The changes to the create_hotword method look good. The fallback mechanism enhances the robustness of the plugin loading process by providing an alternative when the primary plugin fails. The code correctly checks if the fallback plugin exists in ww_configs and is different from the primary plugin before attempting to load it.

ovos_plugin_manager/language.py (2)

Line range hint 108-138: LGTM!

The changes in the create method of OVOSLangDetectionFactory are well-structured and improve the handling of fallback plugins. The key improvements include:

  • Changing the method from static to a class method, allowing for more flexible access to class-level properties and methods.
  • Implementing a fallback mechanism to load an alternative plugin if the primary one fails, enhancing the robustness of the plugin loading process.
  • Simplifying the logic by removing the checks for mappings and directly retrieving the fallback module from the configuration.

The code changes are approved.


Line range hint 164-194: LGTM!

The changes in the create method of OVOSLangTranslationFactory are well-structured and improve the handling of fallback plugins, similar to the changes in OVOSLangDetectionFactory. The key improvements include:

  • Changing the method from static to a class method, allowing for more flexible access to class-level properties and methods.
  • Implementing a fallback mechanism to load an alternative plugin if the primary one fails, enhancing the robustness of the plugin loading process.
  • Simplifying the logic by removing the checks for mappings and directly retrieving the fallback module from the configuration.

The code changes are approved.

JarbasAl added a commit to OpenVoiceOS/ovos-config that referenced this pull request Sep 11, 2024
similar to WakeWords, allows defining a plugin to load if the primary fails

this is DIFFERENT from fallback TTS/STT, it isnt loaded at same time but instead when main plugin fails to load for any reason

companion to OpenVoiceOS/ovos-plugin-manager#263
JarbasAl added a commit to OpenVoiceOS/ovos-config that referenced this pull request Sep 11, 2024
similar to WakeWords, allows defining a plugin to load if the primary fails

this is DIFFERENT from fallback TTS/STT, it isnt loaded at same time but instead when main plugin fails to load for any reason

companion to OpenVoiceOS/ovos-plugin-manager#263
@github-actions github-actions bot added feature and removed feature labels Sep 11, 2024
@github-actions github-actions bot added feature and removed feature labels Sep 11, 2024
@github-actions github-actions bot added feature and removed feature labels Sep 11, 2024
@github-actions github-actions bot added feature and removed feature labels Sep 11, 2024
@JarbasAl JarbasAl merged commit 4e447d8 into dev Sep 11, 2024
9 checks passed
@JarbasAl JarbasAl deleted the feat/fallback_plugins branch September 11, 2024 21:23
JarbasAl added a commit to OpenVoiceOS/ovos-config that referenced this pull request Sep 11, 2024
similar to WakeWords, allows defining a plugin to load if the primary fails

this is DIFFERENT from fallback TTS/STT, it isnt loaded at same time but instead when main plugin fails to load for any reason

companion to OpenVoiceOS/ovos-plugin-manager#263
JarbasAl added a commit to OpenVoiceOS/ovos-dinkum-listener that referenced this pull request Sep 11, 2024
@JarbasAl JarbasAl mentioned this pull request Sep 11, 2024
JarbasAl added a commit to OpenVoiceOS/ovos-dinkum-listener that referenced this pull request Sep 11, 2024
* plugins

* debug

* feat:fallback_plugins

OpenVoiceOS/ovos-config#153

OpenVoiceOS/ovos-plugin-manager#263

* Update requirements.txt
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