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/pipeline_plugins_opm #527

Merged
merged 13 commits into from
Oct 14, 2024
Merged

feat/pipeline_plugins_opm #527

merged 13 commits into from
Oct 14, 2024

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Jul 20, 2024

subclass pipelines from the OPM placeholder base class

directly integrated pipeline into padacioso

move to maintained ovos-adapt-parser and ovos-padatious forked packages and directly integrate pipeline plugins into those

extracts OCP code into it's own plugin ovos-ocp-pipeline-plugin to allow better versioning classifier models etc. same for ovos-common-query-pipeline-plugin

NOTE: the base api for the OPM pipeline base class is not yet defined, this PR is only moving intent engines code to their corresponding packages (that follow semver), arbitrary pipeline plugins can not yet be loaded by core with only this PR, future work is still needed

companion PRS:

moved tests:

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced plugin architecture with the introduction of PipelinePlugin for several services, improving modularity and functionality.
    • Added PLUGIN_ENTRY_POINT in setup for better plugin registration.
  • Bug Fixes

    • Corrected indentation in license testing workflow for improved clarity.
  • Refactor

    • Updated import paths for various services to utilize new modules, ensuring compatibility with the latest library structures.
    • Replaced several classes with their updated counterparts from new modules, enhancing the intent parsing capabilities.
  • Chores

    • Updated dependency specifications in requirements.txt and lgpl.txt to reflect new package versions.

Copy link

coderabbitai bot commented Jul 20, 2024

Walkthrough

The updates introduce modifications to workflow configurations and intent service modules within the project. Key changes include the addition of a new system dependency, python3-fann2, in the build workflow, adjustments to license test exclusions, and a transition to the ovos_adapt library for intent management. Several service classes have been refactored to enhance modularity by inheriting from PipelinePlugin, and various dependencies have been updated to align with the new architecture.

Changes

Files Change Summary
.github/workflows/build_tests.yml Added python3-fann2 as a system dependency; adjusted installation order for build tools.
.github/workflows/license_tests.yml Updated exclude parameter to add ovos-adapt-parser and ovos-padatious; corrected indentation for the Print report step.
mycroft/skills/intent_services/adapt_service.py Updated import statements to transition from adapt to ovos_adapt, renaming AdaptService to AdaptPipeline.
ovos_core/intent_services/__init__.py Changed import paths for AdaptService and PadatiousService to reflect new locations; updated initialization accordingly.
ovos_core/intent_services/adapt_service.py Removed AdaptService class implementation; replaced with AdaptPipeline from ovos_adapt.opm.
ovos_core/intent_services/commonqa_service.py Refactored CommonQAService to inherit from PipelinePlugin; added selected_skill field to Query data class.
ovos_core/intent_services/converse_service.py Updated ConverseService to inherit from PipelinePlugin, altering its initialization.
ovos_core/intent_services/fallback_service.py Modified FallbackService to inherit from PipelinePlugin and updated constructor for initialization.
ovos_core/intent_services/ocp_service.py Changed OCPPipelineMatcher to inherit from both PipelinePlugin and OVOSAbstractApplication; updated constructor for both parent classes.
ovos_core/intent_services/padacioso_service.py Removed PadaciosoIntent and PadaciosoService, replaced with imports from padacioso.opm.
ovos_core/intent_services/padatious_service.py Removed PadatiousMatcher and PadatiousService, replaced with imports from ovos_padatious.opm.
ovos_core/intent_services/stop_service.py Updated StopService to inherit from PipelinePlugin.
requirements/lgpl.txt Replaced padatious with ovos_padatious, updating version constraints; fann2 dependency unchanged.
requirements/requirements.txt Updated padacioso version constraint; replaced adapt-parser with ovos-adapt-parser.
setup.py Introduced PLUGIN_ENTRY_POINT variable for plugin registration under opm.pipeline.
test/unittests/common_query/ovos_tskill_fakewiki/__init__.py Updated import for IntentBuilder from adapt.intent to ovos_adapt.intent.
test/unittests/skills/decorator_test_skill.py Changed import for IntentBuilder from adapt.intent to ovos_adapt.intent.
test/unittests/skills/test_intent_service.py Updated import for ContextManager from ovos_core.intent_services.adapt_service to ovos_adapt.opm.
test/unittests/skills/test_intent_service_interface.py Changed import for IntentBuilder from adapt.intent to ovos_adapt.intent.
test/unittests/skills/test_mycroft_skill.py Updated import for IntentBuilder from adapt.intent to ovos_adapt.intent.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PluginManager
    participant IntentService
    participant AdaptPipeline

    User->>PluginManager: Request intent processing
    PluginManager->>IntentService: Forward request
    IntentService->>AdaptPipeline: Process intent
    AdaptPipeline-->>IntentService: Return matched intent
    IntentService-->>PluginManager: Send response
    PluginManager-->>User: Deliver intent response
Loading

🐰 In fields so wide, where bunnies play,
New paths are forged, come what may.
With plugins bright and code refined,
Our skills grow sharper, our joys entwined.
Hops of progress, leaps of cheer,
Together we thrive, year after year! 🌼✨

Possibly related PRs

  • improve_typing #528: Changes in ovos_core/intent_services/adapt_service.py involve modifications to import statements, which may relate to the overall structure of the codebase that the main PR is also addressing through workflow changes.
  • feat/reranker+optional_ovos_classifiers #529: Updates in ovos_core/intent_services/commonqa_service.py include changes to the initialization and usage of components, which could be relevant to the adjustments made in the main PR regarding dependency management in workflows.
  • fix:version check #557: Modifications in ovos_core/intent_services/commonqa_service.py streamline the handling of attributes, which may connect with the overall improvements in the workflow processes outlined in the main PR.
  • automations:split tests into 2 workflows #558: Introduction of a new workflow for end-to-end tests directly relates to the changes in the main PR regarding the workflow configuration, indicating a focus on enhancing testing processes.

Suggested labels

enhancement, dependencies


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 JarbasAl added refactor code refactor without functional changes packaging dependency updates or packaging changes labels Jul 20, 2024
@JarbasAl JarbasAl marked this pull request as ready for review July 20, 2024 18:28
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: 5

Outside diff range, codebase verification and nitpick comments (4)
.github/workflows/build_tests.yml (1)

35-38: Temporary installation steps approved.

The steps to install ovos-adapt-pipeline-plugin and ovos-padatious-pipeline-plugin from GitHub are necessary for now. Remember to remove these steps once the plugins are released.

.github/workflows/license_tests.yml (1)

27-30: Temporary installation steps approved.

The steps to install ovos-adapt-pipeline-plugin and ovos-padatious-pipeline-plugin from GitHub are necessary for now. Remember to remove these steps once the plugins are released.

.github/workflows/unit_tests.yml (2)

