Fix modal deployment + update docs on ruff#430
Fix modal deployment + update docs on ruff#430ffesseler wants to merge 2 commits intoColeMurray:mainfrom
Conversation
The pre-commit hook runs `ruff` from packages/modal-infra/.venv/bin/ruff, which requires the Python environment to be set up. Before this change, the docs labeled Python setup as "Optional", causing contributors to skip it and hit a confusing "ruff: command not found" error when committing Python files. Changes: 1. Update lint-staged config to explicitly use the venv ruff path (no system-wide installation needed) 2. Clarify in SETUP_GUIDE that Python 3.12+ is required if committing Python files (was labeled Optional) 3. Add explicit warning in setup.sh when Python is missing, explaining the hook will fail This makes it clear that running .openinspect/setup.sh is mandatory before contributing Python code, while keeping Python optional if you only work on TypeScript/web layers.
📝 WalkthroughWalkthroughThese changes update setup and deployment configurations to enforce using Ruff from a dedicated virtual environment. Setup scripts and documentation are clarified to specify that Python 3.12+ is required when committing Python files, with pre-commit hooks running Ruff from the venv. A sys.path addition enables sandbox runtime imports in the deploy module. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@package.json`:
- Around line 52-53: Add a pre-commit guard in .husky/pre-commit that checks for
the ruff executable at packages/modal-infra/.venv/bin/ruff and fails fast with
an actionable message if it’s missing; specifically, test that the file is
present and executable, print a clear fix command (e.g., how to create the
virtualenv and install dev deps for modal-infra), and exit non-zero before
running lint-staged so contributors see the instruction instead of a “No such
file or directory” error.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ffd61bfe-bbb7-4629-94ac-afa81c2909be
📒 Files selected for processing (4)
.openinspect/setup.shdocs/SETUP_GUIDE.mdpackage.jsonpackages/modal-infra/deploy.py
| "packages/modal-infra/.venv/bin/ruff check --fix", | ||
| "packages/modal-infra/.venv/bin/ruff format" |
There was a problem hiding this comment.
Fail fast with an actionable error when the Ruff venv binary is missing.
Directly invoking packages/modal-infra/.venv/bin/ruff will hard-fail with a low-signal “No such file or directory” when .venv hasn’t been created yet. Add a guard in .husky/pre-commit so contributors get a clear fix command before lint-staged runs.
Proposed guard in .husky/pre-commit
# Activate modal-infra venv if it exists (provides ruff for Python linting)
if [ -f packages/modal-infra/.venv/bin/activate ]; then
. packages/modal-infra/.venv/bin/activate
fi
+if git diff --cached --name-only | grep -q '^packages/modal-infra/.*\.py$'; then
+ if [ ! -x packages/modal-infra/.venv/bin/ruff ]; then
+ echo "ERROR: packages/modal-infra/.venv/bin/ruff not found."
+ echo "Run: bash .openinspect/setup.sh"
+ exit 1
+ fi
+fi
+
npx lint-staged🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@package.json` around lines 52 - 53, Add a pre-commit guard in
.husky/pre-commit that checks for the ruff executable at
packages/modal-infra/.venv/bin/ruff and fails fast with an actionable message if
it’s missing; specifically, test that the file is present and executable, print
a clear fix command (e.g., how to create the virtualenv and install dev deps for
modal-infra), and exit non-zero before running lint-staged so contributors see
the instruction instead of a “No such file or directory” error.
Summary by CodeRabbit
Documentation
Chores