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/drop_OCP_mycroft_hacks #80

Merged
merged 4 commits into from
Jul 17, 2024
Merged

fix/drop_OCP_mycroft_hacks #80

merged 4 commits into from
Jul 17, 2024

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Jul 17, 2024

OCP was loaded as a regular audio plugin, this was the only way to inject it into mycroft-core

in OVOS this is no longer needed and OCP is loaded directly as part of ovos-audio (until ovos-media is released)

the compat layer is dropped to avoid issues in edge cases, such as it getting selected as the default audio plugin if no others are installed, which can cause an infinite loop at playback time

Summary by CodeRabbit

  • Refactor
    • Simplified audio backend setup by removing conditional logic related to disable_ocp flag.
    • Improved handling of older plugin versions for OCP backend.
    • Ensured default audio backend is always set up correctly.
    • Added event handlers for audio playback.

OCP was loaded as a regular audio plugin, this was the only way to inject it into mycroft-core

in OVOS this is no longer needed and OCP is loaded directly as part of ovos-audio (until ovos-media is released)

the compat layer is dropped to avoid issues in edge cases, such as it getting selected as the default audio plugin if no others are installed, which can cause an infinite loop at playback time
@JarbasAl JarbasAl added the bug Something isn't working label Jul 17, 2024
@JarbasAl JarbasAl requested a review from a team July 17, 2024 22:07
@JarbasAl JarbasAl self-assigned this Jul 17, 2024
Copy link
Contributor

coderabbitai bot commented Jul 17, 2024

Walkthrough

The recent changes to the ovos_audio module primarily focus on refactoring how the OCPAudioBackend is set up. The find_ocp method now instantiates the OCPAudioBackend using configuration settings and adjusts to handle older plugin versions. Additionally, the logic for selecting the default backend has been modified to simplify the process by removing conditional checks and unconditionally setting up the default audio backend, while also adding event handlers for audio playback.

Changes

File(s) Change Summary
ovos_audio/audio.py Refactored find_ocp to instantiate OCPAudioBackend using configs, adjusted for older plugin versions, removed conditional logic related to disable_ocp, and added event handlers

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant AudioService
    participant OCPAudioBackend
    Client->>AudioService: load_services()
    AudioService->>AudioService: find_default()
    AudioService->>OCPAudioBackend: Instantiate with configs
    OCPAudioBackend-->>AudioService: Instance created
    AudioService->>AudioService: Setup event handlers
    AudioService-->>Client: Default audio backend set
Loading

Poem

In the land of code and sound,
The OCPAudioBackend was found.
Refactored and set with care,
With configurations, everywhere.
No more flags to sway the tune,
Just seamless playback, afternoon to moon. 🌙


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2fcea0b and 53c5db7.

Files selected for processing (1)
  • ovos_audio/audio.py (3 hunks)
Additional context used
Ruff
ovos_audio/audio.py

102-102: Do not use bare except

(E722)

Additional comments not posted (2)
ovos_audio/audio.py (2)

Line range hint 118-125:
LGTM!

The changes to the find_default method are straightforward and correct.


151-151: LGTM! But verify the impact of removing the disable_ocp flag.

The changes to the load_services method are correct. However, ensure that removing the disable_ocp flag doesn't affect other parts of the codebase.

ovos_audio/audio.py Outdated Show resolved Hide resolved
actually call find_ocp()... forgot that in previous commit
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 53c5db7 and 36cadc8.

Files selected for processing (1)
  • ovos_audio/audio.py (4 hunks)
Additional context used
Ruff
ovos_audio/audio.py

104-104: Do not use bare except

(E722)

Additional comments not posted (2)
ovos_audio/audio.py (2)

Line range hint 108-117:
LGTM!

The changes ensure that the default backend is always set up, improving reliability.

Tools
Ruff

104-104: Do not use bare except

(E722)


Line range hint 130-158:
LGTM!

The changes simplify the logic and ensure that the default backend is always set up, improving reliability. Additionally, the method now sets up event handlers for audio playback, which is essential for functionality.

ovos_audio/audio.py Outdated Show resolved Hide resolved
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: 3

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 36cadc8 and bd4b669.

Files selected for processing (1)
  • ovos_audio/audio.py (4 hunks)
Additional context used
Ruff
ovos_audio/audio.py

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

Remove assignment to unused variable e

(F841)

Additional comments not posted (2)
ovos_audio/audio.py (2)

113-121: Ensure proper handling of missing default backend.

The function should handle the case where no default backend is found more explicitly.

Ensure that the removal of the disable_ocp flag check does not cause unintended side effects.

-        if not self.service:
+        if not self.service or not self.default:
            LOG.error("No audio player plugins found!")
            return False

159-163: Ensure compatibility with future releases.

The comment indicates that the current implementation will be replaced by ovos-media in a future release. Ensure that the transition is smooth and backward compatibility is maintained.

Ensure that the removal of the disable_ocp flag does not cause unintended side effects.

ovos_audio/audio.py Show resolved Hide resolved
ovos_audio/audio.py Show resolved Hide resolved
ovos_audio/audio.py Show resolved Hide resolved
@JarbasAl JarbasAl merged commit 3983816 into dev Jul 17, 2024
4 checks passed
@JarbasAl JarbasAl deleted the fix/drop_OCP_mycroft_hacks branch July 17, 2024 23:08
This was referenced Sep 12, 2024
@coderabbitai coderabbitai bot mentioned this pull request Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant