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:delayed_padatious_training #627

Merged
merged 4 commits into from
Dec 9, 2024
Merged

fix:delayed_padatious_training #627

merged 4 commits into from
Dec 9, 2024

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Dec 9, 2024

needs OpenVoiceOS/ovos-padatious-pipeline-plugin#29

Summary by CodeRabbit

  • New Features

    • Enhanced skill loading mechanism with improved logging for better traceability.
    • Integrated skill loading with intent training processes for up-to-date functionality.
    • Default value for instant_train configuration option set to False.
    • Updated dependency version for ovos_padatious to >=1.1.0, <2.0.0.
  • Bug Fixes

    • Ensured the system appropriately responds when new skills are detected.
    • Improved error handling for intent training requests and service creation.

Copy link

coderabbitai bot commented Dec 9, 2024

Warning

Rate limit exceeded

@JarbasAl has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 0 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 21a5f7a and cb50d5a.

📒 Files selected for processing (3)
  • ovos_core/intent_services/__init__.py (2 hunks)
  • ovos_core/skill_manager.py (5 hunks)
  • requirements/lgpl.txt (1 hunks)

Walkthrough

This pull request introduces modifications to two main components: the IntentService class and the SkillManager class. In IntentService, a new configuration option instant_train for the padatious service is added, defaulting to False. The loading logic for the padacioso service is adjusted to ensure it is instantiated regardless of the padatious service's availability. In SkillManager, enhancements include tracking newly loaded skills, updating method signatures to indicate return types, and integrating skill loading with intent training, improving error logging.

Changes

File Path Change Summary
ovos_core/intent_services/init.py Added instant_train configuration option for padatious. Adjusted loading logic for padacioso service. Reorganized import statements. Modified get_pipeline to conditionally use matchers based on availability.
ovos_core/skill_manager.py Introduced loaded_new variable, updated load_plugin_skills and _load_new_skills methods to handle skill loading and logging; method signatures updated to indicate return types. Updated _get_plugin_skill_loader to accept an additional skill_class parameter.
requirements/lgpl.txt Updated version constraint for ovos_padatious dependency from >=1.0.5, <2.0.0 to >=1.1.0, <2.0.0.

Possibly related PRs

  • improve_typing #528: This PR modifies the ovos_core/intent_services/__init__.py file, directly related to changes in the IntentService class.
  • deprecate ready setting #554: This PR involves changes in ovos_core/skill_manager.py, relevant to service and skill management similar to the main PR.
  • fix:log_spam #566: This PR updates the IntentService class in ovos_core/intent_services/__init__.py, directly related to the changes made in the main PR.
  • fix:standardize_lang #568: This PR includes changes to the IntentService class, focusing on language handling, relevant to modifications in the main PR.

Suggested labels

dependencies

Suggested reviewers

  • goldyfruit
  • j1nx
  • builderjer

🐇 "In the code where the skills do load,
A new path for training, we now strode.
With plugins in tow, and logs shining bright,
Our intents will flourish, all day and all night!" 🌟


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 generate docstrings to generate docstrings for this PR. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

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

CodeRabbit Configuration File (.coderabbit.yaml)

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

Documentation and Community

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

@github-actions github-actions bot added feature and removed feature labels Dec 9, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

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

95-96: Consider moving the configuration to ovos-config.

The instant_train configuration is hardcoded here with a TODO comment indicating it should be moved to ovos-config. This change aligns with the delayed training implementation in the skill manager.

Would you like me to help create a PR to add this configuration to ovos-config?

ovos_core/skill_manager.py (1)

513-518: LGTM: Added delayed padatious training.

The implementation efficiently triggers padatious training only when new skills are loaded, waiting for the training to complete before proceeding.

Consider adding a timeout to wait_for_response to prevent potential deadlocks if the training response is not received.

-            self.bus.wait_for_response(Message("padatious:train"),
-                                       "mycroft.skills.trained")
+            self.bus.wait_for_response(Message("padatious:train"),
+                                       "mycroft.skills.trained",
+                                       timeout=300)  # 5 minutes timeout
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 88b094d and e6e333f.

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

291-291: LGTM: Added tracking of newly loaded skills.

The addition of the loaded_new flag helps track when new skills are loaded, which is used to determine if intent training is needed.

Also applies to: 313-314


479-479: LGTM: Added tracking of newly loaded skills.

The addition of the loaded_new flag helps track when new skills are loaded from both plugin skills and local skills.

Also applies to: 511-512

Copy link

codecov bot commented Dec 9, 2024

Codecov Report

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

Project coverage is 72.33%. Comparing base (23f0bab) to head (cb50d5a).
Report is 141 commits behind head on dev.

Files with missing lines Patch % Lines
ovos_core/skill_manager.py 37.50% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #627      +/-   ##
==========================================
- Coverage   75.33%   72.33%   -3.01%     
==========================================
  Files          15       15              
  Lines        3094     1569    -1525     
==========================================
- Hits         2331     1135    -1196     
+ Misses        763      434     -329     
Flag Coverage Δ
end2end 55.13% <18.18%> (?)
unittests 49.20% <54.54%> (-26.14%) ⬇️

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 feature and removed feature labels Dec 9, 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

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

Line range hint 728-766: Consider cleaning up deprecated methods in a future PR.

The file contains several deprecated methods at the end that could be removed in a future PR to improve code maintainability:

  • load_priority
  • is_device_ready
  • handle_check_device_readiness
  • check_services_ready
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between e6e333f and 582d485.

📒 Files selected for processing (1)
  • ovos_core/skill_manager.py (7 hunks)
🔇 Additional comments (2)
ovos_core/skill_manager.py (2)

Line range hint 291-315: LGTM! Well-structured tracking of newly loaded skills.

The addition of the loaded_new flag effectively tracks when new skills are loaded, which is then used to determine if intent training is needed. The implementation is clean and maintains the existing functionality while adding this new capability.


Line range hint 334-350: LGTM! Good enhancement to plugin skill loader initialization.

The addition of the optional skill_class parameter provides more flexibility in skill loading while maintaining backward compatibility. This is a clean implementation that allows for direct skill class assignment when available.

ovos_core/skill_manager.py Outdated Show resolved Hide resolved
@github-actions github-actions bot added feature and removed feature labels Dec 9, 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/skill_manager.py (2)

520-526: Consider making the Padatious training timeout configurable

The timeout for the Padatious training response is currently hardcoded to 60 seconds. Consider making this timeout configurable through the settings to allow flexibility based on different deployment environments and training times.


Line range hint 334-350: Consider passing skill_class to PluginSkillLoader constructor

Currently, skill_class is assigned to the loader after initialization. If possible, consider modifying the PluginSkillLoader constructor to accept skill_class as a parameter. This would make the initialization more cohesive and ensure that any initialization logic depending on skill_class is properly handled.

ovos_core/intent_services/__init__.py (2)

96-97: Address the TODO: Read 'instant_train' from configuration

You have added a TODO to read 'instant_train' from the configuration once the default value is added to ovos-config. Considering implementing this now to enhance configurability and avoid hardcoding values in the code.

Would you like assistance in updating the code to read 'instant_train' from the configuration?


99-99: Remove unnecessary f-string without placeholders

The log message at line 99 uses an f-string without any placeholders. Consider removing the f prefix to avoid unnecessary string processing.

Apply this diff to fix the issue:

-                LOG.error(f'Failed to create padatious intent handlers, padatious not installed')
+                LOG.error('Failed to create padatious intent handlers, padatious not installed')
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 582d485 and 0db6b22.

📒 Files selected for processing (2)
  • ovos_core/intent_services/__init__.py (4 hunks)
  • ovos_core/skill_manager.py (7 hunks)
🧰 Additional context used
🪛 Ruff (0.8.0)
ovos_core/intent_services/__init__.py

100-100: f-string without any placeholders

Remove extraneous f prefix

(F541)

🔇 Additional comments (1)
ovos_core/skill_manager.py (1)

515-530: Impressive implementation of timeout and error handling for Padatious training

The addition of timeout and error handling around the Padatious training request ensures that the system does not hang indefinitely and properly logs any issues during training.

@JarbasAl
Copy link
Member Author

JarbasAl commented Dec 9, 2024

#628 and #629 split from this PR

@JarbasAl JarbasAl changed the title feat:delayed_padatious_training fix:delayed_padatious_training Dec 9, 2024
@github-actions github-actions bot added fix and removed feature labels Dec 9, 2024
@github-actions github-actions bot added fix and removed fix labels Dec 9, 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: 2

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

96-97: Consider making 'instant_train' configurable via ovos-config

Currently, instant_train is hardcoded to False, which limits flexibility. Reading this value from the configuration allows for dynamic adjustments without code changes.

Apply this diff to read instant_train from the configuration:

 # TODO - read from config once default value has been added to ovos-config
-self.config["padatious"]["instant_train"] = False
+self.config["padatious"]["instant_train"] = self.config["padatious"].get("instant_train", False)

100-100: Remove unnecessary 'f' prefix from LOG.error message

