Skip to content

chore(deps): pin pytest below 9.2 - #6255

Merged
mday-io merged 3 commits into
SQLMesh:mainfrom
mday-io:ci/pin-pytest-below-9.2
Dec 1, 2026
Merged

mday-io merged 3 commits into
SQLMesh:mainfrom
mday-io:ci/pin-pytest-below-9.2

Conversation

@mday-io

@mday-io mday-io commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Why

Since 2026-10-31, engine-tests-cloud (bigquery) on main has failed every run. The runner either gets a shutdown signal about a minute into pytest or stops responding until the job is cancelled. Either way, no log or artifact survives.

The cause is a pytest 9.2.0 regression, pytest-dev/pytest#15281, triggered by bigframes:

  • Importing bigframes.pandas calls sys.setrecursionlimit(10_000_000). SQLMesh's BigQuery adapter imports it when it's installed, and only the BigQuery job installs the bigframes extra.
  • pytest 9.2.0, released 2026-10-27, added a check during collection that calls inspect.unwrap on every module attribute. On unittest.mock.call, __wrapped__ returns a new _Call each time, so the only limit on unwrap is sys.getrecursionlimit(). With the default of 1000 that costs nothing. With 10,000,000 it allocates until the process runs out of memory.
  • Several test modules import call at module level, so each xdist worker grows by several GB during collection, before any test runs.

Other jobs also run pytest 9.2.0, but they don't install bigframes, so they pass.

How

Pin pytest<9.2 in the dev extra. Remove the pin once a pytest release includes a fix for #15281. Two fix PRs are open upstream: pytest-dev/pytest#15283 and pytest-dev/pytest#15315.

The pin covers every job that installs the dev dependencies, which is broader than the problem, but nothing depends on 9.2.0. Python 3.9 already resolves to pytest 8.4.2, so it's unchanged.

Test Plan

On CI, the experiment in #6254 changed one dependency at a time in the BigQuery job:

Run google-cloud-bigquery grpcio pytest Result
All three pinned 3.46.2 1.84.0 9.1.1 Passed
grpcio only 3.47.0 1.84.0 9.2.0 Out of memory
google-cloud-bigquery only 3.46.2 1.85.4 9.2.0 Out of memory
pytest only 3.47.0 1.85.4 9.1.1 Passed

Locally, in a Linux container with 4 CPUs and 16 GB, like the GitHub runner, on main at d0c003bb5 with the BigQuery job's install steps and a fake service-account key:

Setup Peak memory
pytest -n auto -m bigquery, as in CI Container killed for running out of memory after about 45 s. 16 crashed xdist workers, no test reported.
pytest 9.2.0, --collect-only on tests/integrations/github/cicd/test_github_controller.py 12.5 GB, killed at the memory cap
Same, with the recursion limit set back to 1000 after importing bigframes 320 MB
pytest 9.1.1, same file 318 MB
pytest 9.1.1, full -m bigquery collection 495 MB, 172 tests collected

py-spy on the growing process shows it in FixtureManager._check_for_wrapped_fixture → inspect.unwrap → unittest.mock._Call.__getattr__.

The same thing happens without SQLMesh or bigframes: a conftest.py that calls sys.setrecursionlimit(10_000_000), plus a test file containing from unittest.mock import call, grows by about 2.3 GB per second during collection on pytest 9.2.0. On pytest 9.1.1, or with the default limit, it uses about 40 MB.

pre-commit run --files pyproject.toml passes.

Follow-ups

Checklist

  • I have run make style and fixed any issues
  • I have added tests for my changes (if applicable): not applicable, dependency pin only
  • All existing tests pass (make fast-test)
  • My commits are signed off (git commit -s) per the DCO

Summary by CodeRabbit

  • Chores
    • Restricted the supported version range for the test tooling to versions below 9.2.
    • No changes to app features or behavior are included in this update.

pytest 9.2.0 grows each xdist worker to about 3.8 GB while collecting
tests, which runs the 16 GB CI runners out of memory and kills the
BigQuery cloud engine job. See SQLMesh#6254.

Signed-off-by: mday-io <mdaytn@gmail.com>
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The development dependency declaration now limits pytest to versions below 9.2.

