Skip to content

test: skip incompatible pylance / python versions in compat_test.py#7811

Open
westonpace wants to merge 2 commits into
lance-format:mainfrom
westonpace:test/fix-compat-test-3-14
Open

test: skip incompatible pylance / python versions in compat_test.py#7811
westonpace wants to merge 2 commits into
lance-format:mainfrom
westonpace:test/fix-compat-test-3-14

Conversation

@westonpace

@westonpace westonpace commented Jul 15, 2026

Copy link
Copy Markdown
Member

The compat_test runs older versions of pylance to generate old datasets. When running python 3.14 it was failing with a segmentation fault. It turns out the root cause is that older versions of pylance used a pyo3 library that didn't support python 3.14 (likely called functions that were since removed). This fix skips the older compat_test runs on those versions (they will still be tested for the time being on 3.13)

This should help unblock #7728

Summary by CodeRabbit

  • Bug Fixes
    • Improved compatibility test handling by skipping known unsupported Lance/Python version combinations.
    • Tightened virtual-environment reuse so cached environments are rebuilt when Python-version metadata is missing or outdated.
    • Enhanced subprocess failure reporting by including the subprocess exit code and clearer panic/communication details.
  • Diagnostics
    • Enabled full Rust backtraces for persistent subprocess execution to simplify troubleshooting.

@westonpace
westonpace requested a review from wjones127 July 15, 2026 20:10
@github-actions github-actions Bot added A-python Python bindings chore labels Jul 15, 2026
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Compatibility test execution adds version-based skips, validates virtual environments against Lance and Python versions, improves Rust panic visibility, and reports subprocess exit or communication failures with additional detail.

Changes

Compatibility execution

Layer / File(s) Summary
Compatibility skips and venv identity
python/python/tests/compat/venv_manager.py
Adds a Lance/Python compatibility skip whitelist and stores the creating interpreter’s major and minor version in virtual-environment markers, rebuilding stale markers when needed.
Subprocess environment and failure reporting
python/python/tests/compat/venv_manager.py
Sets RUST_BACKTRACE=full, skips unsupported executions before subprocess startup, and includes subprocess exit codes plus panic or communication details in failures.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: skipping incompatible compatibility test runs for certain Python/PyLance versions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@python/python/tests/compat/venv_manager.py`:
- Around line 112-121: The _skip_reason function must include a GitHub issue URL
in the message returned for every compatibility skip. Update the returned skip
text alongside the existing _COMPAT_SKIP reference to include the relevant issue
URL, while preserving the Lance and Python version details.
- Line 318: Update the environment setup in the venv manager to assign
RUST_BACKTRACE to "full" unconditionally rather than using setdefault, ensuring
inherited values such as "0" or "1" are overridden.
- Around line 315-317: Update the environment setup near env and tests_dir so
PYTHONPATH prepends tests_dir while retaining the inherited PYTHONPATH value,
including the appropriate path separator; preserve the existing behavior when no
inherited value is present.
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f7e55f7c-362e-4a28-a760-b2f2ad62e61a

📥 Commits

Reviewing files that changed from the base of the PR and between 9effdb1 and 83f75fb.

📒 Files selected for processing (1)
  • python/python/tests/compat/venv_manager.py

Comment on lines +112 to +121
def _skip_reason(lance_version: str) -> Optional[str]:
"""Return a pytest.skip message if this lance/Python combo is whitelisted, else None."""
py = sys.version_info[:2]
for max_lance, min_python in _COMPAT_SKIP:
try:
if Version(lance_version) <= Version(max_lance) and py >= min_python:
py_str = f"{py[0]}.{py[1]}"
return (
f"Lance {lance_version} + Python {py_str}: whitelisted skip "
f"(see _COMPAT_SKIP in venv_manager.py)"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Include a GitHub issue URL in the skip reason.

The new pytest.skip() path emits only an internal code reference. Every skipped Python test must include a GitHub issue URL so this intentional compatibility exception remains traceable.

As per coding guidelines: skipped tests must include a GitHub issue URL.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@python/python/tests/compat/venv_manager.py` around lines 112 - 121, The
_skip_reason function must include a GitHub issue URL in the message returned
for every compatibility skip. Update the returned skip text alongside the
existing _COMPAT_SKIP reference to include the relevant issue URL, while
preserving the Lance and Python version details.

