Skip to content

Fix modal deployment + update docs on ruff#430

Closed
ffesseler wants to merge 2 commits intoColeMurray:mainfrom
Mozza-AI:fix/modal-deployment
Closed

Fix modal deployment + update docs on ruff#430
ffesseler wants to merge 2 commits intoColeMurray:mainfrom
Mozza-AI:fix/modal-deployment

Conversation

@ffesseler
Copy link
Copy Markdown
Contributor

@ffesseler ffesseler commented Mar 28, 2026

Summary by CodeRabbit

  • Documentation

    • Clarified Python 3.12+ is required for pre-commit hooks when committing Python files.
    • Reorganized setup prerequisites to distinguish required vs. optional dependencies.
    • Clarified Modal CLI is optional for running/deploying sandboxes.
  • Chores

    • Enhanced setup validation messages with explicit guidance for resolving pre-commit failures.

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.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 28, 2026

📝 Walkthrough

Walkthrough

These 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

Cohort / File(s) Summary
Setup & Documentation
.openinspect/setup.sh, docs/SETUP_GUIDE.md
Clarified Python 3.12+ requirements as mandatory for committing Python files (due to pre-commit hook using venv Ruff), with explicit guidance on venv location and failure recovery steps.
Lint Configuration
package.json
Updated lint-staged Ruff commands from global invocations to explicit venv binary paths (packages/modal-infra/.venv/bin/ruff) for Python files in packages/modal-infra/.
Deployment Module
packages/modal-infra/deploy.py
Added packages/sandbox-runtime/src to sys.path to enable sandbox runtime imports within the deployment module.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

Down the venv path we hop with glee,
Our ruff runs true from .venv/bin, you see!
No more confusion, just clear Python ways,
Setup and deploy, now properly blessed,
With venv enforcement, we're at our best! 🚀

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: fixing Modal deployment (via sys.path changes in deploy.py) and updating documentation on ruff usage (setup.sh, SETUP_GUIDE.md, and package.json).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between b4ac213 and e6d3cd8.

📒 Files selected for processing (4)
  • .openinspect/setup.sh
  • docs/SETUP_GUIDE.md
  • package.json
  • packages/modal-infra/deploy.py

Comment thread package.json
Comment on lines +52 to +53
"packages/modal-infra/.venv/bin/ruff check --fix",
"packages/modal-infra/.venv/bin/ruff format"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

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.

@ColeMurray ColeMurray closed this Apr 18, 2026
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