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:log_spam #566

Merged
merged 5 commits into from
Oct 15, 2024
Merged

fix:log_spam #566

merged 5 commits into from
Oct 15, 2024

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Oct 15, 2024

Summary by CodeRabbit

  • New Features

    • Introduced logging for deprecated properties in the IntentService, enhancing user awareness of upcoming changes.
  • Bug Fixes

    • Restructured import statements for better organization and clarity.
  • Documentation

    • Added comments regarding future changes related to locale management in skills.

@JarbasAl JarbasAl requested a review from goldyfruit October 15, 2024 22:11
Copy link

coderabbitai bot commented Oct 15, 2024

Caution

Review failed

The head commit changed during the review from 9e75e84 to 15d0420.

Walkthrough

The changes in the ovos_core/intent_services/__init__.py file focus on the IntentService class. Import statements have been reordered, and deprecated property decorators have been updated to log deprecation warnings instead of using the @deprecated decorator. The handle_utterance method includes a comment about future changes regarding locale loading. Additionally, method calls to self.adapt_service have been replaced with self._adapt_service in several locations. Overall, these modifications enhance code clarity and manage deprecated properties without altering core functionality.

Changes

File Path Change Summary
ovos_core/intent_services/init.py Reordered imports, added open_intent_envelope, repositioned OCPPipelineMatcher and AdaptPipeline. Updated deprecated properties to log warnings instead of using @deprecated decorator. Modified handle_utterance for clarity, added comment about future locale loading. Replaced self.adapt_service with self._adapt_service in multiple methods.

Poem

In the code where rabbits play,
Imports dance and properties sway.
With deprecation warnings clear,
We hop along, no need to fear.
Clarity blooms in every line,
As we code, our skills align! 🐇✨


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 the fix label Oct 15, 2024
Copy link

codecov bot commented Oct 15, 2024

Codecov Report

Attention: Patch coverage is 58.33333% with 15 lines in your changes missing coverage. Please review.

Project coverage is 75.20%. Comparing base (23f0bab) to head (7219a13).
Report is 31 commits behind head on dev.

Files with missing lines Patch % Lines
ovos_core/intent_services/__init__.py 55.88% 15 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #566      +/-   ##
==========================================
- Coverage   75.33%   75.20%   -0.14%     
==========================================
  Files          15       15              
  Lines        3094     1553    -1541     
==========================================
- Hits         2331     1168    -1163     
+ Misses        763      385     -378     
Flag Coverage Δ
end2end 55.31% <27.77%> (?)
unittests 52.60% <50.00%> (-22.74%) ⬇️

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 15, 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 (5)
ovos_core/intent_services/__init__.py (5)

94-96: LGTM! Consider updating documentation.

The change from @deprecated decorator to log_deprecation is a good approach. It provides more flexibility in handling deprecations and informs users about future changes.

Consider updating the class or module documentation to reflect this deprecation and the planned transition to plugins.


100-101: LGTM! Consider refactoring for DRY principle.

The consistent application of log_deprecation across multiple properties is good. It ensures a uniform approach to deprecation warnings.

