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

feat:assistant_config #194

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from
Open

feat:assistant_config #194

wants to merge 9 commits into from

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Jan 7, 2025

deprecates RemoteConfig , backend-client and personal-server have been deprecated already

adds AssistantConfig, meant for runtime changes made by OVOS, this ensure we don't accidentally corrupt or ignore user configs

some plugins like IPGeo were using the RemoteConf for this purpose as an hack, some other components have been corrupting the user config / replacing user config with syntax errors

Summary by CodeRabbit

Release Notes

  • Configuration Management

    • Renamed configuration classes for better clarity
    • Added new AssistantConfig for runtime configuration
    • Deprecated remote configuration support
  • User Experience

    • Updated configuration loading process
    • Simplified configuration paths
    • Removed deprecated configuration variables
  • Testing

    • Updated unit tests to reflect new configuration structure
    • Removed remote configuration test scenarios
  • Documentation

    • Updated comments and descriptions to reflect OpenVoiceOS branding

deprecates RemoteConfig , backend-client and personal-server have been deprecated already

adds AssistantConfig, meant for runtime changes made by OVOS, this ensure we don't accidentally corrupt or ignore user configs

some plugins like IPGeo were using the RemoteConf for this purpose as an hack, some other components have been corrupting the user config / replacing user config with syntax errors
Copy link
Contributor

coderabbitai bot commented Jan 7, 2025

Warning

Rate limit exceeded

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

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

Walkthrough

The pull request introduces significant changes to the configuration management system in the OpenVoiceOS project. The modifications focus on updating configuration classes, removing deprecated remote configuration support, and introducing a new AssistantConfig for runtime configuration. The changes streamline the configuration structure, rename existing classes, and remove references to remote configuration. The updates affect multiple files across the project, including configuration models, locations, main configuration file, and associated test files.

Changes

File Change Summary
ovos_config/config.py - Added AssistantConfig() attribute to Configuration class
- Updated configuration class references
- Modified load_all_configs and read_mycroft_config methods
- Added update_assistant_config() function
ovos_config/locations.py - Removed OLD_USER_CONFIG and REMOTE_CONFIG variables
- Added ASSISTANT_CONFIG variable
- Added deprecation warnings
ovos_config/models.py - Renamed configuration classes (e.g., MycroftDefaultConfigDefaultConfig)
- Added AssistantConfig and UserConfig classes
- Added deprecation warnings
test/unittests/test_configuration.py - Removed test_remote method
- Updated imports and configuration loading
test/unittests/test_locations.py - Removed references to OLD_USER_CONFIG and REMOTE_CONFIG
- Added ASSISTANT_CONFIG variable
ovos_config/__main__.py - Updated CONFIGS list
- Modified configuration display commands
ovos_config/mycroft.conf - Updated comments and terminology
- Removed remote configuration references
test/unittests/config_stack/remote.yaml - Completely removed

Sequence Diagram

sequenceDiagram
    participant User
    participant Configuration
    participant AssistantConfig
    participant DefaultConfig
    participant SystemConfig
    participant DistributionConfig

    User->>Configuration: Initialize
    Configuration->>AssistantConfig: Create runtime config
    Configuration->>DefaultConfig: Load default settings
    Configuration->>SystemConfig: Load system settings
    Configuration->>DistributionConfig: Load distribution settings
    Configuration->>User: Merged Configuration
Loading

Poem

🐰 Configuration Rabbit's Delight

In OpenVoiceOS, configs take flight
Remote settings fade, assistant grows bright
Classes renamed with rabbit's might
A new config dance, pure and light
Hop into the future, configuration's delight! 🌟


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. (Beta)
  • @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 Jan 7, 2025
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

🧹 Nitpick comments (3)
ovos_config/locations.py (1)

127-127: Consider documenting the runtime configuration format.

The new ASSISTANT_CONFIG path is introduced for plugins/skills to store runtime changes. Consider adding a docstring or comment explaining the expected format and structure of the runtime.conf file.

ovos_config/models.py (1)

172-175: Consider adding docstring to AssistantConfig.

The new AssistantConfig class is a key addition for runtime changes, but it lacks documentation explaining its purpose and usage.

Consider adding a docstring:

 class AssistantConfig(LocalConf):
+    """Configuration class for runtime changes made by plugins and skills.
+    This config is writable and changes here won't corrupt user configurations."""
     def __init__(self):
         super().__init__(ASSISTANT_CONFIG)
ovos_config/config.py (1)

386-396: Consider code style improvements.

The function can be simplified using a ternary operator.

-    if path is None:
-        conf = AssistantConfig()
-    else:
-        conf = LocalConf(path)
+    conf = AssistantConfig() if path is None else LocalConf(path)

Also, consider updating the docstring to better reflect the AssistantConfig usage:

-    """ updates user config file with the contents of provided dict
-    if a path is provided that location will be used instead of AssistantConfig"""
+    """Updates configuration with the contents of provided dict.
+    
+    Args:
+        config (dict): Configuration to merge
+        path (str, optional): If provided, this location will be used instead of AssistantConfig
+        bus: Optional message bus for broadcasting configuration changes
+    Returns:
+        LocalConf: The updated configuration object
+    """
🧰 Tools
🪛 Ruff (0.8.2)

387-390: Use ternary operator conf = AssistantConfig() if path is None else LocalConf(path) instead of if-else-block

Replace if-else-block with conf = AssistantConfig() if path is None else LocalConf(path)

(SIM108)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d010c7d and 9bb3e53.

📒 Files selected for processing (3)
  • ovos_config/config.py (5 hunks)
  • ovos_config/locations.py (4 hunks)
  • ovos_config/models.py (4 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
ovos_config/config.py

387-390: Use ternary operator conf = AssistantConfig() if path is None else LocalConf(path) instead of if-else-block

Replace if-else-block with conf = AssistantConfig() if path is None else LocalConf(path)

(SIM108)

🔇 Additional comments (3)
ovos_config/locations.py (1)

90-94: LGTM! Clear deprecation warnings added.

The deprecation warnings are well-implemented with clear messages and proper stacklevel.

Also applies to: 111-115

ovos_config/models.py (1)

189-193: LGTM! Consistent deprecation warnings.

The deprecation warnings are consistently implemented across all renamed classes with clear messages.

Also applies to: 200-204, 210-214, 220-224, 230-234, 240-244

ovos_config/config.py (1)

37-37: LGTM! AssistantConfig properly integrated.

The AssistantConfig is correctly integrated into the configuration stack and reload mechanism.

Also applies to: 141-141, 173-173

JarbasAl added a commit to OpenVoiceOS/ovos-PHAL-plugin-gpsd that referenced this pull request Jan 7, 2025
JarbasAl added a commit to OpenVoiceOS/ovos-PHAL-plugin-ipgeo that referenced this pull request Jan 7, 2025
@github-actions github-actions bot added feature and removed feature labels Jan 11, 2025
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: 1

🧹 Nitpick comments (2)
ovos_config/config.py (2)

386-396: Simplify conditional logic using ternary operator.

The code can be simplified using a ternary operator as suggested by the static analysis.

-    if path is None:
-        conf = AssistantConfig()
-    else:
-        conf = LocalConf(path)
+    conf = AssistantConfig() if path is None else LocalConf(path)
🧰 Tools
🪛 Ruff (0.8.2)

387-390: Use ternary operator conf = AssistantConfig() if path is None else LocalConf(path) instead of if-else-block

Replace if-else-block with conf = AssistantConfig() if path is None else LocalConf(path)

(SIM108)


Line range hint 1-396: Overall implementation aligns well with PR objectives, but RemoteConfig needs removal.

The changes successfully introduce AssistantConfig and properly integrate it into the configuration management system. However, there's one critical issue:

  1. RemoteConfig is still present (line 36) despite being deprecated without replacement according to the pipeline warning.

The rest of the implementation looks solid, with proper deprecation warnings and configuration management integration.

🧰 Tools
🪛 GitHub Actions: Run UnitTests

[warning] 36-36: DeprecationWarning: deprecated without replacement, OVOS no longer supports remote config

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b8d2e3e and ec0702a.

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

387-390: Use ternary operator conf = AssistantConfig() if path is None else LocalConf(path) instead of if-else-block

Replace if-else-block with conf = AssistantConfig() if path is None else LocalConf(path)

(SIM108)

🪛 GitHub Actions: Run UnitTests
ovos_config/config.py

[warning] 36-36: DeprecationWarning: deprecated without replacement, OVOS no longer supports remote config

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

16-16: LGTM! Import changes align with the new configuration system.

The addition of the warnings module and updated imports reflect the transition to the new configuration system with AssistantConfig.

Also applies to: 20-22


33-35: LGTM! Configuration class attributes updated to use new config types.

The changes properly initialize the new configuration types and add AssistantConfig for runtime changes.

Also applies to: 37-37


141-141: LGTM! AssistantConfig properly integrated into configuration management.

The changes correctly:

  • Include AssistantConfig in reload operations
  • Add AssistantConfig to the configuration stack
  • Set up file watching for AssistantConfig changes

Also applies to: 173-173, 264-266


376-380: LGTM! Proper deprecation warning added.

The deprecation warning is well-implemented with a clear message directing users to use Configuration() directly.

ovos_config/config.py Outdated Show resolved Hide resolved
@github-actions github-actions bot added feature and removed feature labels Jan 11, 2025
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: 1

🧹 Nitpick comments (1)
ovos_config/__init__.py (1)

1-1: Address unused imports.

The imports Configuration and LocalConf are not used in this file.

Either:

  1. Remove the unused imports:
-from ovos_config.config import Configuration, LocalConf
  1. Or add them to __all__ if they are meant to be exported:
+__all__ = ['Configuration', 'LocalConf']
from ovos_config.config import Configuration, LocalConf
🧰 Tools
🪛 Ruff (0.8.2)

1-1: ovos_config.config.Configuration imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


1-1: ovos_config.config.LocalConf imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ec0702a and 1370931.

📒 Files selected for processing (4)
  • ovos_config/__init__.py (1 hunks)
  • ovos_config/__main__.py (4 hunks)
  • ovos_config/config.py (9 hunks)
  • ovos_config/mycroft.conf (3 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
ovos_config/__init__.py

1-1: ovos_config.config.Configuration imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


1-1: ovos_config.config.LocalConf imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

ovos_config/config.py

333-335: f-string used as docstring. Python will interpret this as a joined string, rather than a docstring.

(B021)

🔇 Additional comments (9)
ovos_config/__main__.py (4)

13-13: LGTM! Configuration paths updated correctly.

The changes correctly update the imports and configuration paths to use the new AssistantConfig.

Also applies to: 18-19


109-109: LGTM! Command description updated.

The command description has been updated to reflect the new configuration structure.


281-281: LGTM! CLI options updated.

The CLI options have been updated to use assistant instead of remote.

Also applies to: 285-285


297-297: LGTM! Documentation updated.

The joining pattern documentation has been updated to reflect the new configuration hierarchy.

ovos_config/config.py (3)

33-36: LGTM! Configuration class attributes updated.

The Configuration class has been correctly updated to use the new config classes.


348-352: LGTM! Deprecation warnings implemented correctly.

The deprecation warnings are properly implemented with appropriate warning messages and stacklevels.

Also applies to: 359-363


364-364: LGTM! Clear logging of configuration path changes.

The log warning clearly indicates which configuration file is being updated.

ovos_config/mycroft.conf (2)

2-5: LGTM! Documentation updated for OVOS context.

The configuration file documentation has been updated to use OpenVoiceOS terminology instead of Mycroft-specific terms.


566-569: LGTM! New session configuration added.

The new session configuration section has been added with appropriate documentation.

ovos_config/config.py Show resolved Hide resolved
@github-actions github-actions bot added feature and removed feature labels Jan 11, 2025
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: 2

🔭 Outside diff range comments (1)
test/unittests/test_configuration.py (1)

Line range hint 165-165: Update test assertions for new configuration structure

The test assertions need to be updated to reflect the removal of remote configuration:

Apply this diff to update the assertions:

-                                                  "from_rem": False,
+                                                  "from_rem": None,
-                                          "remote": False})
+                                          "remote": None})

Also applies to: 151-151, 157-157

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1370931 and 7ca8814.

📒 Files selected for processing (5)
  • ovos_config/__main__.py (4 hunks)
  • ovos_config/config.py (9 hunks)
  • ovos_config/models.py (4 hunks)
  • test/unittests/config_stack/remote.yaml (0 hunks)
  • test/unittests/test_configuration.py (3 hunks)
💤 Files with no reviewable changes (1)
  • test/unittests/config_stack/remote.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • ovos_config/models.py
🧰 Additional context used
🪛 Ruff (0.8.2)
ovos_config/config.py

22-22: ovos_config.models.MycroftDefaultConfig imported but unused

Remove unused import

(F401)


22-22: ovos_config.models.OvosDistributionConfig imported but unused

Remove unused import

(F401)


22-22: ovos_config.models.MycroftSystemConfig imported but unused

Remove unused import

(F401)


22-22: ovos_config.models.MycroftUserConfig imported but unused

Remove unused import

(F401)


22-22: ovos_config.models.RemoteConf imported but unused

Remove unused import

(F401)


333-335: f-string used as docstring. Python will interpret this as a joined string, rather than a docstring.

(B021)

🪛 GitHub Actions: Run UnitTests
test/unittests/test_configuration.py

[error] 195-195: Test failure in test_config_patches_filewatch: AssertionError: False is not true


[error] 305-305: Test failure in test_on_file_changes_not_called: Expected mock to be called once but was called 2 times


[warning] 192-192: DeprecationWarning: use 'update_assistant_config' instead of 'update_mycroft_config'

🔇 Additional comments (6)
test/unittests/test_configuration.py (1)

9-10: LGTM! Import cleanup.

The removal of unused imports sleep and MagicMock improves code cleanliness.

ovos_config/config.py (3)

33-36: LGTM! Configuration class updates

The changes correctly implement the new configuration structure using the new config classes.


358-365: LGTM! Deprecation warning implementation

The deprecation warning is well implemented with a clear message and proper stacklevel.


332-343: ⚠️ Potential issue

Fix docstring format in update_assistant_config

The function uses an f-string as a docstring, which Python will interpret as a joined string rather than a docstring.

Apply this diff to fix the docstring:

-    f""" updates assistant config file with the contents of provided dict 
-    path: {ASSISTANT_CONFIG}
-    """
+    """ updates assistant config file with the contents of provided dict 
+    path: {}
+    """.format(ASSISTANT_CONFIG)

Likely invalid or redundant comment.

🧰 Tools
🪛 Ruff (0.8.2)

333-335: f-string used as docstring. Python will interpret this as a joined string, rather than a docstring.

(B021)

ovos_config/__main__.py (2)

18-19: LGTM! Updated CONFIGS list

The CONFIGS list correctly reflects the new configuration structure with AssistantConfig replacing RemoteConfig.


297-297: Update configuration joining pattern documentation

The joining pattern documentation has been updated to reflect the new configuration structure.

Run this script to verify the joining pattern matches the implementation:

✅ Verification successful

Configuration joining pattern documentation is accurate

The documented pattern "user > assistant > system > default" correctly reflects the implementation. In the code, configs are loaded in reverse precedence order (default first, user last) because later configs override earlier ones during merging, which creates the documented precedence order.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify configuration joining pattern in code
# Expected pattern: user > assistant > system > default

ast-grep --pattern $'class Configuration {
  $$$
  load_all_configs($$$) {
    $$$
    configs = [$$$]
    $$$
  }
  $$$
}'

Length of output: 124


Script:

#!/bin/bash
# Search for configuration related files and the joining pattern
echo "=== Searching for configuration files ==="
rg -l "Configuration" --type py

echo -e "\n=== Searching for joining pattern mentions ==="
rg "joining pattern|config.*join" -A 3 -B 3

echo -e "\n=== Searching for configuration loading implementation ==="
rg "load_all_configs|load.*config" -A 5 -B 5 --type py

Length of output: 20346


Script:

#!/bin/bash
# Search for the load_all_configs implementation with more context
echo "=== Searching for load_all_configs implementation ==="
rg "def load_all_configs" -A 20 -B 5 ovos_config/config.py

echo -e "\n=== Searching for configuration stack loading ==="
rg "configs = \[" -A 10 -B 10 ovos_config/config.py

Length of output: 3126

test/unittests/test_configuration.py Show resolved Hide resolved
ovos_config/config.py Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant