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 install_env.sh of Comfy #1170

Merged
merged 14 commits into from
Dec 27, 2024
Merged

Update install_env.sh of Comfy #1170

merged 14 commits into from
Dec 27, 2024

Conversation

jackalcooper
Copy link
Collaborator

@jackalcooper jackalcooper commented Dec 26, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced installation script for improved package management.
    • Updated GitHub Actions workflow to include specific versions for Docker images.
    • Added new dependency opencv-python-headless to the requirements.
  • Bug Fixes

    • Adjusted installation commands to ensure compatibility with Python 3 and user-specific installations.
    • Removed volume mappings in the test configuration, which may impact service functionality.

Copy link
Contributor

coderabbitai bot commented Dec 26, 2024

Walkthrough

The pull request modifies the install_env.sh script to enhance Python package installation. It introduces the python3 -m prefix to pip install commands, ensuring the use of the Python 3 interpreter, and adds the --user flag for user-specific installations. The .github/workflows/examples.yml file is updated to modify the Docker image specifications and package installations during the CI workflow. Two volume mappings are removed from the tests/diffusers-docker-compose.yml file, affecting the container's file system setup.

Changes

File Change Summary
onediff_comfy_nodes/benchmarks/scripts/install_env.sh - Added python3 -m prefix to pip install commands
- Added --user flag to all pip install commands
- Consolidated installation of common dependencies into a single command
.github/workflows/examples.yml - Updated Docker image specifications in run-examples job
- Refined installation steps for ComfyUI requirements
- Uninstalled transformer-engine as part of the requirements
- Added command to check pip cache directory
tests/diffusers-docker-compose.yml - Removed volume mappings for ${SDXL_BASE} and ${UNET_INT8} in onediff-test service
onediff_diffusers_extensions/examples/requirements.txt - Added new dependency: opencv-python-headless

Poem

🐰 Pip install with care, a rabbit's delight,
User-specific packages, now shining bright!
Python3 leads the way, with modules anew,
In workflows we hop, making tasks complete!
With Docker and scripts, we dance through the night,
A joyful install, all set for flight! 🐾


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e04c0ae and 80a7ad2.