However, the repetitive nature of these changes presents an opportunity for refactoring. Consider creating a helper method or decorator to apply this deprecation logging, which would adhere to the DRY (Don't Repeat Yourself) principle and make future updates easier.

Also applies to: 106-107, 112-114, 119-120, 125-126, 131-132, 137-138


459-462: LGTM! Consider creating a tracking issue.

The addition of the try-except block for setup_locale improves the robustness of the code by handling potential exceptions. The comment about uncoupling lingua franca from the core indicates a planned architectural change.

Consider creating a tracking issue or adding a TODO comment with a ticket number for the future task of making skills responsible for locale loading. This will ensure the planned change is not forgotten and can be properly prioritized.

🧰 Tools
🪛 Ruff

461-461: Local variable e is assigned to but never used

Remove assignment to unused variable e

(F841)


Line range hint 1-750: Overall improvements with opportunities for further refinement.

The changes in this file generally improve the codebase by:

  1. Providing more informative deprecation warnings.
  2. Ensuring proper resource cleanup during shutdown.
  3. Adding robustness to locale handling.

However, there are opportunities for further improvement:

  1. Refactor the repetitive deprecation logging in properties to adhere to the DRY principle.
  2. Create tracking issues for planned architectural changes (e.g., uncoupling lingua franca from the core).
  3. Verify the removal of event handler deregistrations to prevent potential issues.

Consider addressing these points in future updates to enhance code maintainability and prevent potential bugs.


Event Handler Deregistrations Not Fully Removed

The verification script found that several self.bus.remove calls are still present in ovos_core/intent_services/__init__.py and associated test files. Please ensure that these event handler deregistrations are either no longer needed or have been handled appropriately elsewhere in the codebase to prevent potential memory leaks or unexpected behavior.

  • self.bus.remove('register_vocab', self.handle_register_vocab)
  • self.bus.remove('register_intent', self.handle_register_intent)
  • self.bus.remove('recognizer_loop:utterance', self.handle_utterance)
  • self.bus.remove('detach_intent', self.handle_detach_intent)
  • self.bus.remove('detach_skill', self.handle_detach_skill)
  • self.bus.remove('add_context', self.handle_add_context)
  • self.bus.remove('remove_context', self.handle_remove_context)
  • self.bus.remove('clear_context', self.handle_clear_context)
  • self.bus.remove('mycroft.skills.loaded', self.update_skill_name_dict)
  • self.bus.remove('intent.service.intent.get', self.handle_get_intent)
  • self.bus.remove('intent.service.skills.get', self.handle_get_skills)
  • self.bus.remove('intent.service.adapt.get', self.handle_get_adapt)
  • self.bus.remove('intent.service.adapt.manifest.get', self.handle_adapt_manifest)
  • self.bus.remove('intent.service.adapt.vocab.manifest.get', self.handle_vocab_manifest)
  • self.bus.remove('intent.service.padatious.get', self.handle_get_padatious)
  • self.bus.remove('intent.service.padatious.manifest.get', self.handle_padatious_manifest)
  • self.bus.remove('intent.service.padatious.entities.manifest.get', self.handle_entity_manifest)
🔗 Analysis chain

Line range hint 723-750: Verify removal of event handler deregistrations.

The addition of shutdown calls for utterance_plugins and metadata_plugins is good for proper resource cleanup.

However, several self.bus.remove calls for event handlers have been removed. Please verify that these event handlers are indeed no longer needed or are handled elsewhere in the codebase to prevent potential memory leaks or unexpected behavior.

To verify the removal of event handlers, run the following script:



🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to the removed event handlers

# Test: Search for references to removed event handlers
rg --type python "self\.bus\.(on|remove)\s*\(\s*'(register_vocab|register_intent|recognizer_loop:utterance|detach_intent|detach_skill|add_context|remove_context|clear_context|mycroft\.skills\.loaded|intent\.service\.intent\.get|intent\.service\.skills\.get|intent\.service\.adapt\.get|intent\.service\.adapt\.manifest\.get|intent\.service\.adapt\.vocab\.manifest\.get|intent\.service\.padatious\.get|intent\.service\.padatious\.manifest\.get|intent\.service\.padatious\.entities\.manifest\.get)'"

Length of output: 535


Script:

#!/bin/bash
# Description: List all supported file types in ripgrep to identify the correct type for Python files

rg --type-list

Length of output: 4821


Script:

#!/bin/bash
# Description: Check for any remaining references to the removed event handlers using the correct file type identifier

rg --type py "self\.bus\.(on|remove)\s*\(\s*'(register_vocab|register_intent|recognizer_loop:utterance|detach_intent|detach_skill|add_context|remove_context|clear_context|mycroft\.skills\.loaded|intent\.service\.intent\.get|intent\.service\.skills\.get|intent\.service\.adapt\.get|intent\.service\.adapt\.manifest\.get|intent\.service\.adapt\.vocab\.manifest\.get|intent\.service\.padatious\.get|intent\.service\.padatious\.manifest\.get|intent\.service\.padatious\.entities\.manifest\.get)'"

Length of output: 4603

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 21ba8de and 1ce61a0.

📒 Files selected for processing (1)
  • ovos_core/intent_services/init.py (3 hunks)
🧰 Additional context used
🔇 Additional comments (2)
ovos_core/intent_services/__init__.py (2)

20-23: LGTM! New import may affect intent handling.

The import changes look good. The addition of open_intent_envelope from ovos_workshop.intents suggests a potential enhancement or refactoring in intent handling. Ensure that this new functionality is properly documented and tested.


143-144: Consistent with getters. Refactoring opportunity remains.

The setter methods have been updated consistently with their corresponding getters, which is good for maintaining symmetry in the deprecation approach.

As mentioned for the getter methods, consider refactoring these deprecation warnings into a single helper method or decorator to reduce code duplication and improve maintainability.

Also applies to: 149-150, 155-156, 161-162, 167-168, 173-174, 179-180, 185-186

@github-actions github-actions bot added fix and removed fix labels Oct 15, 2024
@goldyfruit
Copy link
Member

All good.

@JarbasAl JarbasAl merged commit f956666 into dev Oct 15, 2024
6 checks passed
@JarbasAl JarbasAl deleted the fix/logs branch October 15, 2024 22:32
@coderabbitai coderabbitai bot mentioned this pull request Nov 11, 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.

2 participants