Changes: Pytest dependency

Layer / File(s) Summary
Development dependency cap
pyproject.toml
The development dependency now specifies pytest<9.2.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Other · Severity of issue fixed: Medium

Suggested reviewers: yuki-kakegawa, cmgoffena13

Merge Risk: Minimal · up to e7005

This dependency-only change caps pytest below 9.2 for development installs to work around CI runner failures in the BigQuery tests. It does not affect runtime behavior for end users, and no merge-blocking risk is apparent.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "chore(deps): pin pytest below 9.2" matches the single change in the changeset, which constrains the dev dependency pytest to below 9.2 in pyproject.toml. It is concise, specific, and uses a…
Linked Issues check Passed [#6254] The linked issue is open and marked 'do not merge'. Its experiment steps (CI run for this PR, three pins in the BigQuery step, version printing, live-log sampling) apply to the experiment bran…
Out of Scope Changes check Passed The whole-PR diff changes one line in pyproject.toml: the dev extra pin pytest<9.2. The pin matches the objective in the PR summary. The PR adds no test, workflow, diagnostic, or other dependency ch…
Description check Passed The description is thorough and covers the template's core sections. The Description section has a detailed Why and How explaining the pytest 9.2.0 regression (pytest-dev/pytest#15281) that triggers m…
Full details: Title check

Explanation

The title "chore(deps): pin pytest below 9.2" matches the single change in the changeset, which constrains the dev dependency pytest to below 9.2 in pyproject.toml. It is concise, specific, and uses a conventional commit prefix. It does not mention the BigQuery memory issue that motivates the pin, but that is an acceptable level of detail.

Full details: Linked Issues check

Explanation

[#6254] The linked issue is open and marked 'do not merge'. Its experiment steps (CI run for this PR, three pins in the BigQuery step, version printing, live-log sampling) apply to the experiment branch only. Its one follow-up is: if BigQuery passes, identify the pin that matters and open a clean PR with only that pin. The whole-PR diff (merge base 1f96a72 to head e700555) shows one change: "pytest" becomes "pytest&lt;9.2" in the dev extra of pyproject.toml. This PR carries only the pytest pin, not the google-cloud-bigquery or grpcio pins, CI workflow edits, or diagnostics. The pytest-only pass and the failures of the other two pins are author-reported results from #6254. This assessment does not verify them from the repository. No coding requirement from #6254 is unmet for this PR. Note: the whole-PR diff shows no explanatory comment in pyproject.toml, although the PR description and the prior assessment mention one. This does not change the verdict because the comment is not an issue requirement.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff changes one line in pyproject.toml: the dev extra pin pytest&lt;9.2. The pin matches the objective in the PR summary. The PR adds no test, workflow, diagnostic, or other dependency change. The incremental change since the previous review does not add code. The whole-PR diff shows no comment line, which is a documentation gap relative to the PR description. It is not an unrelated change, so it does not make any change out of scope.

Full details: Description check

Explanation

The description is thorough and covers the template's core sections. The Description section has a detailed Why and How explaining the pytest 9.2.0 regression (pytest-dev/pytest#15281) that triggers memory exhaustion in the BigQuery job, and why the pin to pytest<9.2 in the dev extra is the chosen remedy. The Test Plan gives a comparison table of CI experiments, local reproduction results, and a minimal reproduction without SQLMesh or bigframes. The Checklist is present, with the test-addition item marked not applicable and the other items checked. The template's HTML comment placeholders were replaced with content, and the Checklist items match the template. Minor gap: the template's trailing CONTRIBUTING.md reference is not repeated, which is not critical.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: acbe8bdc-ea23-4544-bfd9-338b72647d23
Commits

Reviewing files that changed from the base of the PR and between e2b4791 and e700555.

Files selected for processing: 1

  • pyproject.toml
Files with no reviewable changes: 1

  • pyproject.toml

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Signed-off-by: mday-io <mdaytn@gmail.com>
The cause is recorded in the pull request description and the upstream pytest issue.

Signed-off-by: mday-io <mdaytn@gmail.com>
@mday-io
mday-io merged commit f4a4192 into SQLMesh:main Dec 1, 2026
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants