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:bundled_resources #297

Merged
merged 3 commits into from
Nov 19, 2024
Merged

fix:bundled_resources #297

merged 3 commits into from
Nov 19, 2024

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Nov 19, 2024

cancel.voc was no longer matching inside get_response

noticed in ovos-core end2end tests

Summary by CodeRabbit

  • New Features

    • Added vocabulary entries for cancellation commands: "cancel," "nevermind," and "forget it."
    • Enhanced resource management for skills with a new workshop directory for better organization.
    • Improved language handling, ensuring consistent formatting and appropriate vocabulary usage across different languages.
  • Bug Fixes

    • Enhanced reliability in resource loading and user input processing by standardizing language tags and file paths.
    • Introduced deprecation warnings for certain properties to improve future compatibility.

Copy link

coderabbitai bot commented Nov 19, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request introduces enhancements to the vocabulary and resource management within the ovos_workshop project. New phrases related to cancellation are added to the vocabulary file, while modifications in the resource management classes improve the handling of language-specific resources. Additionally, changes in the ovos.py file focus on standardizing language handling and updating methods to support this functionality.

Changes

File Path Change Summary
ovos_workshop/locale/en/cancel.voc Added new entries: "cancel", "nevermind", "forget it" for cancellation-related commands.
ovos_workshop/resource_files.py - Added method locate_workshop_directory(self) and variable self.workshop_directory in ResourceType.
- Updated _locate method to check workshop_directory.
- Simplified CoreResources constructor.
ovos_workshop/skills/ovos.py - Updated _get_dialog, voc_match, and join_word_list methods to include lang parameter for improved language handling and resource path standardization.
ovos_workshop/skills/common_query_skill.py Changed default_res path to locale/{lang} and added deprecation logging for translated_noise_words.

Possibly related PRs

  • fix:bundled_resources #297: This PR directly relates to the main PR as it also introduces new entries to the vocabulary file ovos_workshop/locale/en/cancel.voc, specifically adding the phrases "cancel," "nevermind," and "forget it," which are identical to the changes made in the main PR.

Suggested reviewers

  • goldyfruit
  • NeonDaniel

🐰 In the workshop where words abound,
New phrases for canceling can now be found.
With directories sorted and paths made clear,
Our skills will respond, oh so dear!
Let's hop along, with joy we proclaim,
Language and resources, a delightful game! 🌟

Warning

Rate limit exceeded

@github-actions[bot] has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 22 minutes and 43 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 3d75fea and c51b2b0.


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 Nov 19, 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: 3

🧹 Outside diff range and nitpick comments (2)
ovos_workshop/locale/en/cancel.voc (2)

1-3: Consider adding more common variations for better coverage.

To improve the robustness of cancellation detection, consider adding these common variations:

 cancel
 nevermind
 forget it
+never mind
+cancelled
+canceling
+stop
+abort

1-3: Add file documentation.

Consider adding a header comment to explain the file's purpose and usage in the context of the get_response function.

+# Vocabulary file for cancellation phrases
+# Used by get_response() to detect when user wants to cancel/abort an interaction
+
 cancel
 nevermind
 forget it
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a478c29 and 3d75fea.

📒 Files selected for processing (3)
  • ovos_workshop/locale/en/cancel.voc (1 hunks)
  • ovos_workshop/resource_files.py (5 hunks)
  • ovos_workshop/skills/ovos.py (2 hunks)
🔇 Additional comments (6)
ovos_workshop/locale/en/cancel.voc (2)

1-3: LGTM! The basic cancellation phrases are appropriate.

The vocabulary entries provide clear, commonly used phrases for cancellation actions.


1-3: Verify integration with get_response function.

Since the PR objectives mention issues with matching in get_response, let's verify the integration.

✅ Verification successful

Let me gather more information about how the vocabulary files are used in the codebase.


Based on the search results, I can now generate a final response as I've found clear evidence of how cancel.voc is integrated with get_response functionality.

Integration with get_response is properly implemented

The cancel.voc file is correctly integrated with the dialog system:

  • It's loaded via the standard vocabulary file loading mechanism in ovos_workshop/resource_files.py
  • The voc_match method in ovos_workshop/skills/ovos.py explicitly checks for 'cancel' vocabulary during response validation
  • There's a dedicated is_cancel function used within the validator of get_response that uses voc_match(utterance, 'cancel', lang=session.lang)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check how get_response uses cancel.voc file
# Expected: Find code that loads and uses cancel.voc for response handling

# Search for references to cancel.voc
rg -l "cancel.voc"

# Search for get_response implementation
ast-grep --pattern 'def get_response($_) {
  $$$
}'

# Look for vocabulary file loading patterns
rg -A 5 "load.*voc.*file"

Length of output: 2877


Script:

#!/bin/bash
# Search for methods that use vocabulary files for matching
rg -A 5 "voc_match" 

# Search for methods that handle cancel/stop intents
ast-grep --pattern 'def $_cancel$_($_) {
  $$$
}'

# Look for dialog handling patterns
rg -A 5 "get_response.*cancel"

Length of output: 6522

ovos_workshop/skills/ovos.py (1)

1845-1845: LGTM: Language-aware vocabulary matching

The addition of the lang parameter to voc_match call improves the accuracy of vocabulary matching by ensuring the correct language-specific vocabulary files are used.

ovos_workshop/resource_files.py (3)

30-30: Approved: Import of LOG module

The LOG module is appropriately imported and used for logging purposes within the class methods.


619-619: Approved: Initializing workshop directories for resource types

Calling locate_workshop_directory() for each resource type ensures that the workshop directories are properly set up.


900-900: Verify the impact of changing the CoreResources directory path

The __init__ method of CoreResources now directly sets the directory to dirname(__file__)/locale, removing previous logic that might have used MYCROFT_ROOT_PATH.

Ensure that this change does not affect the loading of core resources, especially in environments where MYCROFT_ROOT_PATH might be different from dirname(__file__).

To verify that core resources are correctly loaded, you can run the following script:

This script searches for resource files in the specified directory. Confirm that all necessary resource files are present and accessible.

✅ Verification successful

Change to locale directory is safe and properly implemented

The verification shows this change is safe for several reasons:

  • The old implementation already had a fallback to using dirname(__file__) when MYCROFT_ROOT_PATH wasn't available
  • The resource files are properly organized in the new locale directory structure as shown by the file listing
  • The change aligns with the documented preferred method: "The preferred method is to use the 'locale' directory"
  • All necessary language-specific word connector files are present in the new location (az, ca, cs, da, de, en, es, etc.)

The removal of MYCROFT_ROOT_PATH dependency actually simplifies the implementation and makes it more reliable by using a consistent, package-relative path.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that core resource files are correctly located after the directory path change.

# Expected Result: List of core resource files indicating they are found.

# Find all resource files in the new directory path
find "$(dirname "${BASH_SOURCE[0]}")/locale" -type f -print

Length of output: 117


Script:

#!/bin/bash
# Let's first check the actual structure of the repository and locate the resource files
fd -t f -e json -e qml -e txt "." ovos_workshop/locale

# Let's also examine the CoreResources class implementation
ast-grep --pattern 'class CoreResources:
  $$$
'

# Check for any references to MYCROFT_ROOT_PATH
rg "MYCROFT_ROOT_PATH" -A 2

Length of output: 808


Script:

#!/bin/bash
# Let's examine the CoreResources class and its directory handling
rg -A 10 "class CoreResources" ovos_workshop/resource_files.py

# Check for any previous commits that might show the old implementation
git log -p ovos_workshop/resource_files.py | rg -A 5 -B 5 "MYCROFT_ROOT_PATH|CoreResources"

# Check if there are any other usages of the locale directory
rg "locale" ovos_workshop/resource_files.py

Length of output: 2216

ovos_workshop/skills/ovos.py Show resolved Hide resolved
ovos_workshop/resource_files.py Show resolved Hide resolved
ovos_workshop/resource_files.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Nov 19, 2024

Codecov Report

Attention: Patch coverage is 77.27273% with 5 lines in your changes missing coverage. Please review.

Project coverage is 51.69%. Comparing base (7c02206) to head (c51b2b0).
Report is 146 commits behind head on dev.

Files with missing lines Patch % Lines
ovos_workshop/skills/ovos.py 33.33% 4 Missing ⚠️
ovos_workshop/resource_files.py 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #297      +/-   ##
==========================================
- Coverage   53.41%   51.69%   -1.73%     
==========================================
  Files          37       36       -1     
  Lines        4362     4188     -174     
==========================================
- Hits         2330     2165     -165     
+ Misses       2032     2023       -9     

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


🚨 Try these New Features:

@JarbasAl JarbasAl merged commit c436ec4 into dev Nov 19, 2024
8 of 9 checks passed
@github-actions github-actions bot added fix and removed fix labels Nov 19, 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