51-53: Temporary installation steps approved.

The steps to install ovos-adapt-pipeline-plugin from GitHub are necessary for now. Remember to remove these steps once the plugin is released.


87-87: Temporary installation step approved.

The step to install ovos-padatious-pipeline-plugin from GitHub is necessary for now. Remember to remove this step once the plugin is released.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b603751 and 4b1505c.

Files selected for processing (19)
  • .github/workflows/build_tests.yml (1 hunks)
  • .github/workflows/license_tests.yml (1 hunks)
  • .github/workflows/unit_tests.yml (2 hunks)
  • mycroft/skills/intent_services/adapt_service.py (1 hunks)
  • ovos_core/intent_services/init.py (2 hunks)
  • ovos_core/intent_services/adapt_service.py (1 hunks)
  • ovos_core/intent_services/commonqa_service.py (4 hunks)
  • ovos_core/intent_services/converse_service.py (4 hunks)
  • ovos_core/intent_services/fallback_service.py (3 hunks)
  • ovos_core/intent_services/ocp_service.py (9 hunks)
  • ovos_core/intent_services/padacioso_service.py (1 hunks)
  • ovos_core/intent_services/padatious_service.py (1 hunks)
  • ovos_core/intent_services/stop_service.py (6 hunks)
  • requirements/lgpl.txt (1 hunks)
  • requirements/requirements.txt (1 hunks)
  • test/unittests/common_query/ovos_tskill_fakewiki/init.py (1 hunks)
  • test/unittests/skills/decorator_test_skill.py (1 hunks)
  • test/unittests/skills/test_intent_service_interface.py (1 hunks)
  • test/unittests/skills/test_mycroft_skill.py (1 hunks)
Files skipped from review due to trivial changes (3)
  • test/unittests/common_query/ovos_tskill_fakewiki/init.py
  • test/unittests/skills/decorator_test_skill.py
  • test/unittests/skills/test_intent_service_interface.py
Additional context used
Ruff
ovos_core/intent_services/adapt_service.py

2-2: ovos_adapt.opm.AdaptPipeline imported but unused

Remove unused import: ovos_adapt.opm.AdaptPipeline

(F401)

ovos_core/intent_services/padacioso_service.py

2-2: padacioso.opm.PadaciosoPipeline imported but unused

Remove unused import

(F401)


2-2: padacioso.opm.PadaciosoIntent imported but unused

Remove unused import

(F401)

ovos_core/intent_services/padatious_service.py

2-2: ovos_padatious.opm.PadatiousMatcher imported but unused

Remove unused import

(F401)


2-2: ovos_padatious.opm.PadatiousPipeline imported but unused

Remove unused import

(F401)

mycroft/skills/intent_services/adapt_service.py

16-16: ovos_adapt.context.ContextManagerFrame imported but unused

Remove unused import: ovos_adapt.context.ContextManagerFrame

(F401)


17-17: ovos_adapt.engine.IntentDeterminationEngine imported but unused

Remove unused import: ovos_adapt.engine.IntentDeterminationEngine

(F401)

ovos_core/intent_services/ocp_service.py

415-415: f-string without any placeholders

Remove extraneous f prefix

(F541)


442-442: f-string without any placeholders

Remove extraneous f prefix

(F541)


459-459: f-string without any placeholders

Remove extraneous f prefix

(F541)


470-470: f-string without any placeholders

Remove extraneous f prefix

(F541)


494-494: f-string without any placeholders

Remove extraneous f prefix

(F541)


1094-1094: f-string without any placeholders

Remove extraneous f prefix

(F541)

Additional comments not posted (26)
requirements/lgpl.txt (1)

2-2: LGTM!

The version constraint for fann2 remains unchanged, which is acceptable.

requirements/requirements.txt (3)

11-11: Verify compatibility with the new version of ovos-plugin-manager.

Ensure that the codebase is compatible with the alpha version 0.0.26a33 of ovos-plugin-manager.


6-7: Verify compatibility with the new version of padacioso.

Ensure that the codebase is compatible with the alpha version 0.2.2a1 of padacioso.


7-7: Verify compatibility with ovos-adapt-parser.

Ensure that the codebase is compatible with ovos-adapt-parser.

.github/workflows/build_tests.yml (1)

33-33: Verify the necessity of python3-fann2.

Ensure that the addition of python3-fann2 is required for the new features or dependencies.

ovos_core/intent_services/fallback_service.py (5)

Line range hint 161-195: Ensure the return type hint is appropriate.

The return type hint Optional[IntentMatch] is appropriate given the method's logic. The method returns an IntentMatch object or None based on the fallback handling.


198-202: Ensure the return type hint is appropriate.

The return type hint Optional[IntentMatch] is appropriate given the method's logic. The method returns the result of _fallback_range, which matches the expected return type.


203-207: Ensure the return type hint is appropriate.

The return type hint Optional[IntentMatch] is appropriate given the method's logic. The method returns the result of _fallback_range, which matches the expected return type.


Line range hint 208-212: Ensure the return type hint is appropriate.

The return type hint Optional[IntentMatch] is appropriate given the method's logic. The method returns the result of _fallback_range, which matches the expected return type.


32-32: Integrate PipelinePlugin correctly.

The class FallbackService now inherits from PipelinePlugin. Ensure the PipelinePlugin methods and properties are correctly utilized within this class.

ovos_core/intent_services/stop_service.py (4)

Line range hint 117-160: Ensure the return type hint is appropriate.

The return type hint Optional[IntentMatch] is appropriate given the method's logic. The method returns an IntentMatch object or None based on the stop handling.


Line range hint 167-194: Ensure the return type hint is appropriate.

The return type hint Optional[IntentMatch] is appropriate given the method's logic. The method returns the result of match_stop_low, which matches the expected return type.


Line range hint 195-236: Ensure the return type hint is appropriate.

The return type hint Optional[IntentMatch] is appropriate given the method's logic. The method returns an IntentMatch object or None based on the stop handling.


15-15: Integrate PipelinePlugin correctly.

The class StopService now inherits from PipelinePlugin. Ensure the PipelinePlugin methods and properties are correctly utilized within this class.

Verification successful

No direct usage of PipelinePlugin methods or properties found in StopService.

The StopService class inherits from PipelinePlugin, but no methods or properties of PipelinePlugin are directly used within the class.

  • ovos_core/intent_services/stop_service.py, lines 15-282
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `PipelinePlugin` methods and properties within `StopService`.

# Test: Search for `PipelinePlugin` methods and properties usage. Expect: Proper utilization within `StopService`.
rg --type python -A 5 'class StopService' | rg 'PipelinePlugin'

Length of output: 94


Script:

#!/bin/bash
# Find the file containing the class StopService
file=$(fd -e py 'class StopService' -x rg -l 'class StopService' {})