Source: Coding guidelines

Comment on lines 315 to 317
env = os.environ.copy()
tests_dir = Path(__file__).parent.parent
env["PYTHONPATH"] = str(tests_dir)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Preserve inherited PYTHONPATH entries.

This assignment discards any caller or CI-provided import paths. Prepend tests_dir instead of replacing the inherited value.

Proposed fix
         env = os.environ.copy()
         tests_dir = Path(__file__).parent.parent
-        env["PYTHONPATH"] = str(tests_dir)
+        inherited = env.get("PYTHONPATH")
+        env["PYTHONPATH"] = os.pathsep.join(
+            path for path in (str(tests_dir), inherited) if path
+        )
📝 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
env = os.environ.copy()
tests_dir = Path(__file__).parent.parent
env["PYTHONPATH"] = str(tests_dir)
env = os.environ.copy()
tests_dir = Path(__file__).parent.parent
inherited = env.get("PYTHONPATH")
env["PYTHONPATH"] = os.pathsep.join(
path for path in (str(tests_dir), inherited) if path
)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@python/python/tests/compat/venv_manager.py` around lines 315 - 317, Update
the environment setup near env and tests_dir so PYTHONPATH prepends tests_dir
while retaining the inherited PYTHONPATH value, including the appropriate path
separator; preserve the existing behavior when no inherited value is present.

env = os.environ.copy()
tests_dir = Path(__file__).parent.parent
env["PYTHONPATH"] = str(tests_dir)
env.setdefault("RUST_BACKTRACE", "full")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Ensure backtraces are actually configured as full.

setdefault() leaves inherited values such as RUST_BACKTRACE=0 or 1 unchanged, so this change does not guarantee the detailed traces described by the PR objective.

Proposed fix
-        env.setdefault("RUST_BACKTRACE", "full")
+        env["RUST_BACKTRACE"] = "full"
📝 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
env.setdefault("RUST_BACKTRACE", "full")
env["RUST_BACKTRACE"] = "full"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@python/python/tests/compat/venv_manager.py` at line 318, Update the
environment setup in the venv manager to assign RUST_BACKTRACE to "full"
unconditionally rather than using setdefault, ensuring inherited values such as
"0" or "1" are overridden.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
python/python/tests/compat/venv_manager.py (1)

434-445: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Invalidate the stale runner after communication failure. wait(timeout=2) can leave _subprocess set, and _ensure_subprocess() will keep treating that handle as healthy. Clear it (and terminate/kill if possible) before raising so the next call starts a fresh runner, and add a regression test for the stale-handle path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@python/python/tests/compat/venv_manager.py` around lines 434 - 445, Update
the communication-failure handler around _subprocess in the affected runner
method to terminate or kill the existing process when possible, clear
_subprocess before raising RuntimeError, and preserve the captured exit/detail
reporting. Add a regression test covering a stale handle after wait(timeout=2),
verifying the next _ensure_subprocess() call starts a fresh runner.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@python/python/tests/compat/venv_manager.py`:
- Around line 434-445: Update the communication-failure handler around
_subprocess in the affected runner method to terminate or kill the existing
process when possible, clear _subprocess before raising RuntimeError, and
preserve the captured exit/detail reporting. Add a regression test covering a
stale handle after wait(timeout=2), verifying the next _ensure_subprocess() call
starts a fresh runner.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 61e232e9-e7b5-4ac8-8d89-1bf125787f16

📥 Commits

Reviewing files that changed from the base of the PR and between 83f75fb and 8f14c4b.

📒 Files selected for processing (1)
  • python/python/tests/compat/venv_manager.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-python Python bindings chore

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants