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

Update config.py #173

Merged
merged 2 commits into from
Oct 27, 2024
Merged

Update config.py #173

merged 2 commits into from
Oct 27, 2024

Conversation

builderjer
Copy link
Member

@builderjer builderjer commented Oct 20, 2024

fix deprecation warning

Summary by CodeRabbit

  • New Features
    • Enhanced error logging for configuration file reloads.
  • Deprecations
    • Marked load_config_stack and clear_cache methods as deprecated; users are encouraged to use load_all_configs instead.
  • Improvements
    • Updated connectivity check method to improve remote configuration fetching.

fix deprecation warning
Copy link
Contributor

coderabbitai bot commented Oct 20, 2024

Walkthrough

The changes in the pull request primarily involve modifications to the Configuration class in ovos_config/config.py. Key updates include altering the method for checking internet connectivity in set_config_update_handlers, deprecating the load_config_stack method in favor of load_all_configs, and enhancing error handling in _on_file_change to improve logging of exceptions. These adjustments refine the configuration management process and guide users toward updated practices.

Changes

File Path Change Summary
ovos_config/config.py - Updated set_config_update_handlers to use is_connected_http() instead of is_connected().
- Deprecated load_config_stack, added warning to use load_all_configs instead.
- Enhanced error handling in _on_file_change to log exceptions during configuration reload.
- Deprecated clear_cache method.

Suggested labels

fix

Poem

In the code where configs dwell,
Changes ring like a joyful bell.
From stack to all, we now take flight,
With logs that shine, making errors bright.
A hop, a skip, to new ways we go,
In the world of config, watch us grow! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 670bfc7 and d6d03a9.

📒 Files selected for processing (1)
  • ovos_config/config.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • ovos_config/config.py

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.

Copy link

codecov bot commented Oct 20, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Please upload report for BASE (dev@fd6e347). Learn more about missing BASE report.

Files with missing lines Patch % Lines
ovos_config/config.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##             dev    #173   +/-   ##
=====================================
  Coverage       ?   0.00%           
=====================================
  Files          ?      10           
  Lines          ?     877           
  Branches       ?       0           
=====================================
  Hits           ?       0           
  Misses         ?     877           
  Partials       ?       0           

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

Copy link
Contributor

@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_config/config.py (2)

Line range hint 76-89: LGTM: Appropriate deprecation of load_config_stack.

The deprecation of load_config_stack is well-implemented:

  1. A clear warning message is logged.
  2. The method still functions as before, allowing for a gradual transition.
  3. The alternative method load_all_configs is suggested.

Consider adding a deprecation decorator (e.g., @deprecated) if available in your codebase, to provide additional visibility and potentially automate deprecation handling.

🧰 Tools
🪛 Ruff

267-267: ovos_utils.network_utils.is_connected imported but unused

Remove unused import: ovos_utils.network_utils.is_connected

(F401)


268-268: Undefined name is_connected_http

(F821)


271-271: Do not use bare except

(E722)


Line range hint 401-404: Improve deprecation of clear_cache method.

The deprecation of clear_cache is appropriate given that there's no cache anymore. However, there are a couple of points to consider:

  1. The method still calls Configuration.updated(message), which might be unnecessary.
  2. There's no clear indication to users about what they should do instead of calling this method.

Consider the following improvements:

  1. If Configuration.updated(message) is truly unnecessary, remove it:
@staticmethod
def clear_cache(message=None):
    """DEPRECATED - there is no cache anymore """
-   Configuration.updated(message)
    pass
  1. Add a deprecation warning with guidance for users:
@staticmethod
def clear_cache(message=None):
    """DEPRECATED - there is no cache anymore """
+   import warnings
+   warnings.warn("clear_cache is deprecated and does nothing. Configuration updates are now handled automatically.", DeprecationWarning, stacklevel=2)
    pass

This will provide clearer guidance to users about the deprecation and what, if anything, they need to do instead.

🧰 Tools
🪛 Ruff

267-267: ovos_utils.network_utils.is_connected imported but unused

Remove unused import: ovos_utils.network_utils.is_connected

(F401)


268-268: Undefined name is_connected_http

(F821)


271-271: Do not use bare except

(E722)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between fd6e347 and 670bfc7.

📒 Files selected for processing (1)
  • ovos_config/config.py (1 hunks)
🧰 Additional context used
🪛 Ruff
ovos_config/config.py

268-268: Undefined name is_connected_http

(F821)

🔇 Additional comments (1)
ovos_config/config.py (1)

265-270: ⚠️ Potential issue

Update internet connectivity check and resolve import issues.

The change from is_connected() to is_connected_http() appears to address a deprecation, which is good. However, there are a few issues to address:

  1. The import statement for is_connected is now unused and should be removed.
  2. is_connected_http() is not imported or defined, which will cause a NameError.
  3. The TODO comment suggests intermittent import issues, which should be investigated.

To resolve these issues:

  1. Remove the unused import:
- from ovos_utils.network_utils import is_connected
  1. Import the new function:
+ from ovos_utils.network_utils import is_connected_http
  1. Investigate and resolve the intermittent import failures mentioned in the TODO comment.

To ensure the is_connected_http function is available, run:

This will help verify the existence and location of the new function.

🧰 Tools
🪛 Ruff

267-267: ovos_utils.network_utils.is_connected imported but unused

Remove unused import: ovos_utils.network_utils.is_connected

(F401)


268-268: Undefined name is_connected_http

(F821)

forgot the import
@JarbasAl JarbasAl added the fix label Oct 27, 2024
@JarbasAl JarbasAl merged commit 593f36b into OpenVoiceOS:dev Oct 27, 2024
9 checks passed
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