# Verify the usage of `PipelinePlugin` methods and properties within `StopService`.
rg 'PipelinePlugin' $file

Length of output: 1353


Script:

#!/bin/bash
# Extract the StopService class and its methods from the file
rg -A 50 'class StopService' ovos_core/intent_services/stop_service.py > stop_service_extracted.py

# Search for PipelinePlugin methods and properties within the extracted class
rg 'PipelinePlugin' stop_service_extracted.py

Length of output: 153


Script:

#!/bin/bash
# Extract the StopService class and its methods from the file with more lines to ensure the entire class is captured
rg -A 100 'class StopService' ovos_core/intent_services/stop_service.py > stop_service_extracted.py

# Search for PipelinePlugin methods and properties within the extracted class
rg 'PipelinePlugin' stop_service_extracted.py

Length of output: 154


Script:

#!/bin/bash
# Identify the start and end of the StopService class definition
start_line=$(rg -n 'class StopService' ovos_core/intent_services/stop_service.py | cut -d: -f1)
end_line=$(tail -n +$((start_line + 1)) ovos_core/intent_services/stop_service.py | rg -n '^class|^def' | head -n 1 | cut -d: -f1)
if [ -z "$end_line" ]; then
  end_line=$(wc -l < ovos_core/intent_services/stop_service.py)
else
  end_line=$((start_line + end_line - 1))
fi

# Extract the StopService class definition
sed -n "${start_line},${end_line}p" ovos_core/intent_services/stop_service.py > stop_service_extracted.py

# Search for PipelinePlugin methods and properties within the extracted class
rg 'PipelinePlugin' stop_service_extracted.py

Length of output: 401

ovos_core/intent_services/commonqa_service.py (3)

35-39: Ensure the config parameter is correctly utilized.

The config parameter is correctly utilized in the initialization logic, allowing for more flexible configuration management within the service.


Line range hint 80-122: Ensure the return type hint is appropriate.

The return type hint Optional[IntentMatch] is appropriate given the method's logic. The method returns an IntentMatch object or None based on the query handling.


34-34: Integrate PipelinePlugin and OVOSAbstractApplication correctly.

The class CommonQAService now inherits from both PipelinePlugin and OVOSAbstractApplication. Ensure the methods and properties from both base classes are correctly utilized within this class.

ovos_core/intent_services/converse_service.py (1)

Line range hint 316-345:
LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to converse_with_skills match the new return type and usage of IntentMatch.

Verification successful

Verification successful.

The function converse_with_skills is used correctly in the codebase, and the return type and usage of IntentMatch are consistent.

  • ovos_core/intent_services/converse_service.py
  • ovos_core/intent_services/__init__.py
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `converse_with_skills` match the new return type and usage of `IntentMatch`.

# Test: Search for the function usage. Expect: Only occurances of the new signature.
rg --type python -A 5 $'converse_with_skills'

Length of output: 75


Script:

#!/bin/bash
# Description: Verify all function calls to `converse_with_skills` match the new return type and usage of `IntentMatch`.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type py -A 5 $'converse_with_skills'

Length of output: 1601

test/unittests/skills/test_mycroft_skill.py (1)

24-24: LGTM!

The import change for IntentBuilder reflects a reorganization or update in the underlying architecture of the project.

ovos_core/intent_services/__init__.py (1)

34-34: LGTM!

The import change for IntentMatch enhances maintainability and consistency across the codebase by moving towards a more centralized or standardized definition.

ovos_core/intent_services/ocp_service.py (6)

115-123: Constructor changes look good!

The constructor now properly initializes both parent classes PipelinePlugin and OVOSAbstractApplication.


Line range hint 354-393:
Return type annotation is appropriate.

The match_high method's return type is correctly defined as Optional[IntentMatch].


Line range hint 395-423:
Return type annotation is appropriate.

The match_medium method's return type is correctly defined as Optional[IntentMatch].

Tools
Ruff

415-415: f-string without any placeholders

Remove extraneous f prefix

(F541)


Line range hint 424-448:
Return type annotation is appropriate.

The match_fallback method's return type is correctly defined as Optional[IntentMatch].

Tools
Ruff

442-442: f-string without any placeholders

Remove extraneous f prefix

(F541)


459-459: f-string without any placeholders

Remove extraneous f prefix

(F541)


470-470: f-string without any placeholders

Remove extraneous f prefix

(F541)


Line range hint 451-504:
Return type annotation is appropriate.

The _process_play_query method's return type is correctly defined as Optional[IntentMatch].

Tools
Ruff

442-442: f-string without any placeholders

Remove extraneous f prefix

(F541)


459-459: f-string without any placeholders

Remove extraneous f prefix

(F541)


470-470: f-string without any placeholders

Remove extraneous f prefix

(F541)


Line range hint 1074-1098:
Return type annotation is appropriate.

The match_legacy method's return type is correctly defined as Optional[IntentMatch].

Tools
Ruff

1094-1094: f-string without any placeholders

Remove extraneous f prefix

(F541)

requirements/lgpl.txt Outdated Show resolved Hide resolved
ovos_core/intent_services/adapt_service.py Show resolved Hide resolved
@JarbasAl JarbasAl marked this pull request as draft July 20, 2024 18:52
@JarbasAl JarbasAl mentioned this pull request Jul 20, 2024
15 tasks
@JarbasAl JarbasAl added this to the 0.1.0 milestone Jul 22, 2024
@JarbasAl JarbasAl force-pushed the feat/pipeline_plugins_opm branch 2 times, most recently from 5315d9f to eb785e3 Compare October 14, 2024 02:47
subclass pipelines from the OPM placeholder base class

move to maintained ovos-adapt-parser package
@JarbasAl JarbasAl marked this pull request as ready for review October 14, 2024 02:48
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: 4

🧹 Outside diff range and nitpick comments (16)
.github/workflows/build_tests.yml (1)

34-34: Consider moving build tools installation back to its original step

The installation of build tools (python -m pip install build wheel) has been moved from the "Install Build Tools" step to the "Install System Dependencies" step. This change makes the workflow less organized and potentially harder to maintain.

Consider moving this line back to its original position under the "Install Build Tools" step:

- sudo apt install python3-dev swig libssl-dev libfann-dev portaudio19-dev libpulse-dev python3-fann2
- python -m pip install build wheel
+ sudo apt install python3-dev swig libssl-dev libfann-dev portaudio19-dev libpulse-dev python3-fann2

# Under the "Install Build Tools" step
+ python -m pip install build wheel

This will maintain a clearer separation of concerns in the workflow steps.

test/unittests/skills/test_mycroft_skill.py (1)

24-24: Update to OVOS-specific Adapt library

The import statement for IntentBuilder has been changed from adapt.intent to ovos_adapt.intent. This indicates a transition to using an OVOS-specific version of the Adapt library.

