Skip to content

Conversation

@zhenhuaw-me
Copy link
Member

@zhenhuaw-me zhenhuaw-me commented Aug 8, 2025

Previously the build will stop if there is any mounted directory under cpp/build/.

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling when clearing folders to ensure both files and directories are safely removed, reducing the chance of unhandled errors during the process.

Previously the build will stop if there is any mounted directory under `cpp/build/`.

Signed-off-by: Zhenhua Wang <zhenhuaw@nvidia.com>
@zhenhuaw-me zhenhuaw-me self-assigned this Aug 8, 2025
@zhenhuaw-me zhenhuaw-me enabled auto-merge (squash) August 8, 2025 09:24
@zhenhuaw-me
Copy link
Member Author

/bot run

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 8, 2025

📝 Walkthrough

Walkthrough

The clear_folder function in scripts/build_wheel.py was updated to enclose both directory and file removal operations within a single try-except block, ensuring that any OSError or IOError during deletion is caught and handled uniformly. No changes were made to the function's signature or public interface.

Changes

Cohort / File(s) Change Summary
Exception Handling in clear_folder
scripts/build_wheel.py
Refactored clear_folder to wrap both directory and file removal logic in a unified try-except block.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Note

🔌 MCP (Model Context Protocol) integration is now available in Early Access!

Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
  • 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 explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this 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 or @coderabbitai title anywhere in the PR title to generate the title automatically.

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.

@tensorrt-cicd
Copy link
Collaborator

PR_Github #14599 [ run ] triggered by Bot

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)
scripts/build_wheel.py (1)

71-77: Goal achieved; tighten exception handling and skip mount points.

This change prevents the build from stopping—good. To better align with our Python guidelines and handle mount points explicitly:

  • Catch only OSError (IOError is redundant on Py3).
  • Keep the try body to the mutating call.
  • Skip mounted paths up-front.
  • Use os.unlink to make symlink/file removal intent explicit.
-        try:
-            if os.path.isdir(item_path) and not os.path.islink(item_path):
-                rmtree(item_path)
-            else:
-                os.remove(item_path)
-        except (OSError, IOError) as e:
-            print(f"Failed to remove {item_path}: {e}", file=sys.stderr)
+        # Skip mounted paths; do not attempt to remove them.
+        if os.path.ismount(item_path):
+            print(f"Skipping mounted path: {item_path}", file=sys.stderr)
+            continue
+
+        if os.path.isdir(item_path) and not os.path.islink(item_path):
+            try:
+                rmtree(item_path)
+            except OSError as e:
+                print(f"Failed to remove {item_path}: {e}", file=sys.stderr)
+        else:
+            try:
+                os.unlink(item_path)
+            except OSError as e:
+                print(f"Failed to remove {item_path}: {e}", file=sys.stderr)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9ff4e75 and d69d424.

📒 Files selected for processing (1)
  • scripts/build_wheel.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)

**/*.py: Python code should conform to Python 3.8+.
Indent Python code with 4 spaces. Do not use tabs.
Always maintain the namespace when importing in Python, even if only one class or function from a module is used.
Python filenames should use snake_case (e.g., some_file.py).
Python classes should use PascalCase (e.g., class SomeClass).
Python functions and methods should use snake_case (e.g., def my_awesome_function():).
Python local variables should use snake_case. Prefix k for variable names that start with a number (e.g., k_99th_percentile).
Python global variables should use upper snake_case and prefix G (e.g., G_MY_GLOBAL).
Python constants should use upper snake_case (e.g., MY_CONSTANT).
Avoid shadowing variables declared in an outer scope in Python.
Initialize all externally visible members of a Python class in the constructor.
For interfaces that may be used outside a Python file, prefer docstrings over comments.
Comments in Python should be reserved for code within a function, or interfaces that are local to a file.
Use Google style docstrings for Python classes and functions, which can be parsed by Sphinx.
Attributes and variables in Python can be documented inline; attribute docstrings will be rendered under the class docstring.
Avoid using reflection in Python when functionality can be easily achieved without it.
When using try-except blocks in Python, limit the except to the smallest set of errors possible.
When using try-except blocks to handle multiple possible variable types in Python, keep the body of the try as small as possible, using the else block to implement the logic.

Files:

  • scripts/build_wheel.py
**/*.{cpp,h,hpp,cc,cxx,cu,py}

📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)

All TensorRT-LLM Open Source Software code should contain an NVIDIA copyright header that includes the current year. This includes .cpp, .h, .cu, .py, and any other source files which are compiled or interpreted.

Files:

  • scripts/build_wheel.py
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
PR: NVIDIA/TensorRT-LLM#0
File: CODING_GUIDELINES.md:0-0
Timestamp: 2025-08-06T21:22:55.018Z
Learning: Applies to **/*.py : When using try-except blocks in Python, limit the except to the smallest set of errors possible.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Pre-commit Check

@tensorrt-cicd
Copy link
Collaborator

PR_Github #14599 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #11029 completed with status: 'SUCCESS'

@zhenhuaw-me zhenhuaw-me merged commit 7e33ed6 into NVIDIA:main Aug 11, 2025
5 checks passed
@zhenhuaw-me zhenhuaw-me deleted the fix-build-wheel branch August 11, 2025 12:02
MartinMarciniszyn added a commit to MartinMarciniszyn/TensorRT-LLM that referenced this pull request Aug 12, 2025
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.

3 participants