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:move code to dependencies #571

Merged
merged 31 commits into from
Nov 2, 2024
Merged

fix:move code to dependencies #571

merged 31 commits into from
Nov 2, 2024

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Oct 18, 2024

update imports and requirements for latest pipeline plugins signature

updates typing and versions from #570 without dragging the move to dynamic plugins

companion PRS from new requirements versions:

the number of bus messages per interaction has been reduced and optimized, should improve latency by a few ms

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced intent handling with updated match types for improved skill interactions.
    • Streamlined audio playback control in the CommonPlaySkill.
    • Introduced a new stopping mechanism for audio playback.
  • Bug Fixes

    • Adjusted expected message flows in various tests to reflect recent changes in skill activation and deactivation.
  • Dependencies

    • Updated version constraints for several skills, including ovos-padatious, ovos-skill-application-launcher, and others to ensure compatibility with newer features.
  • Tests

    • Refined test cases to align with the latest message handling logic and improve accuracy in validation, including adjustments for blacklisted skills and intents.
  • Documentation

    • Updated internal documentation to reflect changes in method signatures and expected behaviors.
  • Deprecations

    • Marked several methods in the SkillManager class as deprecated, indicating they are no longer intended for use.

Copy link

coderabbitai bot commented Oct 18, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request introduces significant changes across multiple files, primarily focusing on the transition from IntentMatch to PipelineMatch. This includes updates to method signatures, imports, and internal logic in various services such as IntentService, StopService, ConverseService, and FallbackService. Additionally, several dependencies have updated version constraints in the requirements files. Tests have been adjusted to reflect changes in expected message flows, particularly regarding blacklisted skills and intents.

Changes

File Path Change Summary
ovos_core/intent_services/__init__.py Updated imports and method signatures; replaced IntentMatch with PipelineMatch and IntentHandlerMatch. Converted several methods to static. Introduced _handle_deactivate method and modified logic in _emit_match_message, disambiguate_lang, and handle_utterance. Marked some methods as deprecated.
ovos_core/intent_services/stop_service.py Replaced IntentMatch with PipelineMatch in method signatures for match_stop_high, match_stop_medium, and match_stop_low. Removed IntentMatch import.
requirements/lgpl.txt Updated ovos_padatious dependency version from >=0.1.3,<1.0.0 to >=1.0.3,<2.0.0.
requirements/requirements.txt Updated version constraints for multiple dependencies: padacioso, ovos-adapt-parser, ovos_ocp_pipeline_plugin, ovos-common-query-pipeline-plugin, ovos-plugin-manager, and ovos-workshop.
test/unittests/test_intent_service.py Updated imports and removed test_shutdown method. Replaced ContextManager with IntentContextManager and initialized FakeBus.
ovos_core/intent_services/converse_service.py Replaced IntentMatch with PipelineMatch in converse_with_skills method signature. Updated active_skills property setter.
ovos_core/intent_services/fallback_service.py Replaced IntentMatch with PipelineMatch in multiple method signatures, including _fallback_range, high_prio, medium_prio, and low_prio.
test/end2end/routing/test_sched.py Modified test_no_session method to update expected message sequence and assertions related to message types.
test/end2end/routing/test_session.py Updated test_no_session methods in TestRouting and TestOCPRouting to reflect changes in expected message flow.
mycroft/skills/common_play_skill.py Updated __handle_play_start method to use a new stop() method for audio stopping logic.
test/end2end/session/test_blacklist.py Modified expected message sequences in tests related to blacklisted skills and intents.
test/end2end/session/test_converse.py Removed assertions for specific message types and updated indices in TestSessions.
test/end2end/session/test_fallback.py Removed assertions related to activation messages in TestFallback and TestFallbackTimeout.
test/end2end/session/test_get_response.py Updated expected message types in various test cases related to the get_response functionality.
test/end2end/session/test_ocp.py Removed expected messages related to activation from TestOCPPipeline and TestLegacyCPSPipeline.
test/end2end/session/test_sched.py Updated expected message types in TestSessions class.
test/end2end/session/test_session.py Updated expected message types in TestSessions class.
test/end2end/session/test_stop.py Modified expected message types in TestSessions for test_old_stop and test_new_stop.
requirements/skills-audio.txt Updated ovos-skill-boot-finished and ovos-skill-dictation dependencies to newer versions.
requirements/skills-desktop.txt Updated ovos-skill-application-launcher dependency to a newer version.
requirements/skills-essential.txt Updated versions for several skills, including ovos-skill-fallback-unknown, ovos-skill-personal, ovos-skill-date-time, ovos-skill-hello-world, and ovos-skill-spelling.
requirements/skills-internet.txt Updated skill-ovos-fallback-chatgpt package version.
requirements/skills-media.txt Updated ovos-skill-pyradios dependency version.
requirements/skills-gui.txt Updated ovos-skill-homescreen dependency version.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant IntentService
    participant FallbackService
    participant PipelineMatch

    User->>IntentService: Send Intent
    IntentService->>PipelineMatch: Process Intent
    PipelineMatch-->>IntentService: Return Match
    IntentService->>FallbackService: Handle Fallback
    FallbackService-->>IntentService: Return Fallback Response
    IntentService-->>User: Respond with Result
Loading

Possibly related PRs

  • fix:log_spam #566: This PR modifies the IntentService class in ovos_core/intent_services/__init__.py, which is directly related to the changes made in the main PR that also affects this file, particularly in handling deprecated properties and restructuring imports.
  • fix:fallback match #572: This PR focuses on the fallback_service.py, which is relevant as the main PR also involves changes to the IntentService class that may interact with fallback handling logic.

Suggested labels

packaging

Suggested reviewers

  • goldyfruit
  • j1nx
  • mikejgray

🐇 In the code we hop and play,
With PipelineMatch here to stay.
Old imports now have gone away,
As skills and tests align today.
Let's celebrate this code ballet! 🎉


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.

@github-actions github-actions bot added fix and removed fix labels Oct 18, 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: 5

🧹 Outside diff range and nitpick comments (1)
requirements/requirements.txt (1)

6-13: Summary: Dependency updates align with PR objectives but require careful verification.

The updates to padacioso, ovos-adapt-parser, ovos_ocp_pipeline_plugin, ovos-common-query-pipeline-plugin, and ovos-plugin-manager align with the PR objectives to update requirements related to the latest pipeline plugins signature. However, the major version bumps for most of these dependencies necessitate careful verification to ensure compatibility with the existing codebase.

Recommendations:

  1. Run the provided verification scripts for each major version bump.
  2. Review the changelogs or release notes for each updated dependency to understand any breaking changes or new features.
  3. Consider updating the project's documentation to reflect these dependency changes and any necessary code adjustments.
  4. If possible, run the project's test suite to catch any immediate issues caused by these updates.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between a26b7b7 and e38f895.

📒 Files selected for processing (7)
  • ovos_core/intent_services/init.py (12 hunks)
  • ovos_core/intent_services/converse_service.py (3 hunks)
  • ovos_core/intent_services/fallback_service.py (4 hunks)
  • ovos_core/intent_services/stop_service.py (9 hunks)
  • requirements/lgpl.txt (1 hunks)
  • requirements/requirements.txt (1 hunks)
  • test/unittests/test_intent_service.py (1 hunks)
🧰 Additional context used
🪛 Ruff
ovos_core/intent_services/__init__.py

286-286: Ambiguous variable name: l

(E741)

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

2-2: Verify if fann2 version constraint is still appropriate

While the fann2 dependency remains unchanged, it's worth considering if it needs an update in light of the other changes in the project.

Please verify:

  1. Is the current version constraint (>=1.0.7, < 1.1.0) still appropriate for the project's needs?
  2. Are there any newer versions of fann2 that might offer improvements or bug fixes relevant to this project?
  3. Is this version of fann2 compatible with the updated version of ovos_padatious?

Run the following script to check the latest version of fann2 and its compatibility:

#!/bin/bash
# Description: Check the latest version of fann2 and its compatibility

# Test: Check the latest version of fann2 available on PyPI
echo "Latest version of fann2 on PyPI:"
pip index versions fann2 | head -n 1

# Test: Search for fann2 usage in the project
echo "Searching for fann2 usage in the project:"
rg --type python -i 'from fann2 import|import fann2'

# Note: Review these results manually to determine if an update is necessary

1-1: Significant version update for ovos_padatious - verify compatibility

The update to ovos_padatious>=1.0.2,<2.0.0 is a major version bump, which often implies breaking changes or significant new features. This aligns with the PR objective of updating requirements related to the latest pipeline plugins signature.

To ensure smooth integration:

  1. Verify that this version is compatible with the rest of the project.
  2. Check if any code changes are required to accommodate this update.
  3. Review the changelog or release notes for ovos_padatious to understand the changes introduced in this major version update.

Run the following script to check for potential incompatibilities:

requirements/requirements.txt (5)

13-13: LGTM: Minor version update for ovos-plugin-manager.

The update from >=0.0.26,<1.0.0 to >=0.5.0,<1.0.0 for ovos-plugin-manager is a minor version bump. This change aligns with the PR objectives and should maintain backwards compatibility.


8-8: Verify compatibility with major version update of ovos_ocp_pipeline_plugin.

The update from >=0.1.3,<1.0.0 to >=1.0.0,<2.0.0 for ovos_ocp_pipeline_plugin is a major version bump. This change aligns with the PR objectives to update requirements related to the latest pipeline plugins signature, but it's crucial to ensure compatibility with the rest of the codebase.

Please run the following script to check for any potential breaking changes:

#!/bin/bash
# Description: Check for usage of ovos_ocp_pipeline_plugin and potential breaking changes

# Test: Search for ovos_ocp_pipeline_plugin usage
echo "Searching for ovos_ocp_pipeline_plugin usage:"
rg --type python 'from ovos_ocp_pipeline_plugin import' -A 5

# Test: Check for any deprecated or removed features
echo "Checking for potential breaking changes:"
rg --type python 'ovos_ocp_pipeline_plugin\.' -A 5