This change may have implications for how intents are built and processed throughout the tests and the entire system. Ensure that:

  1. All uses of IntentBuilder in this file and related files are compatible with the OVOS version.
  2. The ovos_adapt library is properly installed and configured in the project environment.
  3. Any differences in behavior between the original Adapt and OVOS Adapt are documented and accounted for in the tests.

Consider adding a comment explaining the reason for this change to help future maintainers understand the context.

ovos_core/intent_services/__init__.py (2)

Line range hint 516-524: Ensure efficient handling of normalized utterances

The change to use padacioso_service aligns with the earlier modifications. The additional handling for normalized utterances can improve intent matching accuracy. However, ensure that this doesn't introduce unnecessary complexity or performance overhead, especially in cases where the normalized utterance is identical to the original.

Consider optimizing the normalized utterance handling:

 def handle_get_padatious(self, message):
     utterance = message.data["utterance"]
     norm = message.data.get('norm_utt', utterance)
-    intent = self.padacioso_service.calc_intent(utterance)
-    if not intent and norm != utterance:
-        intent = self.padacioso_service.calc_intent(norm)
+    intent = self.padacioso_service.calc_intent(utterance)
+    if not intent and norm != utterance:
+        intent = self.padacioso_service.calc_intent(norm)
     if intent:
         intent = intent.__dict__
     self.bus.emit(message.reply("intent.service.padatious.reply",
                                 {"intent": intent}))

This change ensures that we only process the normalized utterance if it's different from the original and the original didn't produce a match, potentially saving unnecessary processing.


Line range hint 1-605: Overall assessment: Improved modularity with potential for optimization

The changes in this file significantly improve the modularity of the intent parsing system by leveraging external packages. This approach can lead to better maintainability and easier updates in the future. However, there are a few key points to consider:

  1. Verify the compatibility and stability of the new external packages (ovos_adapt.opm, ovos_padatious.opm, and padacioso.opm).
  2. Ensure that the fallback mechanism from PadatiousService to PadaciosoService is robust and doesn't introduce unexpected behavior.
  3. Assess the performance impact of the new pipeline configuration, particularly with the addition of PadaciosoService.
  4. Optimize the handling of normalized utterances in the handle_get_padatious method to avoid unnecessary processing.

It's recommended to thoroughly test these changes, particularly focusing on intent matching accuracy and performance across various scenarios. Consider implementing comprehensive unit tests and conducting real-world testing to ensure the system's stability and effectiveness.

To further improve the system's modularity and maintainability, consider:

  1. Implementing a plugin system for intent parsers, allowing for easier addition or removal of parsing services.
  2. Creating an abstract base class for intent parsing services to ensure consistent interfaces across different implementations.
  3. Implementing a configuration-driven approach for defining the intent matching pipeline, allowing for easier customization without code changes.
ovos_core/intent_services/stop_service.py (9)

Line range hint 45-52: Add type hint to the __init__ method for consistency

While type hints are used in other methods, the __init__ method lacks a type hint for the bus parameter. Adding it improves code readability and consistency.

Consider adding the type hint as follows:

 def __init__(self, bus):
+    def __init__(self, bus: MessageBusClient):

Ensure that MessageBusClient is imported:

+from ovos_bus_client import MessageBusClient

Line range hint 55-68: Handle potential exceptions in load_resource_files method

The load_resource_files method performs file I/O operations without exception handling. This could lead to unhandled exceptions if files or directories are missing or unreadable.

Consider adding exception handling to improve robustness:

def load_resource_files(self):
    base = f"{dirname(__file__)}/locale"
    if not os.path.exists(base):
        LOG.warning(f"Locale directory not found: {base}")
        return
    for lang in os.listdir(base):
        lang2 = lang.split("-")[0].lower()
        self._voc_cache[lang2] = {}
        for f in os.listdir(f"{base}/{lang}"):
            file_path = f"{base}/{lang}/{f}"
            try:
                with open(file_path, encoding="utf-8") as fi:
                    lines = [expand_options(l) for l in fi.read().split("\n")
                             if l.strip() and not l.startswith("#")]
                    n = f.split(".", 1)[0]
                    self._voc_cache[lang2][n] = flatten_list(lines)
            except Exception as e:
                LOG.error(f"Error loading vocabulary file {file_path}: {e}")

Line range hint 98-129: Ensure all skills acknowledge the stop request or handle timeouts appropriately

In the _collect_stop_skills method, if some skills fail to respond to the stop.ping, the Event may wait until the timeout is reached. This could delay stop actions unnecessarily.

Consider implementing a maximum wait time per skill and handling unresponsive skills gracefully to improve responsiveness.


Line range hint 132-137: Check if active_skills is empty before proceeding

Before proceeding with skill pings, it's good practice to check if active_skills is not empty to avoid unnecessary processing.

Add a condition to return early if there are no active skills:

if not active_skills:
    return want_stop

This check is already present; ensure it remains after any refactoring.


Line range hint 140-155: Handle missing or unexpected responses in stop_skill method

In the stop_skill method, if wait_for_response returns None, accessing result.data could raise an AttributeError.

Modify the method to handle None responses safely:

def stop_skill(self, skill_id: str, message: Message):
    stop_msg = message.reply(f"{skill_id}.stop")
    result = self.bus.wait_for_response(stop_msg, f"{skill_id}.stop.response")
    if result:
        if 'error' in result.data:
            error_msg = result.data['error']
            LOG.error(f"{skill_id}: {error_msg}")
            return False
        else:
            return result.data.get('result', False)
    else:
        LOG.warning(f"No response from {skill_id} to stop request.")
        return False

149-152: Correct alignment in IntentMatch construction

The parameters in the IntentMatch object are misaligned with the opening parenthesis, which can affect readability.

Adjust the indentation for clarity:

 return IntentMatch(intent_service='Stop',
-                      intent_type=True,
-                      intent_data={"conf": conf},
-                      skill_id=None,
-                      utterance=utterance)
+                   intent_type=True,
+                   intent_data={"conf": conf},
+                   skill_id=None,
+                   utterance=utterance)

163-166: Ensure consistent parameter alignment in IntentMatch

Similar to the previous comment, adjust the indentation of the parameters for better readability.

 return IntentMatch(intent_service='Stop',
-                      intent_type=True,
-                      intent_data={"conf": conf},
-                      skill_id=skill_id,
-                      utterance=utterance)
+                   intent_type=True,
+                   intent_data={"conf": conf},
+                   skill_id=skill_id,
+                   utterance=utterance)

Line range hint 189-198: Simplify conditional logic in match_stop_medium method

The conditional checks for is_stop and is_global_stop can be streamlined for better readability.

Refactor the conditions:

is_stop = self.voc_match(utterance, 'stop', exact=False, lang=lang)
is_global_stop = self.voc_match(utterance, 'global_stop', exact=False, lang=lang) or \
                 (is_stop and not self.get_active_skills(message))

if not is_stop and not is_global_stop:
    return None

return self.match_stop_low(utterances, lang, message)

Line range hint 243-267: Optimize regular expression matching in voc_match method

Compiling regular expressions inside the loop can be inefficient. Pre-compiling the regex patterns can improve performance.

Modify the method to pre-compile patterns:

def voc_match(self, utt: str, voc_filename: str, lang: str,
              exact: bool = False):
    lang = lang.split("-")[0].lower()
    if lang not in self._voc_cache:
        return False

    _vocs = self._voc_cache[lang].get(voc_filename) or []

    if utt and _vocs:
        if exact:
            return any(i.strip() == utt for i in _vocs)
        else:
            patterns = [re.compile(r'.*\b' + re.escape(i) + r'\b.*') for i in _vocs]
            return any(pattern.match(utt) for pattern in patterns)
    return False

Alternatively, store the compiled patterns in a cache to avoid recompiling them on every call.

ovos_core/intent_services/ocp_service.py (3)

37-37: Consider the Order of Base Classes in Multiple Inheritance

The class OCPPipelineMatcher now inherits from both PipelinePlugin and OVOSAbstractApplication. The order of base classes in multiple inheritance affects the Method Resolution Order (MRO). Ensure that the inheritance order aligns with the desired behavior, especially if there are overlapping methods or attributes. Reverse the order if necessary.


Line range hint 631-633: Avoid Using Bare except Clauses

Using bare except statements can catch unintended exceptions, potentially masking bugs and making debugging difficult. It's better practice to catch specific exceptions or at least use except Exception to avoid catching system-exiting exceptions like KeyboardInterrupt or SystemExit.

Apply this diff to catch specific exceptions:

 try:
     # classifier code
-except:
+except Exception as e:
     LOG.exception(f"OCP classifier exception: {query}", exc_info=e)

Similarly, in the is_ocp_query method:

 try:
     # binary classifier code
-except:
+except Exception as e:
     LOG.exception("OCP binary classifier failure", exc_info=e)

Also applies to: 655-657


Line range hint 754-754: Accessing Protected Member _transformer

In OCPFeaturizer.extract_entities, you're accessing ocp_keywords._transformer, which is a protected member (prefixed with an underscore). Accessing protected members from outside the class is generally discouraged as it may lead to fragile code that's harder to maintain.

Consider modifying the KeywordFeaturesVectorizer class to provide a public method or property to access wordlist or perform the extraction without accessing the protected member. This would enhance maintainability and adhere to encapsulation principles.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 4b1505c and e5cceb4.

📒 Files selected for processing (20)
  • .github/workflows/build_tests.yml (1 hunks)
  • .github/workflows/license_tests.yml (1 hunks)
  • mycroft/skills/intent_services/adapt_service.py (1 hunks)
  • ovos_core/intent_services/init.py (2 hunks)
  • ovos_core/intent_services/adapt_service.py (1 hunks)
  • ovos_core/intent_services/commonqa_service.py (2 hunks)
  • ovos_core/intent_services/converse_service.py (1 hunks)
  • ovos_core/intent_services/fallback_service.py (2 hunks)
  • ovos_core/intent_services/ocp_service.py (2 hunks)
  • ovos_core/intent_services/padacioso_service.py (1 hunks)
  • ovos_core/intent_services/padatious_service.py (1 hunks)
  • ovos_core/intent_services/stop_service.py (5 hunks)
  • requirements/lgpl.txt (1 hunks)
  • requirements/requirements.txt (1 hunks)
  • setup.py (2 hunks)
  • test/unittests/common_query/ovos_tskill_fakewiki/init.py (1 hunks)
  • test/unittests/skills/decorator_test_skill.py (1 hunks)
  • test/unittests/skills/test_intent_service.py (1 hunks)
  • test/unittests/skills/test_intent_service_interface.py (1 hunks)
  • test/unittests/skills/test_mycroft_skill.py (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • requirements/requirements.txt
  • test/unittests/common_query/ovos_tskill_fakewiki/init.py
🧰 Additional context used
🪛 Ruff
mycroft/skills/intent_services/adapt_service.py

16-16: ovos_adapt.context.ContextManagerFrame imported but unused

Remove unused import: ovos_adapt.context.ContextManagerFrame

(F401)


17-17: ovos_adapt.engine.IntentDeterminationEngine imported but unused

Remove unused import: ovos_adapt.engine.IntentDeterminationEngine

(F401)


18-18: ovos_workshop.intents.Intent imported but unused

Remove unused import: ovos_workshop.intents.Intent

(F401)


19-19: ovos_adapt.opm.ContextManager imported but unused

Remove unused import

(F401)


19-19: ovos_adapt.opm.AdaptPipeline imported but unused

Remove unused import

(F401)

ovos_core/intent_services/adapt_service.py

2-2: ovos_adapt.opm.AdaptPipeline imported but unused

Remove unused import: ovos_adapt.opm.AdaptPipeline

(F401)

ovos_core/intent_services/padacioso_service.py

2-2: padacioso.opm.PadaciosoPipeline imported but unused

Remove unused import

(F401)


2-2: padacioso.opm.PadaciosoIntent imported but unused

Remove unused import

(F401)

ovos_core/intent_services/padatious_service.py

2-2: ovos_padatious.opm.PadatiousMatcher imported but unused

Remove unused import

(F401)


2-2: ovos_padatious.opm.PadatiousPipeline imported but unused

Remove unused import

(F401)

🔇 Additional comments (33)
requirements/lgpl.txt (2)

1-1: LGTM: Version constraint for ovos_padatious is appropriate.

The version constraint >=0.1.0,<1.0.0 for ovos_padatious is well-defined and follows the suggestion from the previous review. This ensures compatibility while allowing for minor updates.


1-2: Verify the impact of dependency changes.

The changes in this file align with the PR objectives of transitioning to maintained packages. However, it's important to ensure that these changes don't introduce compatibility issues in the project.

Let's verify the usage of the removed and added dependencies:

Please review the output of this script to ensure that:

  1. There are no remaining imports of padatious or padaos.
  2. ovos_padatious is being imported and used in the codebase.

If any inconsistencies are found, additional code changes may be necessary to fully implement this transition.

✅ Verification successful

Action Required: Update Verification Scripts

Please run the following updated shell script to verify the dependency changes:


Dependency Changes Verified Successfully

All removed dependencies (padatious and padaos) are no longer used in the codebase. The new dependency ovos_padatious is correctly imported and utilized in the following files:

  • ovos_core/intent_services/padatious_service.py
  • ovos_core/intent_services/__init__.py
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining usage of removed dependencies and confirm usage of new dependencies.

echo "Checking for any remaining usage of 'padatious':"
rg --type python 'import\s+padatious|from\s+padatious'

echo "Checking for any remaining usage of 'padaos':"
rg --type python 'import\s+padaos|from\s+padaos'

echo "Confirming usage of 'ovos_padatious':"
rg --type python 'import\s+ovos_padatious|from\s+ovos_padatious'

Length of output: 578


Script:

#!/bin/bash
# Description: Check for any remaining usage of removed dependencies and confirm usage of new dependencies.

echo "Checking for any remaining usage of 'padatious':"
rg 'import\s+padatious|from\s+padatious'

echo "Checking for any remaining usage of 'padaos':"
rg 'import\s+padaos|from\s+padaos'

echo "Confirming usage of 'ovos_padatious':"
rg 'import\s+ovos_padatious|from\s+ovos_padatious'

Length of output: 700

mycroft/skills/intent_services/adapt_service.py (2)

16-17: ⚠️ Potential issue

Remove unused imports

The imports of ContextManagerFrame and IntentDeterminationEngine appear to be unused in this file. To maintain a clean codebase, consider removing these imports if they are not needed.

Apply this diff to remove the unused imports:

-from ovos_adapt.context import ContextManagerFrame
-from ovos_adapt.engine import IntentDeterminationEngine
🧰 Tools
🪛 Ruff

16-16: ovos_adapt.context.ContextManagerFrame imported but unused

Remove unused import: ovos_adapt.context.ContextManagerFrame

(F401)


17-17: ovos_adapt.engine.IntentDeterminationEngine imported but unused

Remove unused import: ovos_adapt.engine.IntentDeterminationEngine

(F401)


18-18: ⚠️ Potential issue

Remove unused import and verify AdaptIntent usage

  1. The Intent import from ovos_workshop.intents appears to be unused. Consider removing it to keep the imports clean.

  2. The AdaptIntent class is defined but its usage is not visible in the provided code snippet. Please verify if this class is used elsewhere in the project.

Apply this diff to remove the unused import:

-from ovos_workshop.intents import IntentBuilder, Intent
+from ovos_workshop.intents import IntentBuilder

Run the following script to check for usage of the AdaptIntent class:

If the script returns no results, consider removing the AdaptIntent class or adding a comment explaining its purpose if it's intended for future use.

Also applies to: 22-25

✅ Verification successful

Remove unused Intent import

The Intent import from ovos_workshop.intents in adapt_service.py is not used and can be safely removed to keep the imports clean.

- from ovos_workshop.intents import IntentBuilder, Intent
+ from ovos_workshop.intents import IntentBuilder
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for usage of AdaptIntent in the project

# Test: Search for AdaptIntent usage
echo "Searching for AdaptIntent usage:"
rg --type python "AdaptIntent"

Length of output: 467


Script:

#!/bin/bash
# Description: Check for usage of AdaptIntent in Python files within the project

# Test: Search for AdaptIntent usage in .py files
echo "Searching for AdaptIntent usage in Python files:"
rg "AdaptIntent" --glob "*.py"

Length of output: 888

🧰 Tools
🪛 Ruff

18-18: ovos_workshop.intents.Intent imported but unused

Remove unused import: ovos_workshop.intents.Intent

(F401)

test/unittests/skills/decorator_test_skill.py (2)

Line range hint 1-32: LGTM: Rest of the file is consistent and well-structured.

The remaining parts of the file, including the usage of OVOSSkill, decorators, and the implementation of TestSkill, are consistent with the project's architecture and the purpose of this test file. No further changes are necessary.


15-15: Import statement updated to use ovos_adapt.

The import statement has been changed from adapt.intent to ovos_adapt.intent. This change aligns with the PR objective of transitioning to maintained packages, specifically the ovos-adapt-parser.

To ensure consistency across the codebase, let's verify if all other occurrences of adapt.intent have been updated:

✅ Verification successful

Import statements successfully updated to ovos_adapt.intent.

All instances of from adapt.intent import IntentBuilder have been replaced with from ovos_adapt.intent import IntentBuilder across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining instances of 'adapt.intent'

# Test: Search for 'adapt.intent'. Expect: No results, indicating all instances have been updated.
rg --type python 'from adapt.intent import'

# Test: Search for 'ovos_adapt.intent'. Expect: Results showing updated import statements.
rg --type python 'from ovos_adapt.intent import'

Length of output: 158


Script:

#!/bin/bash
# Description: Check for any remaining instances of 'adapt.intent' and confirm 'ovos_adapt.intent' imports

# Search for 'from adapt.intent import' in Python files
fd --extension py --type f | xargs grep -H 'from adapt.intent import'

# Search for 'from ovos_adapt.intent import' in Python files
fd --extension py --type f | xargs grep -H 'from ovos_adapt.intent import'

Length of output: 530

.github/workflows/build_tests.yml (1)

33-33: LGTM: Addition of python3-fann2 dependency

The addition of python3-fann2 as a system dependency aligns with the PR objectives of transitioning to maintained packages. This change is appropriate and necessary for the new functionality being introduced.

.github/workflows/license_tests.yml (2)

42-43: Indentation correction looks good

The indentation of the "Print report" step has been corrected, ensuring it's properly aligned under the steps section. This change improves the readability and correctness of the workflow file.


40-40: Verify the necessity of new package exclusions

The exclusion list has been updated to include ovos-adapt-parser and ovos-padatious. This change aligns with the PR objectives, which mention transitioning to these maintained packages.

To ensure these packages are indeed part of the project dependencies, run the following script:

setup.py (3)

60-66: LGTM: Well-structured plugin entry points.

The PLUGIN_ENTRY_POINT variable is a well-structured list of entry points for various pipeline plugins. This addition aligns with the PR objectives of enhancing pipeline plugins within the OpenVoiceOS ecosystem. The naming convention is consistent, and the referenced service classes appear to be part of the ovos_core.intent_services module.


98-98: LGTM: Proper integration of pipeline plugins.

The addition of the 'opm.pipeline' entry point in the setup() function correctly integrates the PLUGIN_ENTRY_POINT variable. This change enables the registration of the defined plugins under the 'opm.pipeline' namespace, which is consistent with the PR objectives of enhancing pipeline functionality.


Line range hint 60-98: Summary: Successful integration of pipeline plugins

The changes to setup.py effectively integrate the new pipeline plugins into the package setup. The addition of the PLUGIN_ENTRY_POINT variable and its inclusion in the entry_points dictionary of the setup() function are well-implemented. These modifications align with the PR objectives of transitioning to maintained packages and enhancing pipeline plugins within the OpenVoiceOS ecosystem.

The changes provide a clear and organized way to register the new plugins, which should facilitate easier management and extension of the pipeline functionality in the future.

test/unittests/skills/test_intent_service_interface.py (2)

Line range hint 1-186: No further changes required in this file.

I've reviewed the rest of the file, and it appears that no additional changes are needed. The tests, particularly in the KeywordIntentRegistrationTest class, continue to use IntentBuilder in the same way as before. This suggests that the interface of IntentBuilder from ovos_adapt.intent is compatible with the previous implementation.

However, to ensure complete compatibility, please run the tests after making this change to verify that all test cases still pass successfully.


3-3: LGTM! Verify compatibility with the new IntentBuilder.

The import statement has been updated to use ovos_adapt.intent instead of adapt.intent, which aligns with the PR objectives of transitioning to maintained packages. This change looks good.

To ensure that the new IntentBuilder from ovos_adapt.intent is fully compatible with the existing tests, please run the following verification script:

This script will help ensure that the new IntentBuilder class has the same interface and that all tests still pass with the updated import.

test/unittests/skills/test_intent_service.py (2)

22-22: LGTM! Verify ContextManager functionality.

The import statement has been updated to use ovos_adapt.opm instead of ovos_core.intent_services.adapt_service. This change aligns with the PR objectives of transitioning to maintained packages.

To ensure that this change doesn't affect the functionality of the tests, please run the following script:

#!/bin/bash
# Description: Verify that ContextManager is correctly imported and used in the tests.

# Test: Check if ContextManager is imported correctly
rg --type python "from ovos_adapt.opm import ContextManager" test/unittests/skills/test_intent_service.py

# Test: Verify usage of ContextManager in ContextManagerTest
rg --type python -A 10 "class ContextManagerTest" test/unittests/skills/test_intent_service.py

22-22: Run test suite to ensure no regressions.

While the import change doesn't require modifications to the existing tests, it's crucial to run the entire test suite to ensure that the new ovos_adapt.opm package maintains the same API and functionality as the previous ovos_core.intent_services.adapt_service.

Please run the test suite and confirm that all tests pass:

test/unittests/skills/test_mycroft_skill.py (1)

Line range hint 1-1000: Verify test compatibility with OVOS Adapt

While no other lines in the file have been explicitly changed, the modification of the IntentBuilder import could potentially affect the behavior of tests using this class.

Please ensure that:

  1. All tests in this file run successfully with the new OVOS Adapt library.
  2. The behavior of IntentBuilder in OVOS Adapt matches the expected behavior in these tests.
  3. If there are any differences in behavior or new features in OVOS Adapt, consider adding new tests to cover these aspects.

To verify, run the following command from the project root:

If any tests fail, please review the output and make necessary adjustments to ensure compatibility with OVOS Adapt.

✅ Verification successful

All Tests Passed Successfully

The tests in test/unittests/skills/test_mycroft_skill.py ran successfully with the new OVOS Adapt library. No issues were found related to the IntentBuilder import changes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Run the tests and capture the output
python -m unittest test/unittests/skills/test_mycroft_skill.py > test_output.txt 2>&1

# Check for any failures or errors
if grep -q "FAILED" test_output.txt || grep -q "ERROR" test_output.txt; then
  echo "Tests failed. Please review the output in test_output.txt"
  exit 1
else
  echo "All tests passed successfully."
  exit 0
fi

Length of output: 209

ovos_core/intent_services/__init__.py (3)

60-62: Ensure proper fallback mechanism for PadatiousService

The conditional initialization of PadatiousService with a fallback to PadaciosoService is a good approach for handling potential import issues or configuration preferences. However, make sure that the PadaciosoService is fully compatible with the PadatiousService interface to avoid any runtime issues.

To confirm the compatibility between PadatiousService and PadaciosoService, run the following script:

#!/bin/bash
# Check for common methods between PadatiousService and PadaciosoService
python3 -c "
from ovos_padatious.opm import PadatiousPipeline
from padacioso.opm import PadaciosoPipeline

padatious_methods = set(dir(PadatiousPipeline))
padacioso_methods = set(dir(PadaciosoPipeline))

common_methods = padatious_methods.intersection(padacioso_methods)
print('Common methods:', common_methods)

missing_in_padacioso = padatious_methods - padacioso_methods
if missing_in_padacioso:
    print('Methods in PadatiousService but not in PadaciosoService:', missing_in_padacioso)
"

17-17: Verify compatibility with new external packages

The changes in imports from local modules to external packages (ovos_adapt.opm, ovos_padatious.opm, and padacioso.opm) indicate a shift towards more modular architecture. This can improve maintainability and allow for easier updates. However, ensure that these external packages are properly maintained and fully compatible with the current system.

To confirm the availability and version compatibility of these packages, run the following script:

Also applies to: 23-23


Line range hint 232-238: Verify performance impact of pipeline changes

The addition of PadaciosoService to the pipeline and the conditional handling of PadatiousService availability improve the flexibility of the intent matching process. However, it's crucial to ensure that these changes don't negatively impact performance or accuracy.

To assess the performance impact, consider implementing and running a benchmark test:

Also, consider adding unit tests to verify the accuracy of intent matching with the new pipeline configuration.

Also applies to: 246-247

ovos_core/intent_services/padatious_service.py (1)

2-2: Verify the necessity of the backward compatibility imports

The static analysis tools indicate that PadatiousMatcher and PadatiousPipeline (aliased as PadatiousService) are imported but unused in this file. Since these imports are under the # backwards compat imports section, they might be intended for external use to maintain backward compatibility.

Please verify if these imports are necessary. If they are not required, consider removing them to clean up the code.

To confirm whether these imports are accessed elsewhere in the codebase, you can run the following script:

✅ Verification successful

Verified: The backward compatibility imports (PadatiousMatcher and PadatiousService) are used in multiple locations within the codebase.

  • test/unittests/skills/test_utterance_intents.py
  • ovos_core/intent_services/__init__.py
  • mycroft/skills/intent_services/padatious_service.py
  • mycroft/skills/intent_services/__init__.py
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if 'PadatiousMatcher' and 'PadatiousService' are imported from 'padatious_service' elsewhere.

# Test: Search for import statements that import these classes from 'padatious_service'.
# Expect: Instances where these classes are imported from this module.

rg --type python -A 2 $'from ovos_core.intent_services.padatious_service import (PadatiousMatcher|PadatiousService)'

Length of output: 148


Script:

#!/bin/bash
# Description: Check if 'PadatiousMatcher' and 'PadatiousService' are imported from 'padatious_service' elsewhere.

# Find all Python files and search for the specific import statements.
fd --extension py | xargs rg 'from ovos_core\.intent_services\.padatious_service import (PadatiousMatcher|PadatiousService)'

Length of output: 813

🧰 Tools
🪛 Ruff

2-2: ovos_padatious.opm.PadatiousMatcher imported but unused

Remove unused import

(F401)


2-2: ovos_padatious.opm.PadatiousPipeline imported but unused

Remove unused import

(F401)

ovos_core/intent_services/padacioso_service.py (1)

2-2: Unused Imports Still Present

As previously noted, the imports PadaciosoPipeline and PadaciosoIntent are unused according to the static analysis tool and should be removed to clean up the code.

🧰 Tools
🪛 Ruff

2-2: padacioso.opm.PadaciosoPipeline imported but unused

Remove unused import

(F401)


2-2: padacioso.opm.PadaciosoIntent imported but unused

Remove unused import

(F401)

ovos_core/intent_services/fallback_service.py (4)

17-17: Importing the 'time' module for timeout functionality

The addition of import time is appropriate and necessary for implementing the time constraints in the _collect_fallback_skills method.


23-23: Importing 'IntentMatch' and 'PipelinePlugin' for plugin integration

The import of IntentMatch and PipelinePlugin from ovos_plugin_manager.templates.pipeline is correct and essential for integrating the fallback service into the plugin architecture.


31-31: Updating 'FallbackService' to inherit from 'PipelinePlugin'

Modifying the FallbackService class to inherit from PipelinePlugin enhances modularity and aligns it with the plugin-based architecture, facilitating better integration and extensibility.


40-40: Initializing the superclass with the fallback configuration

Calling super().__init__(self.fallback_config) correctly initializes the superclass with the fallback configuration, ensuring that the PipelinePlugin base class is properly set up with the necessary settings.

ovos_core/intent_services/stop_service.py (2)

10-10: Import of IntentMatch and PipelinePlugin is appropriate

The addition of the import statement for IntentMatch and PipelinePlugin aligns with the new pipeline architecture and is necessary for the class modifications below.


17-17: Class StopService now correctly inherits from PipelinePlugin

Updating the StopService class to inherit from PipelinePlugin integrates it into the pipeline framework, enhancing modularity and consistency with other pipeline plugins.

ovos_core/intent_services/commonqa_service.py (3)

9-9: Importing Configuration is appropriate

The import statement from ovos_config.config import Configuration is necessary for accessing configuration settings later in the code, such as in the __init__ method.


11-11: Importing IntentMatch and PipelinePlugin is necessary

The import statement from ovos_plugin_manager.templates.pipeline import IntentMatch, PipelinePlugin is required for the class definition and functionality. IntentMatch is used for intent matching, and PipelinePlugin is now a parent class of CommonQAService.


33-38: 🛠️ Refactor suggestion

Consider using super() for proper initialization in multiple inheritance

The class CommonQAService now inherits from both PipelinePlugin and OVOSAbstractApplication. In the __init__ method, you're explicitly calling the __init__ methods of both parent classes:

def __init__(self, bus, config=None):
    OVOSAbstractApplication.__init__(
        self, bus=bus, skill_id="common_query.openvoiceos",
        resources_dir=f"{dirname(__file__)}")
    PipelinePlugin.__init__(self, config)

Explicitly invoking parent __init__ methods can lead to issues in multiple inheritance scenarios due to the method resolution order (MRO). To ensure proper initialization and maintainability, consider using super().__init__() which respects the MRO and properly initializes all parent classes.

Here's a suggested refactor:

 class CommonQAService(PipelinePlugin, OVOSAbstractApplication):
     def __init__(self, bus, config=None):
-        OVOSAbstractApplication.__init__(
-            self, bus=bus, skill_id="common_query.openvoiceos",
-            resources_dir=f"{dirname(__file__)}")
-        PipelinePlugin.__init__(self, config)
+        super().__init__(bus=bus, skill_id="common_query.openvoiceos",
+                         resources_dir=f"{dirname(__file__)}", config=config)

This change utilizes super().__init__() to handle the initialization, which is the recommended practice in Python for multiple inheritance. It assumes that both OVOSAbstractApplication and PipelinePlugin properly implement cooperative multiple inheritance by using super() in their own __init__ methods.

Please verify that the parent classes are compatible with this approach. If they are not designed to work with super(), and explicit calls are necessary, ensure that the initialization order is correct and document the reasoning to aid future maintainers.

ovos_core/intent_services/converse_service.py (2)

10-10: Imports are appropriate for the new class hierarchy

The addition of IntentMatch and PipelinePlugin imports is necessary for the updated class inheritance and intent matching functionalities.


Line range hint 161-168: Ensure shutdown method properly calls base class shutdown if necessary

If PipelinePlugin defines a shutdown method, consider calling super().shutdown() within the shutdown method to ensure proper resource cleanup.

Run the following script to check if PipelinePlugin defines a shutdown method:

ovos_core/intent_services/stop_service.py Show resolved Hide resolved
ovos_core/intent_services/converse_service.py Show resolved Hide resolved
ovos_core/intent_services/ocp_service.py Outdated Show resolved Hide resolved
JarbasAl added a commit to OpenVoiceOS/OVOS-workshop that referenced this pull request Oct 14, 2024
JarbasAl added a commit to OpenVoiceOS/OVOS-workshop that referenced this pull request Oct 14, 2024
JarbasAl added a commit to OpenVoiceOS/OVOS-workshop that referenced this pull request Oct 14, 2024
* fix:finish extracting intent classes from adapt package

ports usage of "excludes"

needed for OpenVoiceOS/ovos-core#527

companion to OpenVoiceOS/ovos-adapt-pipeline-plugin#6

* fix test

* simplify

* add a test
@JarbasAl JarbasAl marked this pull request as draft October 14, 2024 05:46
Copy link

codecov bot commented Oct 14, 2024

Codecov Report

Attention: Patch coverage is 87.27273% with 14 lines in your changes missing coverage. Please review.

Project coverage is 72.93%. Comparing base (23f0bab) to head (a422ff2).
Report is 15 commits behind head on dev.

Files with missing lines Patch % Lines
ovos_core/intent_services/__init__.py 88.11% 12 Missing ⚠️
ovos_core/intent_services/adapt_service.py 0.00% 1 Missing ⚠️
ovos_core/intent_services/commonqa_service.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #527      +/-   ##
==========================================
- Coverage   75.33%   72.93%   -2.41%     
==========================================
  Files          15       15              
  Lines        3094     1633    -1461     
==========================================
- Hits         2331     1191    -1140     
+ Misses        763      442     -321     
Flag Coverage Δ
end2end 53.39% <80.90%> (?)
unittests 51.68% <87.27%> (-23.66%) ⬇️

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.

@JarbasAl JarbasAl marked this pull request as ready for review October 14, 2024 20:24
@JarbasAl JarbasAl merged commit 2931ada into dev Oct 14, 2024
5 of 6 checks passed
@JarbasAl JarbasAl deleted the feat/pipeline_plugins_opm branch October 14, 2024 23:56
This was referenced Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature packaging dependency updates or packaging changes refactor code refactor without functional changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants