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

build: simplify dependencies #301

Open
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

maciejmajek
Copy link
Member

@maciejmajek maciejmajek commented Oct 29, 2024

Purpose

RAI's default python environment takes a lot of time to install. Some of the dependencies should be marked as optional.

Proposed Changes

Moved non-core dependencies to optional category

Issues

  • Links to relevant issues

Testing

  • How was it tested, what were the results?

Summary by CodeRabbit

  • New Features

    • Introduced a new optional dependency group for local automatic speech recognition (ASR) with openai-whisper.
  • Bug Fixes

    • Removed the outdated torchaudio dependency to streamline performance.

@maciejmajek
Copy link
Member Author

maciejmajek commented Oct 29, 2024

@coderabbitai full review

@RobotecAI RobotecAI deleted a comment from coderabbitai bot Oct 29, 2024
@RobotecAI RobotecAI deleted a comment from coderabbitai bot Oct 29, 2024
@RobotecAI RobotecAI deleted a comment from coderabbitai bot Oct 29, 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 (2)
pyproject.toml (2)

67-71: LGTM! Consider using a more specific version constraint

The addition of the optional local_asr group aligns well with the PR objective of simplifying dependencies. The group is properly configured as optional, which will help reduce the default installation size.

Consider using a more specific version constraint for openai-whisper to ensure reproducible builds:

-openai-whisper = "^20231117"
+openai-whisper = "==20231117"

Line range hint 1-72: Document optional dependency groups in README

The reorganization of dependencies into optional groups is a good architectural decision that will help users install only what they need. To make this more user-friendly, consider:

  1. Adding a section in the README that explains:
    • Available optional dependency groups
    • How to install specific groups (e.g., poetry install --with local_asr)
    • Which features require which groups
  2. Updating CI/CD pipelines to test different dependency combinations

Would you like me to help draft the documentation for these optional groups?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 1e2e657 and c94dbdf.

⛔ Files ignored due to path filters (1)
  • poetry.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • pyproject.toml (1 hunks)
🔇 Additional comments (1)
pyproject.toml (1)

Line range hint 14-52: Verify impact of removing torchaudio dependency

The removal of torchaudio from main dependencies could impact existing users. While its functionality might be replaced by openai-whisper in the new local_asr group, we should verify there are no direct dependencies on torchaudio in the codebase.

✅ Verification successful

The initial scan found no direct imports of torchaudio, but we found several audio-related files. Let's examine their implementations to understand if they rely on torchaudio indirectly or if the audio processing is handled through other libraries.


Based on the examination of the audio-related files, I can now generate the final response:

Removing torchaudio dependency is safe

The codebase does not rely on torchaudio for audio processing. Instead, it uses:

  • scipy.io.wavfile for audio file operations
  • openai-whisper for speech recognition
  • elevenlabs and OpenTTS for text-to-speech

The removal of torchaudio aligns with the goal of simplifying dependencies without breaking existing functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any direct usage of torchaudio in the codebase
echo "Searching for torchaudio imports and usage..."
rg "import.*torchaudio|from.*torchaudio" -l

# Search for any potential audio processing related files
echo -e "\nSearching for potential audio-related files..."
fd -e py -x grep -l "audio" {}

Length of output: 562


Script:

#!/bin/bash
# Let's check the content of audio-related files to understand the audio processing implementation
echo "=== Checking ASR implementation ==="
cat ./src/rai_asr/rai_asr/asr_clients.py

echo -e "\n=== Checking TTS implementation ==="
cat ./src/rai_tts/rai_tts/tts_clients.py

echo -e "\n=== Checking setup.py for ASR dependencies ==="
cat ./src/rai_asr/setup.py

Length of output: 8065

Copy link

coderabbitai bot commented Oct 29, 2024

Walkthrough

The changes involve updates to the pyproject.toml file, focusing on dependency management. A new optional dependency group named local_asr has been introduced, which includes the openai-whisper library. Dependencies openai-whisper and torchaudio have been removed from the main dependencies list, indicating a restructuring of how these libraries are organized. The existing optional groups, openset and nomad, remain unchanged, and the overall structure of the build-system, isort, and pytest configurations is preserved.

Changes

File Change Summary
pyproject.toml - Added new optional group: [tool.poetry.group.local_asr]
- Added dependency to local_asr: openai-whisper = "^20231117"
- Removed openai-whisper from main dependencies
- Removed torchaudio from main dependencies
- Existing optional groups openset and nomad remain unchanged
- build-system, isort, and pytest configurations unchanged

Poem

In the garden of code, a new group does bloom,
With whispers of OpenAI, dispelling the gloom.
Dependencies dance, some take their leave,
While local_asr joins, a change to believe.
Hops of reorganization, a structure refined,
In the world of Python, new paths we will find! 🐇✨


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

@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 (1)
pyproject.toml (1)

Line range hint 13-72: Consider further dependency optimization opportunities.

While this PR makes a good start at simplifying dependencies, there are additional opportunities for optimization:

  1. Consider grouping LangChain-related dependencies (langchain*) into an optional group for users not requiring LLM features
  2. The use of wildcards (*) in version constraints for packages like langchain and langgraph could lead to unexpected updates

Consider creating a new optional group for LangChain dependencies:

+[tool.poetry.group.llm]
+optional = true
+
+[tool.poetry.group.llm.dependencies]
+langchain-core = "^0.3"
+langchain = "^0.1"
+langgraph = "^0.0.10"
+langchain-aws = "^0.0.3"
+langchain-openai = "^0.0.5"
+langchain-ollama = "^0.0.5"
+langchain-community = "^0.0.10"

This would allow users to install the base package without LLM capabilities when not needed.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 1e2e657 and c94dbdf.

⛔ Files ignored due to path filters (1)
  • poetry.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • pyproject.toml (1 hunks)
🔇 Additional comments (2)
pyproject.toml (2)

Line range hint 1-72: Verify the removal of torchaudio dependency.

While moving openai-whisper to an optional group is well-handled, the removal of torchaudio needs verification. This package might be required by other dependencies or functionality.

Let's check for potential torchaudio usage:

#!/bin/bash
# Search for torchaudio imports or usage
echo "=== Checking for direct torchaudio usage ==="
rg "import torchaudio|from torchaudio" -l

echo "=== Checking if torchaudio is a dependency of other packages ==="
rg "torchaudio" "requirements*.txt" "setup*.py" "pyproject.toml" || true

67-71: LGTM! Good separation of ASR dependencies.

The addition of the local_asr optional group aligns well with the PR objective of simplifying dependencies. This change allows users to install ASR capabilities only when needed.

Let's verify there are no direct dependencies on whisper in the codebase that might break without this optional dependency:

✅ Verification successful

Let me try another search strategy to verify whisper usage:


LGTM! The optional dependency is properly handled in the codebase.

The verification shows that the whisper dependency is well-managed:

  • The ASR functionality is properly isolated in the rai_asr package
  • The code has proper conditional imports in asr_node.py that handle both local whisper and OpenAI whisper options
  • Launch files provide configuration flexibility through the asr_vendor parameter
  • Documentation clearly indicates whisper as an optional dependency

The move to make whisper an optional dependency is safe and aligns with the PR's goal of simplifying installation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for whisper imports or usage that might break without the optional dependency
rg -l "import whisper|from whisper" | while read -r file; do
    echo "=== $file ==="
    rg "import whisper|from whisper" "$file" -A 5
done

Length of output: 459


Script:

#!/bin/bash
# Search for whisper-related patterns more broadly
echo "=== Searching for whisper patterns ==="
rg -i "whisper" -l

echo -e "\n=== Checking content of files with whisper mentions ==="
rg -i "whisper" -C 5

Length of output: 22453

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.

2 participants