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

deprecate:is_classic_core #242

Merged
merged 1 commit into from
Oct 11, 2024
Merged

deprecate:is_classic_core #242

merged 1 commit into from
Oct 11, 2024

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Oct 11, 2024

OVOS no longer supports running OVOS skills under classic mycroft-core

this gets rid of some warning logs about mycroft module deprecation

Summary by CodeRabbit

  • New Features

    • Introduced SkillGUI class for enhanced GUI integration.
    • Added voc_match_cache property for vocabulary cache access.
  • Deprecations

    • Deprecated several methods including is_classic_core, report_metric, and send_email.
    • Renamed network_requirements to runtime_requirements.
    • Deprecated methods for translation and dialog initialization.
  • Bug Fixes

    • Streamlined unit tests for better clarity and direct assertions.

Copy link
Contributor

coderabbitai bot commented Oct 11, 2024

Walkthrough

The changes primarily involve significant modifications to the ovos.py file, including the deprecation of several methods and properties, the introduction of new classes, and the renaming of existing properties. The is_classic_core function has been deprecated, and the network_requirements property has been renamed to runtime_requirements. A new property, voc_match_cache, has been added, along with the introduction of the SkillGUI class. The test_skill.py file has also been updated to reflect these changes, removing references to deprecated functionality.

Changes

File Change Summary
ovos_workshop/skills/ovos.py - Deprecated is_classic_core, report_metric, send_email, and several translation methods.
- Renamed network_requirements to runtime_requirements.
- Added voc_match_cache property and SkillGUI class.
- Created alias OVOSFallbackSkill for OVOSSkill.
test/unittests/test_skill.py - Removed import of is_classic_core.
- Updated test_skill_id and test_registered_events to eliminate conditional checks.

Possibly related PRs

  • refactor/planned_deprecations #227: This PR focuses on planned deprecations and refactoring, which aligns with the main PR's extensive deprecation of methods and properties in the ovos.py file, indicating a shared goal of cleaning up and modernizing the codebase.

Suggested labels

refactor

Poem

🐰 In the code where rabbits play,
Old methods hop away,
New paths we now embrace,
With SkillGUI in the race.
So let’s cheer and sing with glee,
For a cleaner code, oh what a spree! 🎉


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
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 (5)
test/unittests/test_skill.py (2)

98-100: LGTM: Test logic simplified

The removal of the is_classic_core() check simplifies the test logic and aligns with the PR objective. The unconditional assertion for CoreSkill is now appropriate given the deprecation of classic core support.

Consider updating the comment to reflect the current state more accurately:

# The metaclass ensures this always returns True in OVOS
# as we no longer support running under mycroft-core

This minor change would clarify that support for mycroft-core has been completely removed, rather than implying a lack of control over it.


137-144: LGTM: OVOS-specific event checks added

The addition of OVOS-specific event checks and the removal of the is_classic_core() conditional (as mentioned in the AI summary) align well with the PR objective. This change enhances test coverage for OVOS-specific functionality.

Consider adding a brief comment above this block to explain the purpose of these new checks:

# Check for OVOS-specific events that are now always expected
default_ovos = [...]

This would provide context for future developers about why these specific events are being checked.

ovos_workshop/skills/ovos.py (3)

Line range hint 334-339: Typographical error in log message in voc_match_cache setter

There's a missing space in the log message, causing "Thisfunctionality" to be concatenated without a space:

self.log.warning("self._voc_cache should not be modified externally. This"
                 "functionality will be deprecated in a future release")

Consider adding a space at the beginning of the second string or combining the strings for clarity.

Apply this diff to correct the log message:

-self.log.warning("self._voc_cache should not be modified externally. This"
-                 "functionality will be deprecated in a future release")
+self.log.warning("self._voc_cache should not be modified externally. "
+                 "This functionality will be deprecated in a future release")

Line range hint 352-354: Typographical error in deprecation message for translate_namedvalues

The deprecation message for translate_namedvalues contains a typo:

@deprecated("Use `self.resources.load_named_value_filetext, data) instead", "0.1.0")

It should be corrected to:

@deprecated("Use `self.resources.load_named_value_file`", "0.1.0")

This ensures that developers are directed to the correct replacement method.

Apply this diff to fix the deprecation message:

-@deprecated("Use `self.resources.load_named_value_filetext, data) instead", "0.1.0")
+@deprecated("Use `self.resources.load_named_value_file`", "0.1.0")

Line range hint 397-403: Suggestion: Move import statement outside of __new__ method in OVOSFallbackSkill

Currently, the import for FallbackSkill occurs within the __new__ method:

def __new__(cls, *args, **kwargs):
    log_deprecation("Implement "
                    "`ovos_workshop.skills.fallback.FallbackSkill`",
                    "0.1.0")
    from ovos_workshop.skills.fallback import FallbackSkill
    return FallbackSkill(*args, **kwargs)

It's recommended to place imports at the top of the file to improve readability and avoid redundant imports if the method is called multiple times.

Apply this diff to move the import statement:

+from ovos_workshop.skills.fallback import FallbackSkill

 class OVOSFallbackSkill(OVOSSkill):
     def __new__(cls, *args, **kwargs):
         log_deprecation("Implement "
                         "`ovos_workshop.skills.fallback.FallbackSkill`",
                         "0.1.0")
-        from ovos_workshop.skills.fallback import FallbackSkill
         return FallbackSkill(*args, **kwargs)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between bb0d3da and 6953423.

📒 Files selected for processing (2)
  • ovos_workshop/skills/ovos.py (1 hunks)
  • test/unittests/test_skill.py (3 hunks)
🧰 Additional context used
🔇 Additional comments (5)
test/unittests/test_skill.py (2)

8-8: LGTM: Import statement updated correctly

The removal of is_classic_core from the import statement is in line with the PR objective of deprecating classic core support.


Line range hint 1-214: Overall changes are consistent and focused

The modifications in this file are well-aligned with the PR objective of deprecating classic core support. The changes are focused on removing is_classic_core checks and adding OVOS-specific assertions. The rest of the file, including tests for other skill functionalities, remains intact, which maintains good overall test coverage.

These changes effectively transition the test suite to assume an OVOS-only environment, which is consistent with the project's direction. The simplification of test logic should make future maintenance easier.

ovos_workshop/skills/ovos.py (3)

58-60: Deprecation of is_classic_core() function is appropriate

The is_classic_core() function is now deprecated and always returns False, which aligns with the removal of support for classic mycroft-core. This change is appropriate and maintains backward compatibility.


Line range hint 316-322: Deprecation of report_metric method is appropriate

The report_metric method is properly marked as deprecated in favor of MetricsApi().report_metric. This encourages developers to use the updated API, ensuring consistency across the codebase.


Line range hint 324-330: Deprecation of send_email method is appropriate

The send_email method is correctly deprecated, guiding developers to use EmailApi().send_email. This change aligns with the new API structure and improves code maintainability.

OVOS no longer supports running OVOS skills under classic mycroft-core
@JarbasAl JarbasAl force-pushed the deprecate/is_classic_core branch from 6953423 to e8a48c3 Compare October 11, 2024 17:57
Copy link

codecov bot commented Oct 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 49.15%. Comparing base (7c02206) to head (e8a48c3).
Report is 25 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #242      +/-   ##
==========================================
- Coverage   53.41%   49.15%   -4.27%     
==========================================
  Files          37       37              
  Lines        4362     4356       -6     
==========================================
- Hits         2330     2141     -189     
- Misses       2032     2215     +183     

☔ 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: 1

🧹 Outside diff range and nitpick comments (10)
ovos_workshop/skills/ovos.py (10)

Line range hint 95-97: Update the docstring in _OVOSSkillMetaclass.

The docstring references MycroftSkill and classic Mycroft Core. Given that support for classic Mycroft Core has been dropped, consider updating the documentation to reflect the current state of the codebase.


Line range hint 247-259: Clarify the default RuntimeRequirements.

The docstring suggests that the default assumes network and internet are required. However, the method returns RuntimeRequirements() without any parameters, which sets all requirements to False. This might lead to confusion.

Apply this diff to set the correct default requirements:

 @classproperty
 def runtime_requirements(self) -> RuntimeRequirements:
     """
     Override to specify what a skill expects to be available at init and at
     runtime. Default will assume network and internet are required and GUI
     is not required for backwards-compat.
     """
-    return RuntimeRequirements()
+    return RuntimeRequirements(
+        requires_network=True,
+        requires_internet=True,
+        no_network_fallback=True,
+        no_internet_fallback=False
+    )

Line range hint 836-839: Remove the deprecated network_requirements property.

The network_requirements property is marked as deprecated and suggests using runtime_requirements instead. Since this property is no longer in use, it's a good opportunity to remove it and clean up the code.


Line range hint 845-848: Make _voc_cache a read-only property.

The setter for voc_match_cache warns against external modifications. To enforce this, consider removing the setter to make _voc_cache read-only and prevent unintended external changes.

Apply this diff to remove the setter:

 @property
 def voc_match_cache(self) -> Dict[str, List[str]]:
     """
     Backwards-compatible accessor method for vocab cache
     @return: dict vocab resources to parsed resources
     """
     return self._voc_cache

-@voc_match_cache.setter
-def voc_match_cache(self, val):
-    self.log.warning("self._voc_cache should not be modified externally. This"
-                     "functionality will be deprecated in a future release")
-    if isinstance(val, dict):
-        self._voc_cache = val

Line range hint 850-866: Remove deprecated translation methods.

The methods translate, translate_namedvalues, translate_list, and translate_template are all deprecated. Since they redirect to the new implementations, it's advisable to remove these methods to reduce code redundancy.


Line range hint 873-881: Simplify the OVOSFallbackSkill class definition.

The OVOSFallbackSkill class is deprecated and currently returns an instance of FallbackSkill using the __new__ method. For clarity and simplicity, consider making it an explicit alias or removing it if it's no longer necessary.

Apply this diff to simplify the class:

-class OVOSFallbackSkill(OVOSSkill):
-    def __new__(cls, *args, **kwargs):
-        log_deprecation("Implement "
-                        "`ovos_workshop.skills.fallback.FallbackSkill`",
-                        "0.1.0")
-        from ovos_workshop.skills.fallback import FallbackSkill
-        return FallbackSkill(*args, **kwargs)
+from ovos_workshop.skills.fallback import FallbackSkill as OVOSFallbackSkill

Line range hint 93-97: Remove backward compatibility checks for classic core in _OVOSSkillMetaclass.

The __instancecheck_classic__ method is designed for backward compatibility with classic Mycroft Core. Since support for classic core has been deprecated, consider removing this method and related compatibility decorators to simplify the metaclass.


Line range hint 125-129: Clean up deprecated initialization warnings.

In the __init__ method, there are warnings about missing bus and skill_id parameters for backward compatibility. Since the codebase is moving away from supporting classic Mycroft Core, consider removing these warnings and enforcing the required parameters.


Line range hint 539-542: Remove deprecated code related to skill GUI initialization.

The _init_skill_gui method checks if self.gui is None before initializing it. Given that the GUI is now an integral part of the skill, consider enforcing its initialization and removing checks for backward compatibility.


Line range hint 618-623: Update the _register_public_api method to remove deprecated handling.

The method contains code related to backward compatibility, such as handling functions without the __name__ attribute. Since support for older versions is deprecated, you can simplify this method by removing outdated checks.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6953423 and e8a48c3.

📒 Files selected for processing (2)
  • ovos_workshop/skills/ovos.py (1 hunks)
  • test/unittests/test_skill.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/unittests/test_skill.py
🧰 Additional context used

ovos_workshop/skills/ovos.py Show resolved Hide resolved
@JarbasAl JarbasAl merged commit 5d61b6c into dev Oct 11, 2024
9 of 10 checks passed
@JarbasAl JarbasAl deleted the deprecate/is_classic_core branch October 11, 2024 18:02
@coderabbitai coderabbitai bot mentioned this pull request Oct 15, 2024
@coderabbitai coderabbitai bot mentioned this pull request Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant