Fix debugger server failing to detect editable-installed modelopt#1270
Fix debugger server failing to detect editable-installed modelopt#1270
Conversation
Signed-off-by: Chenjie Luo <chenjiel@nvidia.com>
📝 WalkthroughWalkthroughThe server startup sequence is modified to print the configured work directory earlier in the initialization process, immediately after directory variables are defined. Additionally, the Python validation check for modelopt is simplified to use standard Python invocation instead of isolated mode with cleared environment variables. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tools/debugger/server.sh (1)
102-109:⚠️ Potential issue | 🟠 Major
check_modelopt_localcan false-pass due toPYTHONPATHinjection.
PYTHONPATHis exported at line 85 beforecheck_modelopt_localruns (line 112). Thepython -cinvocation at line 102 inherits this environment variable and will importmodeloptfrom$WORKDIReven when editable install is missing, incorrectly skippingpip install -e ".[dev]".Move the
PYTHONPATHexport to after the check runs:Fix
-# Set environment -export PYTHONPATH="$WORKDIR" - # Check for an already-running server if [[ -f "$RELAY_DIR/server.ready" ]]; then @@ if check_modelopt_local >/dev/null 2>&1; then echo "[server] modelopt already editable-installed from $WORKDIR, skipping pip install." else @@ echo "[server] Install done." fi + +# Set environment for executed commands after install/validation +export PYTHONPATH="$WORKDIR"Alternatively, use
python -I(isolated mode) in the check to prevent PYTHONPATH inheritance.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tools/debugger/server.sh` around lines 102 - 109, The PYTHONPATH export happening before the local-check allows the python -c check (the inline python invocation that imports modelopt and compares os.path.realpath against $WORKDIR) to inherit PYTHONPATH and false-pass; either move the PYTHONPATH export (the export of PYTHONPATH at line ~85) to after the check so the check runs with the normal environment, or change the check invocation to isolated mode by using python -I for the inline script (the python -c "import modelopt..." invocation) so it ignores PYTHONPATH during import.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@tools/debugger/server.sh`:
- Around line 102-109: The PYTHONPATH export happening before the local-check
allows the python -c check (the inline python invocation that imports modelopt
and compares os.path.realpath against $WORKDIR) to inherit PYTHONPATH and
false-pass; either move the PYTHONPATH export (the export of PYTHONPATH at line
~85) to after the check so the check runs with the normal environment, or change
the check invocation to isolated mode by using python -I for the inline script
(the python -c "import modelopt..." invocation) so it ignores PYTHONPATH during
import.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: e9f2eb7e-97fd-4e45-a65d-803b65262867
📒 Files selected for processing (1)
tools/debugger/server.sh
|
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## main #1270 +/- ##
===========================================
- Coverage 75.58% 55.66% -19.93%
===========================================
Files 459 458 -1
Lines 48528 48464 -64
===========================================
- Hits 36681 26976 -9705
- Misses 11847 21488 +9641
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
PYTHONPATH="" python -Ioverride incheck_modelopt_local()so the PYTHONPATH validation uses the actual environment instead of an isolated oneserver.shfor better debugging visibilityTest plan
server.shinside a Docker container and verify it correctly detects editable-installed modelopt🤖 Generated with Claude Code
Summary by CodeRabbit