📒 Files selected for processing (2)
  • .github/workflows/examples.yml (3 hunks)
  • onediff_diffusers_extensions/examples/requirements.txt (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • onediff_diffusers_extensions/examples/requirements.txt
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/examples.yml

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.

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 73eaeb7 and 75205c7.

📒 Files selected for processing (1)
  • onediff_comfy_nodes/benchmarks/scripts/install_env.sh (1 hunks)
🔇 Additional comments (1)
onediff_comfy_nodes/benchmarks/scripts/install_env.sh (1)

31-31: Pin nexfort package version for reproducibility.

The nexfort package installation lacks version pinning, which could lead to inconsistent environments across different installations.

-python3 -m pip install --user nexfort
+python3 -m pip install --user "nexfort==<specific-version>"

Let's check the latest stable version:

Comment on lines +25 to +26
python3 -m pip install --user -r $CUSTOM_NODES/ComfyUI_InstantID/requirements.txt
python3 -m pip install --user -r $CUSTOM_NODES/PuLID_ComfyUI/requirements.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling for requirements installation.

The requirements installation commands should include error handling to ensure the script fails gracefully if the requirements files are missing or if installations fail.

Consider this improvement:

-  python3 -m pip install --user -r $CUSTOM_NODES/ComfyUI_InstantID/requirements.txt
-  python3 -m pip install --user -r $CUSTOM_NODES/PuLID_ComfyUI/requirements.txt
+  for node in "ComfyUI_InstantID" "PuLID_ComfyUI"; do
+    req_file="$CUSTOM_NODES/$node/requirements.txt"
+    if [ -f "$req_file" ]; then
+      echo "Installing requirements for $node..."
+      python3 -m pip install --user -r "$req_file" || {
+        echo "Failed to install requirements for $node"
+        exit 1
+      }
+    else
+      echo "Warning: Requirements file not found for $node"
+    fi
+  done
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
python3 -m pip install --user -r $CUSTOM_NODES/ComfyUI_InstantID/requirements.txt
python3 -m pip install --user -r $CUSTOM_NODES/PuLID_ComfyUI/requirements.txt
for node in "ComfyUI_InstantID" "PuLID_ComfyUI"; do
req_file="$CUSTOM_NODES/$node/requirements.txt"
if [ -f "$req_file" ]; then
echo "Installing requirements for $node..."
python3 -m pip install --user -r "$req_file" || {
echo "Failed to install requirements for $node"
exit 1
}
else
echo "Warning: Requirements file not found for $node"
fi
done

fi

echo "Installing common dependencies..."
pip install websocket-client==1.8.0 numpy==1.26.4 scikit-image -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install nexfort
python3 -m pip install --user websocket-client==1.8.0 numpy==1.26.4 scikit-image "huggingface_hub==0.25.0" "flash-attn==2.5.8" -i https://pypi.tuna.tsinghua.edu.cn/simple
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Make mirror URL configurable and add CUDA version check

Based on the repository documentation and code analysis:

  1. The project explicitly requires CUDA 11.8 (with 12.1 and 12.2 as alternatives)
  2. The codebase includes GPU-specific optimizations and CUDA dependencies
  3. flash-attn is used in CrossAttention modules with specific dimension requirements

Suggested changes:

+# Check CUDA version
+if ! command -v nvcc &> /dev/null; then
+    echo "Warning: NVCC not found. flash-attn requires CUDA (11.8, 12.1, or 12.2)"
+    exit 1
+fi
+
+# Allow mirror configuration
+PIP_MIRROR=${PIP_MIRROR:-"https://pypi.tuna.tsinghua.edu.cn/simple"}
+
-python3 -m pip install --user websocket-client==1.8.0 numpy==1.26.4 scikit-image "huggingface_hub==0.25.0" "flash-attn==2.5.8" -i https://pypi.tuna.tsinghua.edu.cn/simple
+python3 -m pip install --user websocket-client==1.8.0 numpy==1.26.4 scikit-image "huggingface_hub==0.25.0" "flash-attn==2.5.8" -i "$PIP_MIRROR"
🔗 Analysis chain

Consider environment-specific mirror selection and verify CUDA compatibility.

The script has two potential improvements:

  1. The Tsinghua mirror is hardcoded, which might not be optimal for users outside China
  2. flash-attn 2.5.8 has specific CUDA requirements that should be verified before installation

Consider making the mirror URL configurable:

-python3 -m pip install --user websocket-client==1.8.0 numpy==1.26.4 scikit-image "huggingface_hub==0.25.0" "flash-attn==2.5.8" -i https://pypi.tuna.tsinghua.edu.cn/simple
+PIP_MIRROR=${PIP_MIRROR:-"https://pypi.tuna.tsinghua.edu.cn/simple"}
+python3 -m pip install --user websocket-client==1.8.0 numpy==1.26.4 scikit-image "huggingface_hub==0.25.0" "flash-attn==2.5.8" -i "$PIP_MIRROR"

Let's verify CUDA compatibility:


Let me check if there are any CUDA requirements or compatibility notes in the repository documentation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check CUDA version and nvcc availability
if command -v nvcc &> /dev/null; then
    echo "CUDA version:"
    nvcc --version
else
    echo "Warning: NVCC not found. flash-attn might not work without CUDA support"
fi

Length of output: 170


Script:

#!/bin/bash
# Check for CUDA requirements in documentation
rg -i "cuda|gpu" README.md || echo "No CUDA/GPU mentions in README"

# Check for any installation requirements or prerequisites
fd "requirements|install" -e txt -e md -X cat {} || echo "No requirement files found"

# Look for any flash-attn related configuration or setup
rg -i "flash.?attn" -A 3 -B 3

Length of output: 4167

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 (1)
onediff_comfy_nodes/benchmarks/scripts/install_env.sh (1)

30-30: Consider splitting package installation into logical groups

The single pip install command mixes different types of dependencies (websocket, numpy, ML-specific packages). Consider grouping them logically for better maintainability.

-python3 -m pip install --user nexfort websocket-client==1.8.0 numpy==1.26.4 scikit-image "huggingface_hub==0.25.0" "flash-attn==2.5.8" -i https://pypi.tuna.tsinghua.edu.cn/simple
+# Base dependencies
+python3 -m pip install --user websocket-client==1.8.0 numpy==1.26.4 scikit-image -i "$PIP_MIRROR"
+# ML-specific dependencies
+python3 -m pip install --user "huggingface_hub==0.25.0" "flash-attn==2.5.8" -i "$PIP_MIRROR"
+# Additional tools
+python3 -m pip install --user nexfort -i "$PIP_MIRROR"
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fcb1156 and 9c9e698.

📒 Files selected for processing (2)
  • .github/workflows/examples.yml (1 hunks)
  • onediff_comfy_nodes/benchmarks/scripts/install_env.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/examples.yml
🔇 Additional comments (3)
onediff_comfy_nodes/benchmarks/scripts/install_env.sh (3)

25-26: Add error handling for requirements installation.

The requirements installation commands need proper error handling to ensure the script fails gracefully if the requirements files are missing or if installations fail.


30-30: Make mirror URL configurable and add CUDA version check

The mirror URL is hardcoded and flash-attn has specific CUDA requirements.


30-30: Verify the purpose of the nexfort package

The nexfort package is being installed but wasn't mentioned in the PR summary or description. Please clarify its purpose and if it's a new requirement.

✅ Verification successful

Nexfort is a valid requirement - it's a PyTorch model compilation backend

Based on the code analysis, nexfort is a legitimate requirement used as a backend for PyTorch model compilation in this project. Specifically:

  • It's used in the BasicNexFortBoosterExecutor class to optimize model performance through compilation
  • The package provides performance optimizations for various model components (ModelPatcher, VAE, ControlNet, etc.)
  • It's integrated with OneDiff's inference compiler system as shown in the backend implementation
  • The package is used to apply memory format optimizations and model compilation with settings like "max-optimize:max-autotune:low-precision"
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

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

echo "Searching for nexfort in requirements files..."
fd requirements.txt -x grep -l "nexfort" {} \;

Length of output: 1705


Script:

#!/bin/bash
# Let's check the content of some key files to understand nexfort's purpose
echo "=== Checking nexfort implementation ==="
cat src/onediff/infer_compiler/backends/nexfort/__init__.py

echo -e "\n=== Checking nexfort booster implementation ==="
cat onediff_comfy_nodes/modules/nexfort/booster_basic.py

echo -e "\n=== Checking requirements.txt that mentions nexfort ==="
cat onediff_comfy_nodes/docs/sd3/requirements.txt

Length of output: 4768

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 330b314 and 7f0fe0e.

📒 Files selected for processing (1)
  • .github/workflows/examples.yml (3 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/examples.yml

298-298: shellcheck reported issue in this script: SC1009:info:1:1: The mentioned syntax error was in this simple command

(shellcheck)


298-298: shellcheck reported issue in this script: SC1073:error:1:96: Couldn't parse this double quoted string. Fix to allow more checks

(shellcheck)


298-298: shellcheck reported issue in this script: SC1072:error:2:1: Expected end of double quoted string. Fix any mentioned problems and try again

(shellcheck)

🔇 Additional comments (5)
.github/workflows/examples.yml (5)

176-177: LGTM: Docker image updates

The Docker image specifications have been updated to use newer versions with PyTorch 2.3 support.

Also applies to: 183-183


286-286: Good practice: Added pip cache inspection and version pinning

The addition of pip cache inspection helps with debugging, and pinning huggingface_hub to a specific version helps ensure reproducible builds.

Also applies to: 293-294


295-297: LGTM: Conditional requirements installation

Requirements installation is properly conditioned based on the test suite being run.


299-300: LGTM: Transformer engine removal

Removing transformer-engine for ComfyUI test suite is correctly conditioned.


363-363: Verify package compatibility

The installation includes multiple packages with specific version constraints. Let's verify their compatibility.

if: matrix.test-suite == 'diffusers_examples'
- run: docker exec ${{ env.CONTAINER_NAME }} python3 -m pip install -r tests/comfyui/requirements.txt --user
if: matrix.test-suite == 'comfy'
- run: docker exec ${{ env.CONTAINER_NAME }} python3 -m pip install -r ComfyUI/requirements.txt --user"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix shell script syntax error

There's a syntax error in the pip install command - an extra quote at the end.

Apply this fix:

-      - run: docker exec ${{ env.CONTAINER_NAME }} python3 -m pip install -r ComfyUI/requirements.txt --user"
+      - run: docker exec ${{ env.CONTAINER_NAME }} python3 -m pip install -r ComfyUI/requirements.txt --user
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- run: docker exec ${{ env.CONTAINER_NAME }} python3 -m pip install -r ComfyUI/requirements.txt --user"
- run: docker exec ${{ env.CONTAINER_NAME }} python3 -m pip install -r ComfyUI/requirements.txt --user
🧰 Tools
🪛 actionlint (1.7.4)

298-298: shellcheck reported issue in this script: SC1009:info:1:1: The mentioned syntax error was in this simple command

(shellcheck)


298-298: shellcheck reported issue in this script: SC1073:error:1:96: Couldn't parse this double quoted string. Fix to allow more checks

(shellcheck)


298-298: shellcheck reported issue in this script: SC1072:error:2:1: Expected end of double quoted string. Fix any mentioned problems and try again

(shellcheck)

Comment on lines +309 to +310
- run: docker exec -w /src/onediff/onediff_comfy_nodes/benchmarks ${{ env.CONTAINER_NAME }} bash scripts/install_env.sh /app/ComfyUI
if: matrix.test-suite == 'comfy'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Script permissions need to be updated for execution

The installation script (install_env.sh) exists but lacks execution permissions (current: -rw-r--r--). This needs to be addressed for the workflow to execute properly.

  • File: onediff_comfy_nodes/benchmarks/scripts/install_env.sh needs execution permissions (chmod +x)
  • The script's contents look correct and safe:
    • It properly validates input parameters
    • Creates symbolic links for custom nodes
    • Handles CI vs local environment appropriately
    • Installs required dependencies

To fix this, you should add a step to set execution permissions before running the script:

- run: chmod +x onediff_comfy_nodes/benchmarks/scripts/install_env.sh
- run: docker exec -w /src/onediff/onediff_comfy_nodes/benchmarks ${{ env.CONTAINER_NAME }} bash scripts/install_env.sh /app/ComfyUI
🔗 Analysis chain

Verify installation script execution

The installation script is being executed in the ComfyUI environment. Let's verify its contents and execution permissions.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the installation script exists and has proper permissions
ls -l onediff_comfy_nodes/benchmarks/scripts/install_env.sh

# Check the script's contents for potential issues
cat onediff_comfy_nodes/benchmarks/scripts/install_env.sh

Length of output: 1229

@jackalcooper jackalcooper merged commit 144f9c2 into main Dec 27, 2024
2 of 6 checks passed
@jackalcooper jackalcooper deleted the refine-comfy-tests branch December 27, 2024 16:13
@coderabbitai coderabbitai bot mentioned this pull request Dec 28, 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