9-9: Verify compatibility with major version update of ovos-common-query-pipeline-plugin.

The update from >=0.1.4,<1.0.0 to >=1.0.0,<2.0.0 for ovos-common-query-pipeline-plugin is a major version bump. This change aligns with the PR objectives to update requirements related to the latest pipeline plugins signature, but it's crucial to ensure compatibility with the rest of the codebase.

Please run the following script to check for any potential breaking changes:

#!/bin/bash
# Description: Check for usage of ovos-common-query-pipeline-plugin and potential breaking changes

# Test: Search for ovos-common-query-pipeline-plugin usage
echo "Searching for ovos-common-query-pipeline-plugin usage:"
rg --type python 'from ovos_common_query_pipeline_plugin import' -A 5

# Test: Check for any deprecated or removed features
echo "Checking for potential breaking changes:"
rg --type python 'ovos_common_query_pipeline_plugin\.' -A 5

7-7: Verify compatibility with major version update of ovos-adapt-parser.

The update from >=0.1.3,<1.0.0 to >=1.0.2,<2.0.0 for ovos-adapt-parser is a major version bump. This change aligns with the PR objectives, but it's crucial to ensure compatibility with the rest of the codebase.

Please run the following script to check for any potential breaking changes:

#!/bin/bash
# Description: Check for usage of ovos-adapt-parser and potential breaking changes

# Test: Search for ovos-adapt-parser usage
echo "Searching for ovos-adapt-parser usage:"
rg --type python 'from ovos_adapt_parser import' -A 5

# Test: Check for any deprecated or removed features
echo "Checking for potential breaking changes:"
rg --type python 'ovos_adapt_parser\.' -A 5

6-6: Verify compatibility with major version update of padacioso.

The update from >=0.2.4,<1.0.0 to >=1.0.0,<2.0.0 for padacioso is a major version bump. This change aligns with the PR objectives, but it's crucial to ensure compatibility with the rest of the codebase.

Please run the following script to check for any potential breaking changes:

test/unittests/test_intent_service.py (3)

Line range hint 1-323: Summary: Changes align with PR objectives, verifications recommended.

The changes in this file align with the PR objectives of updating imports and requirements related to the latest pipeline plugins signature. The main changes include:

  1. Updated import statement for ContextManager.
  2. Configuration update in the test_shutdown method to disable Padatious.

Both changes have been approved, but it's recommended to run the suggested verification scripts to ensure these changes don't negatively impact other parts of the codebase or the test assertions.


Line range hint 323-323: LGTM! Verify the test assertion for removed message types.

The IntentService instantiation now includes a configuration to disable Padatious. This change aligns with the PR objective of updating requirements related to the latest pipeline plugins signature.

To ensure the test assertion for removed message types is still accurate, run the following script:

#!/bin/bash
# Description: Verify the set of removed message types in the test_shutdown method

# Test: Extract the set of removed message types from the test
removed_types=$(rg --no-line-number -o "'[^']+'" test/unittests/test_intent_service.py | sort | uniq)

# Test: Compare with the actual removed types in the IntentService shutdown method
actual_removed=$(rg --no-line-number -o "self\.bus\.remove\('[^']+'" ovos_core/intent_services/intent_service.py | sed "s/self\.bus\.remove('//" | sort | uniq)

echo "Removed types in test:"
echo "$removed_types"
echo "Actual removed types:"
echo "$actual_removed"
echo "Differences:"
diff <(echo "$removed_types") <(echo "$actual_removed")

Please review the output and update the test assertion if necessary.


18-18: LGTM! Verify impact on other parts of the codebase.

The import statement has been updated to use IntentContextManager from ovos_bus_client.session instead of ContextManager from ovos_adapt.opm. This change maintains backwards compatibility by using an alias.

To ensure this change doesn't affect other parts of the codebase, run the following script:

✅ Verification successful

Further Verification Required: Missing File Detected

The script encountered an error locating ovos_core/intent_services/intent_service.py. Please verify the existence and correct path of this file in the repository.


Action Required: Correct the File Search Command

The previous script used an incorrect flag with fd. Please use the corrected command below to search for intent_service.py:


Further Verification Needed: Inspect intent_service.py for ContextManager Usage

To ensure the import change is correctly applied in mycroft/skills/intent_service.py, please run the following script:


Verified: No remaining references to ContextManager found

The import change has been successfully applied. There are no remaining imports or usages of ContextManager from ovos_adapt.opm in mycroft/skills/intent_service.py.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining imports of ContextManager from ovos_adapt.opm

# Test: Search for old import statement
rg --type python "from ovos_adapt.opm import ContextManager"

# Test: Search for usage of ContextManager without import
rg --type python "ContextManager" -g '!test/unittests/test_intent_service.py'

Length of output: 13229


Script:

#!/bin/bash
# Description: Search for the 'intent_service.py' file to verify its existence and correct path.

fd --type f --name "intent_service.py"

Length of output: 289


Script:

#!/bin/bash
# Description: Search for the 'intent_service.py' file to verify its existence and correct path.

fd "intent_service.py" --type f

Length of output: 102


Script:

#!/bin/bash
# Description: Verify the import and usage of ContextManager in 'mycroft/skills/intent_service.py'

# Check for the new import statement
rg "from ovos_bus_client.session import IntentContextManager as ContextManager" mycroft/skills/intent_service.py

# Check for any old import statements
rg "from ovos_adapt.opm import ContextManager" mycroft/skills/intent_service.py

# Check for usage of ContextManager in the file
rg "ContextManager" mycroft/skills/intent_service.py

Length of output: 249

ovos_core/intent_services/fallback_service.py (7)

24-24: Import Pipeline Classes for Fallback Integration

The addition of PipelineMatch and PipelinePlugin imports is appropriate for integrating pipeline functionality into the FallbackService.


28-28: Import FallbackMode for Enhanced Configuration Handling

Including FallbackMode from ovos_workshop.permissions enables better handling of fallback modes as per the configuration settings.


Line range hint 165-176: Update Return Type to Optional[PipelineMatch] in _fallback_range

The return type of _fallback_range has been updated to Optional[PipelineMatch], reflecting the transition from IntentMatch to PipelineMatch. The docstring has also been correctly updated to match this change.


201-204: Update Return Type to Optional[PipelineMatch] in high_prio

The return type of high_prio has been updated to Optional[PipelineMatch], aligning with the changes made in _fallback_range.


206-209: Update Return Type to Optional[PipelineMatch] in medium_prio

The return type of medium_prio has been changed to Optional[PipelineMatch], ensuring consistency across the fallback methods.


211-214: Update Return Type to Optional[PipelineMatch] in low_prio

The return type of low_prio has been updated to Optional[PipelineMatch], matching the updates in the other priority methods.


196-198: Verify if match_data Should Be Populated in PipelineMatch

The PipelineMatch is being returned with an empty match_data dictionary. Please verify whether match_data should include relevant match details to ensure proper downstream processing in the pipeline.

To investigate how PipelineMatch instances are typically constructed, you can run the following script to find usages and see how match_data is populated:

ovos_core/intent_services/stop_service.py (11)

6-6: Approved: Importing 'closest_match' from 'langcodes'

The import of closest_match is necessary for the _get_closest_lang method used in language matching.


12-12: Approved: Import of 'PipelineMatch' and 'PipelinePlugin'

The addition of PipelineMatch and PipelinePlugin imports aligns with the updated class inheritance and method return types.


116-116: Approved: Updated return type in 'match_stop_high' method

The method signature now returns Optional[PipelineMatch], reflecting the transition to the new pipeline architecture.


125-125: Approved: Updated docstring to reflect new return type

The docstring correctly states that the method returns a PipelineMatch if handled, otherwise None.


145-148: Approved: Correct instantiation of 'PipelineMatch'

The PipelineMatch is properly constructed with the necessary arguments when emitting a global stop.


158-161: Approved: Return statement updated to use 'PipelineMatch'

The method returns a PipelineMatch instance with appropriate data when a skill successfully handles the stop request.


164-164: Approved: Updated return type in 'match_stop_medium' method

The method signature has been updated to return Optional[PipelineMatch], consistent with the pipeline changes.


174-174: Approved: Updated docstring to reflect new return type

The docstring now accurately describes the return value as a PipelineMatch if handled.


204-204: Approved: Updated return type in 'match_stop_low' method

The method now correctly returns Optional[PipelineMatch], aligning with the updated architecture.


213-213: Approved: Updated docstring to reflect new return type

The docstring correctly states that the method returns a PipelineMatch if handled, otherwise None.


237-240: Approved: Return statement uses 'PipelineMatch' with appropriate data

The PipelineMatch is instantiated correctly when a skill handles the stop request.

ovos_core/intent_services/converse_service.py (3)

10-10: Imported PipelineMatch and PipelinePlugin

The added import statement brings in PipelineMatch and PipelinePlugin, which are necessary for the updated return types and class inheritance.


14-14: Imported ConverseMode and ConverseActivationMode

These imports are required for handling conversation permissions and activation modes within the ConverseService.


315-315: Updated return type to Optional[PipelineMatch]

The method converse_with_skills now returns an Optional[PipelineMatch] instead of Optional[IntentMatch], aligning with the updated pipeline structure.

ovos_core/intent_services/__init__.py (2)

621-624: ⚠️ Potential issue

Verify attribute availability in both match types

When accessing match.match_type and match.match_data, ensure these attributes are present in both IntentHandlerMatch and PipelineMatch instances. Missing attributes might lead to exceptions during execution.

Refer to the previous comments regarding attribute checks and modifications to ensure consistency across match types.


399-402: ⚠️ Potential issue

Ensure all match types have the required attributes

Since match can be an instance of either IntentHandlerMatch or PipelineMatch, it's important to ensure that both classes have the match_data and match_type attributes used in this method. Accessing missing attributes could lead to AttributeError at runtime.

To verify that both classes have the necessary attributes, you can run:

ovos_core/intent_services/stop_service.py Outdated Show resolved Hide resolved
ovos_core/intent_services/converse_service.py Show resolved Hide resolved
ovos_core/intent_services/__init__.py Show resolved Hide resolved
ovos_core/intent_services/__init__.py Show resolved Hide resolved
ovos_core/intent_services/__init__.py Outdated Show resolved Hide resolved
@github-actions github-actions bot added fix and removed fix labels Oct 18, 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 (4)
ovos_core/intent_services/stop_service.py (1)

204-204: LGTM: Method updated to use PipelineMatch. Consider removing redundant comment.

The match_stop_low method has been successfully updated to use PipelineMatch instead of IntentMatch. The changes are consistent throughout the method, and the existing functionality has been preserved.

However, the comment on line 239 ("emit instead of intent message") is now redundant and potentially confusing. Consider removing this comment to improve code clarity.

Also applies to: 213-213, 237-240, 244-248

ovos_core/intent_services/__init__.py (3)

286-293: LGTM with a minor suggestion: Improve variable naming in list comprehension.

The use of standardize_lang_tag instead of get_full_lang_code is a good improvement in language handling. However, the single-letter variable l in the list comprehension could be made more descriptive for better readability.

Consider renaming the variable for clarity:

-valid_langs = [standardize_lang_tag(l) for l in valid_langs]
+valid_langs = [standardize_lang_tag(lang) for lang in valid_langs]
🧰 Tools
🪛 Ruff

286-286: Ambiguous variable name: l

(E741)


Line range hint 376-402: LGTM with a suggestion: Update docstring to reflect new parameter type.

The changes to _emit_match_message to handle both IntentHandlerMatch and PipelineMatch objects are good improvements, expanding the flexibility of the intent matching system.

Please update the docstring to reflect the new parameter type:

     def _emit_match_message(self, match: Union[IntentHandlerMatch, PipelineMatch], message: Message):
         """Update the message data with the matched utterance information and
         activate the corresponding skill if available.

         Args:
-            match (IntentHandlerMatch): The matched utterance object.
+            match (Union[IntentHandlerMatch, PipelineMatch]): The matched utterance object.
             message (Message): The messagebus data.
         """

486-488: LGTM with a suggestion: Add a safety check for attribute access.

The change to use match.match_type instead of match.intent_type aligns with the new Union[IntentHandlerMatch, PipelineMatch] type. However, there's a potential for AttributeError if match doesn't have a match_type attribute.

Consider adding a safety check:

-                    if isinstance(match, IntentHandlerMatch) and match.match_type in sess.blacklisted_intents:
+                    if isinstance(match, IntentHandlerMatch) and hasattr(match, 'match_type') and match.match_type in sess.blacklisted_intents:

This change will prevent potential AttributeErrors if match doesn't have a match_type attribute.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e38f895 and c6450c7.

📒 Files selected for processing (2)
  • ovos_core/intent_services/init.py (12 hunks)
  • ovos_core/intent_services/stop_service.py (9 hunks)
🧰 Additional context used
🪛 Ruff
ovos_core/intent_services/__init__.py

286-286: Ambiguous variable name: l

(E741)

🔇 Additional comments (10)
ovos_core/intent_services/stop_service.py (6)

12-12: LGTM: Import statement updated correctly.

The addition of PipelineMatch and PipelinePlugin imports is consistent with the changes in the method signatures and aligns with the PR objective of updating imports related to the latest pipeline plugins signature.


116-116: LGTM: Method updated to use PipelineMatch.

The match_stop_high method has been successfully updated to use PipelineMatch instead of IntentMatch. The changes are consistent throughout the method, and the existing functionality has been preserved.

Also applies to: 125-125, 145-148, 158-161


164-164: LGTM: Method signature updated correctly.

The match_stop_medium method signature has been properly updated to return Optional[PipelineMatch]. The method body remains unchanged, which is appropriate as it delegates to match_stop_low for the actual matching logic.

Also applies to: 174-174


Line range hint 21-21: Verify: Should StopService inherit from PipelinePlugin?

The PR objectives mention updating to the latest pipeline plugins signature, but the StopService class doesn't seem to inherit from PipelinePlugin. Please verify if this is intentional or if the class should be updated to inherit from PipelinePlugin.

If it should inherit from PipelinePlugin, consider updating the class definition as follows:

class StopService(PipelinePlugin):

This change would align the class with the latest pipeline plugins signature mentioned in the PR objectives.


Line range hint 1-290: Overall: Changes are consistent, but verify complete alignment with pipeline plugins signature

The changes in this file consistently update the usage of IntentMatch to PipelineMatch across all relevant methods. The existing functionality is preserved while adapting to the new structure. These updates align with the PR objectives of updating imports and requirements related to the latest pipeline plugins signature.

However, to ensure full alignment with the latest pipeline plugins signature:

  1. Verify if the StopService class should inherit from PipelinePlugin.
  2. Double-check if there are any other pipeline-related updates required in this file or elsewhere in the project.

These verifications will help ensure that the PR fully meets its objectives and that the StopService is correctly integrated with the latest pipeline plugin architecture.


145-148: 🛠️ Refactor suggestion

Suggestion: Include 'conf' in 'match_data' for consistency

For consistency with other return statements, consider including the confidence score conf in the match_data field when returning PipelineMatch after emitting the global stop.

Apply this change:

 return PipelineMatch(handled=True,
-                     match_data={},
+                     match_data={"conf": conf},
                      skill_id=None,
                      utterance=utterance)

This change will make the return value consistent with other PipelineMatch instances in the class.

ovos_core/intent_services/__init__.py (4)

15-18: LGTM: Import and type hint updates enhance functionality and type safety.

The addition of Union from typing and the import of OCPPipelineMatcher suggest an expansion of intent matching capabilities. The updated type hint for _emit_match_message improves type safety. These changes are beneficial for maintainability and extensibility of the codebase.

Also applies to: 29-33


Line range hint 353-373: LGTM: Improved session validation logic.

The conversion of _validate_session to a static method and the use of standardize_lang_tag for language standardization are good improvements. These changes enhance the consistency of language handling throughout the codebase.


Line range hint 562-600: LGTM: Improved context handling with static methods.

The conversion of handle_add_context, handle_remove_context, and handle_clear_context to static methods is a good improvement. This change enhances code organization and potentially improves performance by eliminating unnecessary instance method calls.


621-624: LGTM: Consistent updates to intent handling.

The changes in handle_get_intent to use match.match_type and match.match_data are consistent with the earlier updates to the matching system. These modifications ensure that the method works correctly with the new Union[IntentHandlerMatch, PipelineMatch] type.

Copy link

codecov bot commented Oct 18, 2024

Codecov Report

Attention: Patch coverage is 71.73913% with 52 lines in your changes missing coverage. Please review.

Project coverage is 72.86%. Comparing base (23f0bab) to head (d16a335).
Report is 47 commits behind head on dev.

Files with missing lines Patch % Lines
ovos_core/intent_services/__init__.py 74.30% 37 Missing ⚠️
ovos_core/skill_manager.py 66.66% 4 Missing ⚠️
ovos_core/intent_services/adapt_service.py 0.00% 2 Missing ⚠️
ovos_core/intent_services/commonqa_service.py 0.00% 2 Missing ⚠️
ovos_core/intent_services/ocp_service.py 0.00% 2 Missing ⚠️
ovos_core/intent_services/padacioso_service.py 0.00% 2 Missing ⚠️
ovos_core/intent_services/padatious_service.py 0.00% 2 Missing ⚠️
ovos_core/intent_services/stop_service.py 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #571      +/-   ##
==========================================
- Coverage   75.33%   72.86%   -2.48%     
==========================================
  Files          15       15              
  Lines        3094     1537    -1557     
==========================================
- Hits         2331     1120    -1211     
+ Misses        763      417     -346     
Flag Coverage Δ
end2end 56.34% <68.47%> (?)
unittests 49.12% <55.43%> (-26.22%) ⬇️

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 18, 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 (8)
mycroft/skills/intent_services/__init__.py (2)

Line range hint 1-14: Summary of changes and potential impact

The changes in this file reflect a significant restructuring of the project's dependencies and import paths. Overall, these changes appear to improve modularity and organization by moving services and classes to more specific packages.

Key points:

  1. Services like AdaptService, PadaciosoService, and CommonQAService are now imported from their respective packages rather than from ovos_core.intent_services.
  2. IntentMatch is now imported from ovos_plugin_manager.templates.pipeline.
  3. Intent-related classes (AdaptIntent, IntentBuilder, Intent) are now imported from ovos_workshop.intents.
  4. A fallback mechanism is implemented for PadatiousService.

These changes may have the following impacts:

  1. Improved modularity and separation of concerns in the project structure.
  2. Potential need for updates in documentation and dependent code to reflect new import paths.
  3. Possible subtle changes in behavior due to the fallback mechanism for PadatiousService.

Recommendations:

  1. Thoroughly test the system to ensure all services work as expected with the new import structure.
  2. Update project documentation to reflect the new package structure and import paths.
  3. Review and update any code that depends on these imports throughout the project.
  4. Consider addressing the unused imports flagged by the static analysis tool.

To maintain the benefits of this restructuring:

  1. Establish clear guidelines for managing dependencies and import structures in the project.
  2. Regularly review and update dependencies to ensure they align with the project's architectural goals.
  3. Consider implementing automated tests to verify the correct functioning of all services after structural changes.
🧰 Tools
🪛 Ruff

1-1: ovos_core.intent_services.fallback_service.FallbackService imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


2-2: ovos_core.intent_services.converse_service.ConverseService imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


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

(F401)


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

(F401)


5-5: ovos_commonqa.opm.CommonQAService imported but unused

(F401)


6-6: ovos_plugin_manager.templates.pipeline.IntentMatch imported but unused

(F401)


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

(F401)


7-7: ovos_workshop.intents.IntentBuilder imported but unused

(F401)


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

(F401)


10-10: ovos_padatious.opm.PadatiousMatcher imported but unused; consider using importlib.util.find_spec to test for availability

(F401)


Remove Unused PadatiousMatcher Import

The import of PadatiousMatcher in mycroft/skills/intent_services/__init__.py does not appear to be used within the module. Consider removing it to clean up the codebase.

Additionally, please manually verify the compatibility between PadatiousService and PadaciosoService to ensure consistent behavior across different installations.

🔗 Analysis chain

Line range hint 10-14: Approve fallback mechanism and suggest verification

The try-except block provides a good fallback mechanism if ovos_padatious is not installed. This approach ensures that the code can still function even if the preferred package is unavailable.

However, there are a few points to consider:

  1. Verify that PadaciosoService (used as a fallback) is fully compatible with PadatiousService to ensure consistent behavior across different installations.

  2. The import of PadatiousMatcher appears to be unused. Consider removing it if it's not needed elsewhere in the module.

  3. To ensure the fallback mechanism works as intended and to verify the usage of PadatiousService, run the following script:

  4. If PadatiousMatcher is needed, verify its usage with:

Based on the results, update the imports accordingly.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check the usage of PadatiousService and PadaciosoService

echo "Checking usage of PadatiousService:"
rg --type python "PadatiousService" -C 3

echo "Checking usage of PadaciosoService:"
rg --type python "PadaciosoService" -C 3

Length of output: 400


Script:

#!/bin/bash
# Description: Check the usage of PadatiousMatcher

echo "Checking usage of PadatiousMatcher:"
rg --type python "PadatiousMatcher" -C 3

Length of output: 152


Script:

#!/bin/bash
# Description: Check the usage of PadatiousService and PadaciosoService

echo "Checking usage of PadatiousService:"
rg --type py "PadatiousService" -C 3

echo "Checking usage of PadaciosoService:"
rg --type py "PadaciosoService" -C 3

Length of output: 4979


Script:

#!/bin/bash
# Description: Check the usage of PadatiousMatcher

echo "Checking usage of PadatiousMatcher:"
rg --type py "PadatiousMatcher" -C 3

Length of output: 1351

🧰 Tools
🪛 Ruff

1-1: ovos_core.intent_services.fallback_service.FallbackService imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


2-2: ovos_core.intent_services.converse_service.ConverseService imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


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

(F401)


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

(F401)


5-5: ovos_commonqa.opm.CommonQAService imported but unused

(F401)


6-6: ovos_plugin_manager.templates.pipeline.IntentMatch imported but unused

(F401)


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

(F401)


7-7: ovos_workshop.intents.IntentBuilder imported but unused

(F401)


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

(F401)


10-10: ovos_padatious.opm.PadatiousMatcher imported but unused; consider using importlib.util.find_spec to test for availability

(F401)

test/unittests/test_intent_service.py (2)

134-142: LGTM! Consider using a list comprehension for message deserialization.

The changes to use FakeBus and the custom message handler look good. They provide a more standardized and efficient way to mock the bus and track emitted messages.

Consider using a list comprehension for message deserialization in the on_msg function:

-        def on_msg(m):
-            self.bus.emitted_msgs.append(Message.deserialize(m))
+        self.bus.on("message", lambda m: self.bus.emitted_msgs.append(Message.deserialize(m)))

This change would make the code more concise and Pythonic.


192-192: LGTM! Consider refactoring repeated assertions.

The changes to use self.bus.emitted_msgs[-1] are consistent across all test methods and align with the new FakeBus implementation.

To reduce code repetition and improve maintainability, consider refactoring the repeated assertions into a helper method:

def assert_last_emitted_message(self, expected_data):
    self.assertEqual(self.bus.emitted_msgs[-1].data, expected_data)

Then, you can use this helper method in your tests:

self.assert_last_emitted_message({'intent': None})

This refactoring would make the tests more concise and easier to maintain.

Also applies to: 202-202, 210-210, 218-218, 233-233, 245-245

ovos_core/intent_services/__init__.py (4)

286-286: Improve readability by renaming the variable 'l'

The use of 'l' as a variable name can be confusing as it may be mistaken for the number '1' or capital 'I'. Consider renaming it to a more descriptive name, such as 'lang_code'.

Apply this diff to improve readability:

-valid_langs = [standardize_lang_tag(l) for l in valid_langs]
+valid_langs = [standardize_lang_tag(lang_code) for lang_code in valid_langs]
🧰 Tools
🪛 Ruff

286-286: Ambiguous variable name: l

(E741)


Line range hint 376-402: LGTM: Updated _emit_match_message to handle new match types

The changes in this method successfully accommodate both IntentHandlerMatch and PipelineMatch types, aligning with the transition mentioned in the PR summary. This improves the flexibility of the method.

Consider updating the method's docstring to reflect the new parameter type:

-    def _emit_match_message(self, match: IntentHandlerMatch, message: Message):
+    def _emit_match_message(self, match: Union[IntentHandlerMatch, PipelineMatch], message: Message):
         """Update the message data with the matched utterance information and
         activate the corresponding skill if available.

         Args:
-            match (IntentHandlerMatch): The matched utterance object.
+            match (Union[IntentHandlerMatch, PipelineMatch]): The matched utterance object.
             message (Message): The messagebus data.
         """

486-488: LGTM: Improved type checking in handle_utterance

The changes enhance type safety by using isinstance checks and make the blacklisted intents check more specific to IntentHandlerMatch types.

For consistency with the previous checks, consider using hasattr to check for the match_type attribute:

-    if isinstance(match, IntentHandlerMatch) and match.match_type in sess.blacklisted_intents:
+    if isinstance(match, IntentHandlerMatch) and hasattr(match, 'match_type') and match.match_type in sess.blacklisted_intents:

This change would make the code more robust against potential future changes in the IntentHandlerMatch class.


621-624: LGTM: Improved intent data handling in handle_get_intent

The changes in handle_get_intent method align well with the new PipelineMatch and IntentHandlerMatch structures. The intent data is now more consistently structured and includes valuable additional information.

For added robustness, consider adding a check for the existence of match_data:

     if match:
-        if match.match_type:
+        if match.match_type and hasattr(match, 'match_data'):
             intent_data = match.match_data
             intent_data["intent_name"] = match.match_type
             intent_data["intent_service"] = pipeline

This change would prevent potential AttributeError if match_data is not present in future match objects.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c6450c7 and 8343309.

📒 Files selected for processing (4)
  • mycroft/skills/intent_services/init.py (1 hunks)
  • mycroft/skills/intent_services/adapt_service.py (1 hunks)
  • ovos_core/intent_services/init.py (13 hunks)
  • test/unittests/test_intent_service.py (9 hunks)
🧰 Additional context used
🪛 Ruff
mycroft/skills/intent_services/__init__.py

1-1: ovos_core.intent_services.fallback_service.FallbackService imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


2-2: ovos_core.intent_services.converse_service.ConverseService imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


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

(F401)


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

(F401)


5-5: ovos_commonqa.opm.CommonQAService imported but unused

(F401)


6-6: ovos_plugin_manager.templates.pipeline.IntentMatch imported but unused

(F401)


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

(F401)


7-7: ovos_workshop.intents.IntentBuilder imported but unused

(F401)


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

(F401)


10-10: ovos_padatious.opm.PadatiousMatcher imported but unused; consider using importlib.util.find_spec to test for availability

(F401)

mycroft/skills/intent_services/adapt_service.py

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

Remove unused import: ovos_adapt.opm.AdaptPipeline

(F401)


19-19: ovos_bus_client.session.IntentContextManagerFrame imported but unused

Remove unused import

(F401)


20-20: ovos_bus_client.session.IntentContextManager imported but unused

Remove unused import

(F401)

ovos_core/intent_services/__init__.py

286-286: Ambiguous variable name: l

(E741)

🔇 Additional comments (12)
mycroft/skills/intent_services/__init__.py (3)

5-7: Approve updated import paths and suggest documentation review

The changes to import paths for CommonQAService, IntentMatch, AdaptIntent, IntentBuilder, and Intent are good. They align with the overall restructuring of the project, improving modularity and organization.

The move of AdaptIntent, IntentBuilder, and Intent from a local import to ovos_workshop.intents is particularly noteworthy and may require updates to documentation or dependent code.

To address the static analysis hints about unused imports and ensure these changes don't break existing functionality, let's verify their usage:

#!/bin/bash
# Description: Check if the imported classes are used in the codebase

echo "Checking usage of CommonQAService:"
rg --type python "CommonQAService" -C 3

echo "Checking usage of IntentMatch:"
rg --type python "IntentMatch" -C 3

echo "Checking usage of AdaptIntent:"
rg --type python "AdaptIntent" -C 3

echo "Checking usage of IntentBuilder:"
rg --type python "IntentBuilder" -C 3

echo "Checking usage of Intent:"
rg --type python "Intent" -C 3

If these classes are used elsewhere in the codebase, we can safely ignore the static analysis warnings. If they're not used, consider removing these imports or adding them to __all__ if they're meant to be part of the public API.

Additionally, please review and update any documentation that references these classes to reflect their new import paths.

🧰 Tools
🪛 Ruff

5-5: ovos_commonqa.opm.CommonQAService imported but unused

(F401)


6-6: ovos_plugin_manager.templates.pipeline.IntentMatch imported but unused

(F401)


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

(F401)


7-7: ovos_workshop.intents.IntentBuilder imported but unused

(F401)


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

(F401)


3-4: Approve updated import paths for AdaptService and PadaciosoService

The changes to import AdaptService from ovos_adapt.opm and PadaciosoService from padacioso.opm are good. This restructuring likely improves modularity and separation of concerns in the project.

The use of aliases (AdaptPipeline as AdaptService and PadaciosoPipeline as PadaciosoService) maintains backward compatibility, which is a good practice.

To address the static analysis hints about unused imports and ensure these changes don't break existing functionality, let's verify their usage:

#!/bin/bash
# Description: Check if AdaptService and PadaciosoService are used in the codebase

echo "Checking usage of AdaptService:"
rg --type python "AdaptService" -C 3

echo "Checking usage of PadaciosoService:"
rg --type python "PadaciosoService" -C 3

If these services are used elsewhere in the codebase, we can safely ignore the static analysis warnings. If they're not used, consider removing these imports or adding them to __all__ if they're meant to be part of the public API.

🧰 Tools
🪛 Ruff

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

(F401)


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

(F401)


1-2: Approve specific imports for FallbackService and ConverseService

The changes to import FallbackService and ConverseService from their specific submodules in ovos_core.intent_services are good. This approach makes the imports more explicit and can potentially improve code organization.

To address the static analysis hints about unused imports, let's verify their usage:

If these services are indeed used elsewhere in the codebase, we can safely ignore the static analysis warnings. If they're not used, consider removing these imports or adding them to __all__ if they're meant to be part of the public API.

✅ Verification successful

Confirmed usage of FallbackService and ConverseService

The shell script results confirm that both FallbackService and ConverseService are actively used in the codebase. The static analysis warnings about unused imports are false positives and can be safely ignored.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if FallbackService and ConverseService are used in the codebase

echo "Checking usage of FallbackService:"
rg --type python "FallbackService" -C 3

echo "Checking usage of ConverseService:"
rg --type python "ConverseService" -C 3

Length of output: 370


Script:

#!/bin/bash
# Description: Corrected script to check if FallbackService and ConverseService are used in the codebase

echo "Checking usage of FallbackService:"
rg "FallbackService" --type py -C 3

echo "Checking usage of ConverseService:"
rg "ConverseService" --type py -C 3

Length of output: 10789

🧰 Tools
🪛 Ruff

1-1: ovos_core.intent_services.fallback_service.FallbackService imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


2-2: ovos_core.intent_services.converse_service.ConverseService imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

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

18-20: Verify the necessity of newly added imports

The following imports have been added but are flagged as unused by static analysis tools:

  1. AdaptPipeline as AdaptService from ovos_adapt.opm
  2. IntentContextManagerFrame as ContextManagerFrame from ovos_bus_client.session
  3. IntentContextManager as ContextManager from ovos_bus_client.session

Please verify if these imports are necessary for the changes implemented in this file or other parts of the codebase. If they are not required, consider removing them to keep the imports clean and avoid potential confusion.

If you confirm that these imports are indeed unnecessary, I can assist in removing them. Would you like me to propose a fix?

To verify the usage of these imports across the codebase, you can run the following script:

This script will search for occurrences of these imported names across all Python files in the repository. The results will help determine if these imports are used elsewhere in the codebase.

🧰 Tools
🪛 Ruff

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

Remove unused import: ovos_adapt.opm.AdaptPipeline

(F401)


19-19: ovos_bus_client.session.IntentContextManagerFrame imported but unused

Remove unused import

(F401)


20-20: ovos_bus_client.session.IntentContextManager imported but unused

Remove unused import

(F401)

test/unittests/test_intent_service.py (5)

159-159: LGTM! Consistent with new FakeBus usage.

The change to use self.bus.emitted_msgs[-1] is consistent with the new FakeBus implementation and simplifies the code.


170-170: LGTM! Consistent with new FakeBus usage.

The change to use self.bus.emitted_msgs[-1] is consistent with the new FakeBus implementation and the changes in other test methods.


181-181: LGTM! Consistent with new FakeBus usage.

The change to use self.bus.emitted_msgs[-1] is consistent with the new FakeBus implementation and the changes in other test methods.


Line range hint 1-258: Overall, the changes look good and align with the PR objectives.

The updates to the test file test/unittests/test_intent_service.py are well-implemented and consistent. The transition to FakeBus improves the testing approach and aligns with the project's evolution. The changes in import statements and test methods are coherent and maintain the functionality of the tests.

A few suggestions for further improvement:

  1. Consider using a list comprehension for message deserialization in the setUp method.
  2. Refactor the repeated assertions into a helper method to reduce code repetition and improve maintainability.

These minor improvements would enhance the code quality and make it more Pythonic.


18-18: LGTM! Verify usage of new imports.

The import changes look good. The ContextManager import has been updated, and FakeBus has been added. These changes align with the PR objectives of updating imports.

Please run the following script to verify the usage of these new imports:

Also applies to: 23-23

✅ Verification successful

Import changes verified successfully.

The old import from ovos_adapt.opm import ContextManager has been successfully removed. The new imports IntentContextManager and FakeBus are correctly implemented and utilized across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify usage of new imports

# Test: Check for any remaining old imports of ContextManager
rg --type python "from ovos_adapt.opm import ContextManager"

# Test: Verify usage of IntentContextManager
rg --type python "IntentContextManager"

# Test: Verify usage of FakeBus
rg --type python "FakeBus"

Length of output: 222


Script:

#!/bin/bash
# Description: Verify usage of new imports with corrected file type

# Test: Check for any remaining old imports of ContextManager
rg --type py "from ovos_adapt.opm import ContextManager"

# Test: Verify usage of IntentContextManager
rg --type py "IntentContextManager"

# Test: Verify usage of FakeBus
rg --type py "FakeBus"

Length of output: 1785


Script:

#!/bin/bash
# Description: Confirm removal of old imports and correct usage of new imports

# Test: Ensure no remaining old imports of ContextManager from ovos_adapt.opm
rg --type py "^from ovos_adapt\.opm import ContextManager$"

# Test: Verify all imports of IntentContextManager are from ovos_bus_client.session
rg --type py "^from ovos_bus_client\.session import IntentContextManager"

# Test: Verify all imports of FakeBus are from ovos_utils.fakebus
rg --type py "^from ovos_utils\.fakebus import FakeBus"

Length of output: 521

ovos_core/intent_services/__init__.py (3)

15-33: LGTM: Import changes align with PR objectives

The import changes reflect the updates to the latest pipeline plugins signature as mentioned in the PR objectives. The new imports and reorganization of existing ones improve the code structure and dependencies.


532-532: LGTM: Improved language handling in handle_register_vocab

The addition of the lang parameter to _adapt_service.register_vocabulary enhances multi-language support by ensuring the correct language is used when registering vocabulary.


Line range hint 562-600: LGTM: Improved session handling in context methods

The changes to handle_add_context, handle_remove_context, and handle_clear_context methods are well-implemented:

  1. Converting them to static methods improves the design by reducing coupling.
  2. Using SessionManager for session handling aligns with best practices and likely improves consistency across the codebase.

These changes contribute to better maintainability and potentially easier testing of these methods.

update imports and requirements for latest pipeline plugins signature
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: 2

🧹 Outside diff range and nitpick comments (7)
mycroft/skills/intent_services/__init__.py (4)

1-2: Consider addressing unused imports.

The static analysis tool indicates that FallbackService and ConverseService are imported but not used in this file. Consider one of the following actions:

  1. If these services are intended to be part of the public API of this module, add them to the __all__ list.
  2. If they are imported for convenience in other parts of the codebase, consider adding a comment explaining this intention.
  3. If they are truly unused, consider removing these imports to keep the codebase clean.
🧰 Tools
🪛 Ruff

1-1: ovos_core.intent_services.fallback_service.FallbackService imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


2-2: ovos_core.intent_services.converse_service.ConverseService imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


6-6: Consider addressing unused IntentMatch import.

The import of IntentMatch has been updated to come from ovos_plugin_manager.templates.pipeline, which aligns with the PR objectives. However, the static analysis tool indicates that this import is unused in this file. Consider one of the following actions:

  1. If IntentMatch is intended to be part of the public API of this module, add it to the __all__ list.
  2. If it is imported for convenience in other parts of the codebase, consider adding a comment explaining this intention.
  3. If it is truly unused, consider removing this import to keep the codebase clean.
🧰 Tools
🪛 Ruff

6-6: ovos_plugin_manager.templates.pipeline.IntentMatch imported but unused

(F401)


7-7: Consider addressing unused imports from ovos_workshop.intents.

The import of Intent, AdaptIntent, and IntentBuilder has been updated to come from ovos_workshop.intents, which aligns with the PR objectives. However, the static analysis tool indicates that these imports are unused in this file. Consider the following actions:

  1. If these classes are intended to be part of the public API of this module, add them to the __all__ list.
  2. If they are imported for convenience in other parts of the codebase, consider adding a comment explaining this intention.
  3. If they are truly unused, consider removing these imports to keep the codebase clean.

Additionally, note that Intent is imported twice (once as AdaptIntent and once as Intent). This might be intentional, but it's worth verifying if both imports are necessary.

🧰 Tools
🪛 Ruff

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

(F401)


7-7: ovos_workshop.intents.IntentBuilder imported but unused

(F401)


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

(F401)


Line range hint 1-14: Overall import updates look good, but consider a general cleanup.

The changes to the import statements align well with the PR objectives of updating to the latest pipeline plugins signature. The new import paths reflect the restructuring of the codebase and the transition to using the latest versions of various services.

However, there's a consistent pattern of unused imports throughout the file. To improve code cleanliness and maintainability, consider performing a general cleanup of the imports:

  1. Review each import and determine if it's necessary for this file or if it's imported for use in other parts of the codebase.
  2. For imports that are part of the public API of this module, add them to the __all__ list.
  3. For imports that are used elsewhere but not in this file, consider adding a comment explaining their purpose.
  4. Remove any truly unused imports.

This cleanup will make the file's purpose clearer and reduce potential confusion for future developers working on this code.

🧰 Tools
🪛 Ruff

1-1: ovos_core.intent_services.fallback_service.FallbackService imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


2-2: ovos_core.intent_services.converse_service.ConverseService imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


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

(F401)


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

(F401)


5-5: ovos_commonqa.opm.CommonQAService imported but unused

(F401)


6-6: ovos_plugin_manager.templates.pipeline.IntentMatch imported but unused

(F401)


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

(F401)


7-7: ovos_workshop.intents.IntentBuilder imported but unused

(F401)


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

(F401)


10-10: ovos_padatious.opm.PadatiousMatcher imported but unused; consider using importlib.util.find_spec to test for availability

(F401)

ovos_core/intent_services/__init__.py (3)

286-286: Improve variable naming for better readability

While the change to standardize_lang_tag is good, the use of the single-letter variable l in the list comprehension can be improved for better readability. Consider renaming it to a more descriptive name like lang_code.

Apply this diff to enhance code clarity:

-valid_langs = [standardize_lang_tag(l) for l in valid_langs]
+valid_langs = [standardize_lang_tag(lang_code) for lang_code in valid_langs]
🧰 Tools
🪛 Ruff

286-286: Ambiguous variable name: l

(E741)


Line range hint 376-402: LGTM! Improved handling of different match types

The changes to _emit_match_message reflect a more flexible intent matching system that can handle both IntentHandlerMatch and PipelineMatch objects. The new checks ensure appropriate handling for each type of match.

Consider updating the method's docstring to reflect the new parameter type:

     def _emit_match_message(self, match: Union[IntentHandlerMatch, PipelineMatch], message: Message):
         """Update the message data with the matched utterance information and
         activate the corresponding skill if available.

         Args:
-            match (IntentHandlerMatch): The matched utterance object.
+            match (Union[IntentHandlerMatch, PipelineMatch]): The matched utterance object.
             message (Message): The messagebus data.
         """

486-488: LGTM! Improved blacklist checking for IntentHandlerMatch

The addition of the isinstance(match, IntentHandlerMatch) check ensures that the blacklist check is only performed for IntentHandlerMatch objects, which is appropriate as PipelineMatch objects might not have a match_type attribute.

For improved clarity, consider using the hasattr function to check for the match_type attribute:

-                    if isinstance(match, IntentHandlerMatch) and match.match_type in sess.blacklisted_intents:
+                    if hasattr(match, 'match_type') and match.match_type in sess.blacklisted_intents:

This change would make the code more robust against potential future changes in the IntentHandlerMatch or PipelineMatch classes.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 8343309 and b994db3.

📒 Files selected for processing (9)
  • mycroft/skills/intent_services/init.py (1 hunks)
  • mycroft/skills/intent_services/adapt_service.py (1 hunks)
  • ovos_core/intent_services/init.py (13 hunks)
  • ovos_core/intent_services/converse_service.py (3 hunks)
  • ovos_core/intent_services/fallback_service.py (4 hunks)
  • ovos_core/intent_services/stop_service.py (9 hunks)
  • requirements/lgpl.txt (1 hunks)
  • requirements/requirements.txt (1 hunks)
  • test/unittests/test_intent_service.py (9 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • ovos_core/intent_services/stop_service.py
  • requirements/lgpl.txt
  • requirements/requirements.txt
🧰 Additional context used
🪛 Ruff
mycroft/skills/intent_services/__init__.py

1-1: ovos_core.intent_services.fallback_service.FallbackService imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


2-2: ovos_core.intent_services.converse_service.ConverseService imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


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

(F401)


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

(F401)


5-5: ovos_commonqa.opm.CommonQAService imported but unused

(F401)


6-6: ovos_plugin_manager.templates.pipeline.IntentMatch imported but unused

(F401)


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

(F401)


7-7: ovos_workshop.intents.IntentBuilder imported but unused

(F401)


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

(F401)


10-10: ovos_padatious.opm.PadatiousMatcher imported but unused; consider using importlib.util.find_spec to test for availability

(F401)

mycroft/skills/intent_services/adapt_service.py

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

Remove unused import: ovos_adapt.opm.AdaptPipeline

(F401)


19-19: ovos_bus_client.session.IntentContextManagerFrame imported but unused

Remove unused import

(F401)


20-20: ovos_bus_client.session.IntentContextManager imported but unused

Remove unused import

(F401)

ovos_core/intent_services/__init__.py

286-286: Ambiguous variable name: l

(E741)

🔇 Additional comments (19)
mycroft/skills/intent_services/__init__.py (2)

3-5: Verify correct versions and consider addressing unused imports.

The import paths for AdaptService, PadaciosoService, and CommonQAService have been updated, which aligns with the PR objectives. However, the static analysis tool indicates these imports are unused in this file. Consider the following:

  1. Verify that the imported versions match the ones specified in the companion PRs mentioned in the PR description.
  2. If these services are intended to be part of the public API of this module, add them to the __all__ list.
  3. If they are imported for convenience in other parts of the codebase, consider adding a comment explaining this intention.
  4. If they are truly unused, consider removing these imports to keep the codebase clean.

To verify the correct versions are being imported, you can run:

🧰 Tools
🪛 Ruff

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

(F401)


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

(F401)


5-5: ovos_commonqa.opm.CommonQAService imported but unused

(F401)


Line range hint 9-14: Consider addressing unused PadatiousMatcher import and verify fallback import.

The import of PadatiousService has been updated to first try importing from ovos_padatious.opm, with a fallback to ovos_core.intent_services.padacioso_service. This change aligns with the PR objectives and provides backward compatibility. However, there are a couple of points to consider:

  1. The static analysis tool indicates that PadatiousMatcher is imported but unused. If it's not needed, consider removing it from the import statement.

  2. Verify that the fallback import is still necessary. If ovos_padatious is now a required dependency, you might be able to simplify this import by removing the try-except block.

To verify if ovos_padatious is installed and its version, you can run:

If ovos_padatious is always expected to be present, consider simplifying the import to:

from ovos_padatious.opm import PadatiousPipeline as PadatiousService
🧰 Tools
🪛 Ruff

1-1: ovos_core.intent_services.fallback_service.FallbackService imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


2-2: ovos_core.intent_services.converse_service.ConverseService imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


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

(F401)


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

(F401)


5-5: ovos_commonqa.opm.CommonQAService imported but unused

(F401)


6-6: ovos_plugin_manager.templates.pipeline.IntentMatch imported but unused

(F401)


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

(F401)


7-7: ovos_workshop.intents.IntentBuilder imported but unused

(F401)


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

(F401)


10-10: ovos_padatious.opm.PadatiousMatcher imported but unused; consider using importlib.util.find_spec to test for availability

(F401)

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

18-20: Review import changes and verify usage

The import changes align with the PR objectives of updating to the latest pipeline plugins signature. However, there are a few points to consider:

  1. The transition from ovos_adapt to ovos_bus_client for context management is consistent with the intended updates.

  2. The static analysis tool suggests that these imports are unused:

    • AdaptPipeline (aliased as AdaptService)
    • IntentContextManagerFrame (aliased as ContextManagerFrame)
    • IntentContextManager (aliased as ContextManager)

Please verify if these imports are used elsewhere in the file. If they are indeed unused, consider removing them to keep the imports clean. Run the following script to check for their usage:

  1. The alias AdaptService for AdaptPipeline might indicate a refactoring intention. Ensure this aligns with the overall project direction.

If these imports are confirmed to be unused, you can remove them as follows:

-from ovos_adapt.opm import AdaptPipeline as AdaptService
-from ovos_bus_client.session import IntentContextManagerFrame as ContextManagerFrame, \
-    IntentContextManager as ContextManager
✅ Verification successful

Remove unused import statements

The imports AdaptService, ContextManagerFrame, and ContextManager are not used anywhere in adapt_service.py. Removing these unused imports will help keep the codebase clean and maintainable.

- from ovos_adapt.opm import AdaptPipeline as AdaptService
- from ovos_bus_client.session import IntentContextManagerFrame as ContextManagerFrame, \
-     IntentContextManager as ContextManager
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for usage of potentially unused imports

# Test: Search for usage of AdaptService, ContextManagerFrame, and ContextManager
echo "Searching for AdaptService usage:"
rg --type python 'AdaptService' mycroft/skills/intent_services/adapt_service.py

echo "Searching for ContextManagerFrame usage:"
rg --type python 'ContextManagerFrame' mycroft/skills/intent_services/adapt_service.py

echo "Searching for ContextManager usage:"
rg --type python 'ContextManager' mycroft/skills/intent_services/adapt_service.py

Length of output: 590


Script:

#!/bin/bash
# Description: Check for usage of potentially unused imports

# Test: Search for usage of AdaptService, ContextManagerFrame, and ContextManager in the specified file.
echo "Searching for AdaptService usage:"
rg 'AdaptService' mycroft/skills/intent_services/adapt_service.py

echo "Searching for ContextManagerFrame usage:"
rg 'ContextManagerFrame' mycroft/skills/intent_services/adapt_service.py

echo "Searching for ContextManager usage:"
rg 'ContextManager' mycroft/skills/intent_services/adapt_service.py

Length of output: 731

🧰 Tools
🪛 Ruff

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

Remove unused import: ovos_adapt.opm.AdaptPipeline

(F401)


19-19: ovos_bus_client.session.IntentContextManagerFrame imported but unused

Remove unused import

(F401)


20-20: ovos_bus_client.session.IntentContextManager imported but unused

Remove unused import

(F401)

ovos_core/intent_services/fallback_service.py (6)

199-202: LGTM! Correct usage of PipelineMatch.

The PipelineMatch object is being correctly instantiated and returned, which is consistent with the transition from IntentMatch to PipelineMatch.


205-218: LGTM! Consistent updates to method signatures.

The return types of high_prio, medium_prio, and low_prio methods have been correctly updated from Optional[IntentMatch] to Optional[PipelineMatch], maintaining consistency with the transition to the new pipeline plugin architecture.


Line range hint 1-224: Overall assessment: Changes are consistent and well-implemented.

The modifications in this file successfully transition from IntentMatch to PipelineMatch, aligning with the PR objectives. The changes are consistent across method signatures, return types, and object instantiations. The FallbackService class now inherits from PipelinePlugin, further supporting the transition to the new pipeline plugin architecture.

To ensure the changes are complete and correct, please verify the following:

  1. Confirm that all necessary methods required by PipelinePlugin are implemented in the FallbackService class.
  2. Double-check that there are no remaining references to IntentMatch in the file or in any dependent files.
  3. Ensure that any documentation or comments related to these methods are updated to reflect the new PipelineMatch return type.

28-28: LGTM! Verify PipelinePlugin implementation.

The FallbackService class now inherits from PipelinePlugin, which is consistent with the transition to the new pipeline plugin architecture.

To ensure correct implementation, run the following script:

✅ Verification successful

LGTM! PipelinePlugin implementation verified.

The FallbackService class correctly inherits from PipelinePlugin and includes the necessary __init__ method, ensuring compliance with the new pipeline plugin architecture.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify PipelinePlugin implementation
ast-grep --lang python --pattern 'class FallbackService(PipelinePlugin):
  $$$
  def __init__(self, $$$):
    $$$
  $$$
'

Length of output: 18926


24-24: LGTM! Verify usage of new imports.

The change from IntentMatch to PipelineMatch and PipelinePlugin is consistent with the PR objectives. This transition appears to be part of a larger update to the latest pipeline plugins signature.

To ensure correct usage, run the following script:

✅ Verification successful

Usage of new imports verified.

The usage of PipelineMatch and PipelinePlugin in ovos_core/intent_services/fallback_service.py has been verified and aligns with the intended changes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify usage of PipelineMatch and PipelinePlugin
rg --type python -e 'PipelineMatch|PipelinePlugin' ovos_core/intent_services/fallback_service.py

Length of output: 18926


Line range hint 168-179: LGTM! Verify _fallback_range implementation.

The return type of the _fallback_range method has been updated from Optional[IntentMatch] to Optional[PipelineMatch], which is consistent with the transition to the new pipeline plugin architecture.

To ensure correct implementation, run the following script:

ovos_core/intent_services/converse_service.py (4)

10-10: LGTM: Import changes are consistent with code modifications

The import changes on lines 10 and 14 correctly reflect the transition from IntentMatch to PipelineMatch and the reorganization of ConverseMode and ConverseActivationMode imports. These changes align with the modifications in the converse_with_skills method.

Also applies to: 14-14


Line range hint 315-344: LGTM: Successful transition from IntentMatch to PipelineMatch

The converse_with_skills method has been updated to use PipelineMatch instead of IntentMatch, which is consistent with the import changes. The handled parameter is now correctly set based on the state variable, which improves the clarity of the code.


17-17: LGTM: Class inheritance updated to PipelinePlugin

The ConverseService class now inherits from PipelinePlugin, which is consistent with the transition to the pipeline architecture. This change likely provides additional functionality or interfaces required for the new pipeline system.


340-344: ⚠️ Potential issue

Potential IndexError when accessing utterances[0]

The code assumes that utterances is not empty when accessing utterances[0]. This could lead to an IndexError if utterances is an empty list. Consider adding a check to ensure utterances is not empty before accessing the first element.

Apply this diff to handle the case when utterances is empty:

+                if not utterances:
+                    LOG.warning("No utterances provided to converse_with_skills")
+                    return None
                 return PipelineMatch(handled=state != UtteranceState.RESPONSE,
                                      # handled == True -> emit "ovos.utterance.handled"
                                      match_data={},
                                      skill_id=skill_id,
-                                     utterance=utterances[0])
+                                     utterance=utterances[0] if utterances else "")

Likely invalid or redundant comment.

ovos_core/intent_services/__init__.py (4)

15-33: LGTM! Improved imports for better modularity and type hinting.

The changes to the imports reflect a shift towards a more modular and plugin-based architecture. The addition of Union for type hinting and the new pipeline-related imports (OCPPipelineMatcher, PipelineMatch, IntentHandlerMatch) indicate an effort to improve the intent matching system. The replacement of get_full_lang_code with standardize_lang_tag suggests an update in language handling.


317-317: LGTM! Simplified padatious matcher assignment

The direct assignment of self._padatious_service to padatious_matcher improves code readability by removing a redundant conditional assignment.


353-354: LGTM! Improved session validation

The conversion of _validate_session to a static method is appropriate as it doesn't use self. The standardization of the lang parameter using standardize_lang_tag ensures consistency in language handling throughout the class.


532-532: LGTM! Improved method consistency and language handling

The changes to these methods improve consistency and language handling:

  1. handle_register_vocab: The addition of the lang parameter ensures proper language-specific vocabulary registration.
  2. handle_add_context, handle_remove_context, and handle_clear_context: Converting these to static methods is appropriate as they don't use self.

These changes contribute to better code organization and maintainability.

Also applies to: 562-563, 585-586, 597-598

test/unittests/test_intent_service.py (2)

18-18: Update import to reflect module changes

The import statement for ContextManager has been updated to from ovos_bus_client.session import IntentContextManager as ContextManager, which aligns with the module's refactoring. This change ensures that you're importing the IntentContextManager from its new location.


23-23: Import FakeBus for improved testing

You've added from ovos_utils.fakebus import FakeBus to replace the previous use of MockEmitter. Using FakeBus enhances your test environment by providing a more realistic simulation of the message bus.

test/unittests/test_intent_service.py Outdated Show resolved Hide resolved
test/unittests/test_intent_service.py Outdated Show resolved Hide resolved
JarbasAl added a commit to OpenVoiceOS/OVOS-workshop that referenced this pull request Oct 31, 2024
ovos.utterance.handled is now emitted by the fallback pipeline, the skill class should not emit it or we get duplicate events

noticed in end2end tests from OpenVoiceOS/ovos-core#571
@github-actions github-actions bot added fix and removed fix labels Oct 31, 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

Reviewing files that changed from the base of the PR and between b994db3 and f06f549.

📒 Files selected for processing (1)
  • ovos_core/intent_services/__init__.py (12 hunks)
🧰 Additional context used
🪛 Ruff
ovos_core/intent_services/__init__.py

31-31: ovos_utils.log.deprecated imported but unused

(F401)


256-256: Ambiguous variable name: l

(E741)

🔇 Additional comments (5)
ovos_core/intent_services/__init__.py (5)

15-33: LGTM: Import changes align with pipeline updates

The import changes correctly support the transition to the latest pipeline plugins signature.

🧰 Tools
🪛 Ruff

31-31: ovos_utils.log.deprecated imported but unused

(F401)


346-379: LGTM: Improved type handling

The changes correctly handle both PipelineMatch and IntentHandlerMatch types with proper type annotations and runtime checks.


323-324: LGTM: Appropriate static method conversions

The conversion of methods to static is correct as they don't require instance state.

Also applies to: 529-530, 552-553, 564-565


499-499: LGTM: Method signature update

The updated parameters for register_vocabulary align with the latest pipeline plugins signature.


256-256: ⚠️ Potential issue

Rename variable for better readability

The single letter variable l can be confused with number 1 or capital I. Use a more descriptive name like lang_code.

-        valid_langs = [standardize_lang_tag(l) for l in valid_langs]
+        valid_langs = [standardize_lang_tag(lang_code) for lang_code in valid_langs]

Likely invalid or redundant comment.

🧰 Tools
🪛 Ruff

256-256: Ambiguous variable name: l

(E741)

ovos_core/intent_services/__init__.py Show resolved Hide resolved
@github-actions github-actions bot added fix and removed fix labels Nov 1, 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 (1)
mycroft/skills/intent_services/__init__.py (1)

10-14: Enhance the warning message for missing Padatious.

The warning message could be more informative to help users understand the implications and fallback behavior.

-    LOG.warning("padatious not installed")
+    LOG.warning("Padatious not installed, falling back to Padacioso pipeline")
🧰 Tools
🪛 Ruff

10-10: ovos_padatious.opm.PadatiousMatcher imported but unused; consider using importlib.util.find_spec to test for availability

(F401)


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

(F401)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 58af9d6 and 2971403.

📒 Files selected for processing (11)
  • mycroft/skills/intent_services/__init__.py (1 hunks)
  • mycroft/skills/intent_services/commonqa_service.py (1 hunks)
  • mycroft/skills/intent_services/padatious_service.py (1 hunks)
  • ovos_core/intent_services/adapt_service.py (1 hunks)
  • ovos_core/intent_services/commonqa_service.py (1 hunks)
  • ovos_core/intent_services/ocp_service.py (1 hunks)
  • ovos_core/intent_services/padacioso_service.py (1 hunks)
  • ovos_core/intent_services/padatious_service.py (1 hunks)
  • requirements/skills-essential.txt (1 hunks)
  • requirements/skills-internet.txt (1 hunks)
  • requirements/skills-media.txt (1 hunks)
✅ Files skipped from review due to trivial changes (5)
  • ovos_core/intent_services/adapt_service.py
  • ovos_core/intent_services/commonqa_service.py
  • ovos_core/intent_services/ocp_service.py
  • ovos_core/intent_services/padacioso_service.py
  • ovos_core/intent_services/padatious_service.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • requirements/skills-essential.txt
  • requirements/skills-internet.txt
  • requirements/skills-media.txt
🧰 Additional context used
🪛 Ruff
mycroft/skills/intent_services/__init__.py

1-1: ovos_core.intent_services.fallback_service.FallbackService imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


2-2: ovos_core.intent_services.converse_service.ConverseService imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


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

(F401)


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

(F401)


5-5: ovos_commonqa.opm.CommonQAService imported but unused

(F401)


6-6: ovos_plugin_manager.templates.pipeline.IntentMatch imported but unused

(F401)


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

(F401)


7-7: ovos_workshop.intents.IntentBuilder imported but unused

(F401)


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

(F401)


10-10: ovos_padatious.opm.PadatiousMatcher imported but unused; consider using importlib.util.find_spec to test for availability

(F401)


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

(F401)

mycroft/skills/intent_services/commonqa_service.py

1-1: ovos_commonqa.opm.CommonQAService imported but unused

Remove unused import: ovos_commonqa.opm.CommonQAService

(F401)

mycroft/skills/intent_services/padatious_service.py

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