The f-string in the LOG.error call does not contain any placeholders, so the f prefix is unnecessary.

Apply this diff to remove the unnecessary f prefix:

 except ImportError:
-    LOG.error(f'Failed to create padatious intent handlers, padatious not installed')
+    LOG.error('Failed to create padatious intent handlers, padatious not installed')
🧰 Tools
🪛 Ruff (0.8.0)

100-100: f-string without any placeholders

Remove extraneous f prefix

(F541)


108-109: Improve log message formatting for clarity

The log message could be more grammatically correct and clearer.

Apply this diff to enhance the log message:

 elif "disable_padacioso" not in self.config:
     LOG.debug("Padacioso pipeline is disabled, only padatious is loaded. "
-              "set 'disable_padacioso': false in mycroft.conf if you want it to load alongside padatious")
+              "Set 'disable_padacioso': false in mycroft.conf if you want it to load alongside padatious.")
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0db6b22 and fad1b76.

📒 Files selected for processing (2)
  • ovos_core/intent_services/__init__.py (4 hunks)
  • ovos_core/skill_manager.py (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • ovos_core/skill_manager.py
🧰 Additional context used
🪛 Ruff (0.8.0)
ovos_core/intent_services/__init__.py

100-100: f-string without any placeholders

Remove extraneous f prefix

(F541)

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

211-217: ⚠️ Potential issue

Add a check before accessing attributes of padatious_matcher

When updating the matchers dictionary, ensure that padatious_matcher is not None to prevent potential AttributeError.

Apply this diff to include a safety check:

 if self._padatious_service is not None:
     matchers.update({
         "padatious_high": padatious_matcher.match_high,
         "padatious_medium": padatious_matcher.match_medium,
         "padatious_low": padatious_matcher.match_low,
 
     })
+else:
+    LOG.debug("Padatious matcher is not available; skipping padatious matchers.")

Likely invalid or redundant comment.

ovos_core/intent_services/__init__.py Outdated 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 Dec 9, 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)

96-97: Consider documenting the instant_train configuration option.

The new instant_train configuration option for padatious service is introduced with a default value of False. While the implementation is correct, it would be beneficial to add documentation explaining its purpose and impact.

Consider adding a comment like:

 if "instant_train" not in self.config["padatious"]:
+    # Controls whether padatious should train immediately when new intents are registered
     self.config["padatious"]["instant_train"] = False
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between fad1b76 and 21a5f7a.

📒 Files selected for processing (3)
  • ovos_core/intent_services/__init__.py (2 hunks)
  • ovos_core/skill_manager.py (5 hunks)
  • requirements/lgpl.txt (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • ovos_core/skill_manager.py
🔇 Additional comments (3)
requirements/lgpl.txt (1)

1-1: LGTM! Version constraint update aligns with new features.

The version bump for ovos_padatious to >=1.1.0 is necessary to support the new instant_train configuration option while maintaining compatibility with existing features.

ovos_core/intent_services/__init__.py (2)

19-21: LGTM! Import organization improved.

The imports for CommonQAService and PadaciosoService are now placed with other pipeline-related imports, improving code organization.


96-97: Verify dependency chain for instant training feature.

The new instant_train configuration option requires ovos_padatious>=1.1.0. Let's verify this dependency is properly handled across the codebase.

✅ Verification successful

Dependencies are properly handled for instant_train feature

The verification shows that:

  • The required dependency ovos_padatious>=1.1.0 is correctly specified in requirements/lgpl.txt
  • The feature is properly guarded with a default value of False
  • The imports from ovos_padatious are consistent across the codebase
  • The feature is only used within the padatious service initialization, which has proper error handling for missing dependencies
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the minimum version requirement is consistently defined
rg -l "ovos_padatious.*1\.1\.0" 

# Check for any potential version conflicts
rg "ovos_padatious.*[0-9]+\.[0-9]+\.[0-9]+"

Length of output: 153


Script:

#!/bin/bash
# Check if instant_train is used in the codebase and how it's handled
rg -A 5 "instant_train" 

# Check for any padatious imports or usage
ast-grep --pattern 'from ovos_padatious import $_'
ast-grep --pattern 'import ovos_padatious'

# Check setup.py for dependencies
cat setup.py

Length of output: 6113

@github-actions github-actions bot added fix and removed fix labels Dec 9, 2024
@JarbasAl JarbasAl merged commit 4e95204 into dev Dec 9, 2024
9 of 10 checks passed
@JarbasAl JarbasAl deleted the delay_padatious branch December 9, 2024 21:15
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