Repository navigation
fix(serve): pin pandas below 3.1.0 to unblock serve unit tests - #6524
Conversation
The sagemaker-serve unit-tests job runs py310/py311/py312 tox envs.
pandas is pulled in transitively (via mlflow) and is unpinned, so pip
resolves the newly released pandas 3.1.0 on py311/py312 (3.x requires
Python >=3.11). That build leaves the C extensions unbuilt in CI
("ImportError: C extension: None not built"), so pytest fails at
collection and the whole job goes red — even though py310 (pandas 2.3.3)
passes all tests. This is environment/dependency churn, unrelated to any
product change.
Pin pandas to the 2.x line in the test extra so all three envs resolve
the known-good 2.3.3 (what py310 already uses). Verified locally:
`pandas>=2.3.0,<3` resolves to 2.3.3 and imports cleanly on Python 3.12.
There was a problem hiding this comment.
🤖 AI code review
This PR adds pandas>=2.3.0,<3 to the test extra in sagemaker-serve/pyproject.toml to unblock the py311/py312 serve unit-test CI envs, which were resolving the newly released pandas 3.1.0 and failing at collection time. The change is scoped to the test extra, uses a version range rather than an exact pin, and is consistent with sibling packages (sagemaker-core uses pandas>=2.0.0, <3.0.0, sagemaker-mlops uses pandas<3.0) and the existing conda_in_process.yml pin (pandas>=2.3.0). This also aligns with prior guidance to use ranges rather than exact pins (Source: #4983). No issues found.
Reviewed commit 4288634. Automated review; verify before acting.
Refine the pin to the last-known-good state: before pandas 3.1.0 was released, the py311/py312 unit-test envs resolved pandas 3.0.6 and passed; py310 resolves 2.3.3 (pandas 3.x requires Python >=3.11). 3.1.0's wheels are built against a newer NumPy C-ABI than those envs resolve, so it fails to import at collection. `>=2.3.0,<3.1.0` restores py311/py312 to 3.0.6 and keeps py310 on 2.3.3 -- exactly the configuration that was green before the 3.1.0 release. A hard ==3.0.6 is intentionally avoided because it would break the py310 env.
There was a problem hiding this comment.
🤖 AI code review
This PR adds a pandas>=2.3.0,<3.1.0 pin to the test extra of sagemaker-serve/pyproject.toml to unblock py311/py312 unit test collection. The change is small, correct, and consistent with existing conventions elsewhere in the repo (e.g. sagemaker-core uses pandas>=2.0.0, <3.0.0). No code bugs found; one minor note about a mismatch between the PR description and the actual constraint.
Reviewed commit 372ddb3. Automated review; verify before acting.
| # pandas 3.1.0 ships wheels built against a newer NumPy C-ABI than the | ||
| # py311/py312 test envs resolve, so it fails to import ("ImportError: | ||
| # C extension: None not built") at pytest collection time. The previous | ||
| # release 3.0.6 was passing on py311/py312; py310 stays on the 2.x line |
There was a problem hiding this comment.
🟡 Low: Minor: the PR description states the constraint is pandas>=2.3.0,<3 (a hard cap below 3.x), but the actual pin here is pandas>=2.3.0,<3.1.0, which still permits pandas 3.0.x on py311/py312. The inline comment's reasoning is internally consistent (it says 3.0.6 passed and only 3.1.0 broke), so the <3.1.0 cap is intentional — just worth updating the PR description so reviewers aren't confused about which cap was actually applied. Note that team precedent (Source: #4983) discourages hard single-major caps; <3.1.0 is a narrower upper bound and acceptable, but consider whether <3.1.0 vs a future relaxation is tracked anywhere so the temporary cap doesn't linger.
Brings in the serve test extra pin `pandas>=2.3.0,<3.1.0` (aws#6524), which is what the `unit-tests (sagemaker-serve)` hook failed on: pandas 3.1.0 imports with `ImportError: C extension: None not built` on py311 and py312. --- X-AI-Prompt: Can you fix the failing PR hooks on my sagemaker-python-sdk pull request? X-AI-Tool: claude-code
Issue
unit-tests (sagemaker-serve)is failing on open PRs (e.g. #6508, #6516) — this is environment/dependency churn, not a test or code regression.The serve unit job runs three tox envs. py310 passes all 2176 tests; py311/py312 fail at pytest collection:
pandas is pulled in transitively (via mlflow) and is unpinned. The newly released pandas 3.1.0 (requires Python >= 3.11) now floats into the py311/py312 envs; its wheels are built against a newer NumPy C-ABI than those envs resolve (numpy==2.1.3), so pandas' compiled extension cannot load and import fails before any test runs. py310 is unaffected because it cannot install 3.x and stays on the working 2.3.3.
Until pandas 3.1.0 was released, py311/py312 resolved pandas 3.0.6 and passed — i.e. this went red purely due to the new release, with no code change.
Description of changes
Cap pandas below 3.1.0 in the serve
testextra, restoring the last-known-good configuration:"pandas>=2.3.0,<3.1.0",A hard
==3.0.6is intentionally avoided — it would break the py310 env, which cannot install any 3.x.Testing done
Locally, matching the CI Python versions:
pip install pandas-> 3.1.0 (the broken one);pip install "pandas>=2.3.0,<3.1.0"-> 3.0.6, andimport pandassucceeds.pip install "pandas>=2.3.0,<3.1.0"-> 2.3.3 (3.x correctly excluded).[test]extra carriespandas>=2.3.0,<3.1.0.Full validation is the serve unit job on this PR across py310/py311/py312.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.