Remove unused import

(F401)


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

Remove unused import

(F401)


16-16: ovos_padatious.opm.PadatiousIntent imported but unused

Remove unused import

(F401)

🔇 Additional comments (2)
mycroft/skills/intent_services/__init__.py (2)

1-2: LGTM: Core service imports are properly organized.

The imports are correctly structured to use the dedicated modules from ovos_core.intent_services.

🧰 Tools
🪛 Ruff

1-1: ovos_core.intent_services.fallback_service.FallbackService imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


2-2: ovos_core.intent_services.converse_service.ConverseService imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


3-5: Verify coordination with companion PRs.

The pipeline service imports have been updated to use the latest plugin signatures. Please ensure these changes are synchronized with the companion PRs mentioned in the PR description, particularly:

  • ovos-adapt-pipeline-plugin#12
  • ovos-padatious-pipeline-plugin#15
  • ovos-common-query-pipeline-plugin#11
✅ Verification successful

Pipeline service imports are correctly aligned with the codebase

The verification shows that these pipeline services are properly integrated in the codebase:

  • The imports are used consistently across both mycroft/skills/intent_services and ovos_core/intent_services
  • The services are properly instantiated in the IntentService class
  • There are corresponding service-specific files (adapt_service.py, commonqa_service.py, etc.) that handle the implementation details
  • The deprecation notices in the codebase confirm these are the new intended import paths
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the imported classes exist in the respective repos
# Description: Check if the new pipeline classes are defined in the companion repos

echo "Checking for AdaptPipeline in ovos-adapt-pipeline-plugin..."
rg -l "class AdaptPipeline"

echo "Checking for PadaciosoPipeline in padacioso..."
rg -l "class PadaciosoPipeline"

echo "Checking for CommonQAService in ovos-commonqa..."
rg -l "class CommonQAService"

Length of output: 434


Script:

#!/bin/bash
# Let's check the imports and their usage in the codebase

# Check if these imports are used and how
echo "Checking usage of pipeline services..."
rg -A 5 "AdaptService|PadaciosoService|CommonQAService" 

# Check the import statements to understand the module structure
echo -e "\nChecking import statements..."
rg "^from.*import.*(Adapt|Padacioso|CommonQA)"

# Look for any configuration or setup related to these services
echo -e "\nChecking for service configuration..."
rg -l "pipeline.*service" --type yaml

Length of output: 7038

🧰 Tools
🪛 Ruff

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

(F401)


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

(F401)


5-5: ovos_commonqa.opm.CommonQAService imported but unused

(F401)

@github-actions github-actions bot added fix and removed fix labels Nov 2, 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 (1)
ovos_core/intent_services/__init__.py (1)

500-645: Consider adding deprecation timeline documentation.

The deprecated methods and properties are well marked with @deprecated decorators and version information. However, it would be helpful to add documentation about when these will be removed completely.

Add a comment block at the start of the deprecated section:

###########
# DEPRECATED STUFF
# The following methods and properties are deprecated and will be removed in version 1.0.0
# Users should migrate to using the plugin-based pipeline system instead.
###########
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2971403 and 0bcea32.

📒 Files selected for processing (1)
  • ovos_core/intent_services/__init__.py (14 hunks)
🧰 Additional context used
🪛 Ruff
ovos_core/intent_services/__init__.py

146-146: Ambiguous variable name: l

(E741)

🔇 Additional comments (6)
ovos_core/intent_services/__init__.py (6)

15-16: LGTM! Type hints and imports are properly structured.

The addition of Union type hints and defaultdict import improves code clarity and type safety.


236-244: LGTM! Well-documented deactivation tracking implementation.

The new deactivation tracking mechanism properly handles skill state management during intent matching.


381-382: LGTM! Proper cleanup of deactivation tracking.

The code correctly cleans up the deactivation tracking dictionary when the session ends.


213-214: LGTM! Proper conversion to static methods.

The conversion of these methods to static methods is appropriate as they don't use instance state.

Also applies to: 397-398, 420-421, 432-433


146-146: ⚠️ Potential issue

Replace ambiguous variable name l with descriptive name.

Using single-letter variable names like l can be confusing as it looks similar to 1 (one) or I (capital i).

-valid_langs = [standardize_lang_tag(l) for l in valid_langs]
+valid_langs = [standardize_lang_tag(lang_code) for lang_code in valid_langs]

Likely invalid or redundant comment.

🧰 Tools
🪛 Ruff

146-146: Ambiguous variable name: l

(E741)


246-284: 🛠️ Refactor suggestion

Consider adding error handling for match data access.

The code assumes match_type and match_data will always exist on IntentHandlerMatch objects. While this is likely true for internal implementations, it's safer to handle potential attribute errors.

-            data.update(match.match_data)
+            if hasattr(match, 'match_data'):
+                data.update(match.match_data)

@github-actions github-actions bot added fix and removed fix labels Nov 2, 2024
@github-actions github-actions bot added fix and removed fix labels Nov 2, 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)
test/unittests/test_intent_service.py (3)

Line range hint 26-49: Remove unused MockEmitter class

The MockEmitter class is defined but not utilized anywhere in the code. Removing this unused class will clean up the codebase and improve maintainability.

Apply this diff to remove the unused class:

- class MockEmitter(object):
-     def __init__(self):
-         self.reset()
-
-     def emit(self, message):
-         self.types.append(message.msg_type)
-         self.results.append(message.data)
-
-     def get_types(self):
-         return self.types
-
-     def get_results(self):
-         return self.results
-
-     def remove(self, msg_type, handler):
-         self.removed.append(msg_type)
-
-     def on(self, msg_type, handler):
-         pass
-
-     def reset(self):
-         self.removed = []
-         self.types = []
-         self.results = []

Line range hint 51-51: Remove unused emitter attribute in ContextManagerTest

The ContextManagerTest class declares an emitter attribute but does not use it within any of its methods. Removing this unused attribute will enhance code clarity.

Apply this diff to remove the unused attribute:

- class ContextManagerTest(TestCase):
-     emitter = MockEmitter()
+ class ContextManagerTest(TestCase):

Line range hint 73-79: Ensure test isolation when modifying global state

In the test_no_lang_in_message method, the global locale is modified using setup_locale("it-it") and setup_locale("en-US"). Modifying global state within tests can lead to flaky tests if other tests depend on the locale setting. Consider resetting the locale after the test to ensure proper isolation.

You can restore the original locale after the test completes:

    @mock.patch.dict(Configuration._Configuration__patch, BASE_CONF)
    def test_no_lang_in_message(self):
        """No lang in message should result in lang from active locale."""
+       original_locale = setup_locale()
        setup_locale("it-it")
        msg = Message('test msg', data={})
        self.assertEqual(get_message_lang(msg), 'it-IT')
        setup_locale("en-US")
        self.assertEqual(get_message_lang(msg), 'en-US')
+       setup_locale(original_locale)

Alternatively, use setUp and tearDown methods to manage locale settings:

class TestLanguageExtraction(TestCase):
+     def setUp(self):
+         self.original_locale = setup_locale()
+
+     def tearDown(self):
+         setup_locale(self.original_locale)

This ensures that each test starts with a known state and cleans up after itself, preventing unintended side effects.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0bcea32 and d8359f2.

📒 Files selected for processing (1)
  • test/unittests/test_intent_service.py (1 hunks)

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

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

81-83: Consider adding session cleanup for deactivations

The new deactivation tracking mechanism is a good addition, but the _deactivations dictionary might grow if sessions are abandoned without proper cleanup.

Consider adding a cleanup mechanism in the session management code or implementing a session timeout-based cleanup.

Also applies to: 236-244


Line range hint 350-363: Optimize blacklist checking logic

The current implementation checks blacklists after obtaining a match. Consider moving these checks into the match functions to avoid unnecessary processing.

This would prevent the pipeline from spending time on matches that will be discarded anyway.


500-645: Enhance deprecation messages with migration examples

While the deprecation notices are clear, consider adding specific examples of how to migrate to the new plugin-based approach in the deprecation messages.

For example:

-    log_deprecation("direct access to self.adapt_service is deprecated, "
-                    "pipelines are in the progress of being replaced with plugins", "1.0.0")
+    log_deprecation("direct access to self.adapt_service is deprecated. "
+                    "Use the plugin system instead, e.g., 'from ovos_plugin_manager import get_intent_plugin'. "
+                    "Pipelines are in the progress of being replaced with plugins", "1.0.0")
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between cc84d2f and e5a667a.

📒 Files selected for processing (1)
  • ovos_core/intent_services/__init__.py (14 hunks)
🧰 Additional context used
🪛 Ruff
ovos_core/intent_services/__init__.py

146-146: Ambiguous variable name: l

(E741)

🔇 Additional comments (2)
ovos_core/intent_services/__init__.py (2)

Line range hint 397-433: LGTM! Good static method conversions

The conversion of context handling methods to static methods is appropriate as they don't use instance state. The added type hints improve code clarity.


146-146: ⚠️ Potential issue

Rename ambiguous variable name

The variable name l is ambiguous and could be confused with the number '1' or capital 'I'.

-valid_langs = [standardize_lang_tag(l) for l in valid_langs]
+valid_langs = [standardize_lang_tag(lang_code) for lang_code in valid_langs]

Likely invalid or redundant comment.

🧰 Tools
🪛 Ruff

146-146: Ambiguous variable name: l

(E741)

ovos_core/intent_services/__init__.py Show resolved Hide resolved
@JarbasAl JarbasAl changed the title fix:update requirements fix:move code to dependencies Nov 2, 2024
@github-actions github-actions bot removed the fix label Nov 2, 2024
@JarbasAl JarbasAl merged commit 09e4c0a into dev Nov 2, 2024
11 of 12 checks passed
@github-actions github-actions bot added the fix label Nov 2, 2024
@JarbasAl JarbasAl deleted the fix/update branch November 2, 2024 02:13
@github-actions github-actions bot added fix and removed fix labels Nov 2, 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