Repository navigation
[CI] Improve requirements for python 3.14 - #66731
pseudo-rnd-thoughts wants to merge 1 commit into
Conversation
Signed-off-by: Mark Towers <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces support for Python 3.14 dependency compilation by adding a dedicated compile_pip_dependencies_py314 function in ci/ci.sh, creating a py314-overrides.txt file to handle package compatibility, and updating the corresponding lock files. The review feedback suggests improving the robustness of the shell script by using mktemp to avoid hardcoded temporary file paths, splitting the tr command for better POSIX compatibility, passing multi-line variables to awk via environment variables, and correcting a minor typo in a comment.
| # A resolution failure here means a new divergence: add it to the overrides | ||
| # file with the reason. | ||
| TARGET="requirements_compiled_py3.14.txt" | ||
| local parity_constraints="/tmp/ray-deps/py314-parity-constraints.txt" |
There was a problem hiding this comment.
Using a hardcoded path in /tmp (like /tmp/ray-deps/py314-parity-constraints.txt) can cause permission conflicts on shared multi-user development machines or CI runners if the directory/file was previously created by another user. It is safer and more robust to use mktemp to generate a unique temporary file path.
| local parity_constraints="/tmp/ray-deps/py314-parity-constraints.txt" | |
| local parity_constraints | |
| parity_constraints="$(mktemp)" | |
| trap 'rm -f "${parity_constraints}"' EXIT |
| local overridden | ||
| overridden="$(sed -e 's/#.*//' -e 's/[=;<> ].*//' python/requirements/py314-overrides.txt \ | ||
| | grep -v '^$' | tr '[:upper:]_' '[:lower:]-' | sort -u)" | ||
| mkdir -p "$(dirname "${parity_constraints}")" | ||
| grep -E '^[A-Za-z0-9_.-]+==' python/requirements_compiled.txt \ | ||
| | awk -v skip="${overridden}" 'BEGIN { n = split(skip, a, "\n"); for (i = 1; i <= n; i++) s[a[i]] = 1 } | ||
| { name = tolower($0); sub(/==.*/, "", name); gsub(/_/, "-", name); if (!(name in s)) print }' \ | ||
| > "${parity_constraints}" |
There was a problem hiding this comment.
- POSIX Compatibility: Mixing character classes and literal characters in a single
trset (liketr '[:upper:]_' '[:lower:]-') can lead to undefined behavior or compatibility issues on some non-GNUtrimplementations (e.g., BSDtron macOS). Splitting this into two separatetrcommands is safer and more portable. - Robust Variable Passing: Passing a multi-line shell variable containing newlines via
awk -vcan cause syntax or parsing errors in someawkversions. Exporting the variable and accessing it viaENVIRONinsideawkis the standard, robust way to handle multi-line strings. - Redundant Directory Creation: Since
parity_constraintsis now created usingmktempdirectly in the system's temporary directory, themkdir -pcommand is no longer needed.
| local overridden | |
| overridden="$(sed -e 's/#.*//' -e 's/[=;<> ].*//' python/requirements/py314-overrides.txt \ | |
| | grep -v '^$' | tr '[:upper:]_' '[:lower:]-' | sort -u)" | |
| mkdir -p "$(dirname "${parity_constraints}")" | |
| grep -E '^[A-Za-z0-9_.-]+==' python/requirements_compiled.txt \ | |
| | awk -v skip="${overridden}" 'BEGIN { n = split(skip, a, "\n"); for (i = 1; i <= n; i++) s[a[i]] = 1 } | |
| { name = tolower($0); sub(/==.*/, "", name); gsub(/_/, "-", name); if (!(name in s)) print }' \ | |
| > "${parity_constraints}" | |
| local overridden | |
| overridden="$(sed -e 's/#.*//' -e 's/[=;<> ].*//' python/requirements/py314-overrides.txt \\ | |
| | grep -v '^$' | tr '[:upper:]' '[:lower:]' | tr '_' '-' | sort -u)" | |
| export overridden | |
| grep -E '^[A-Za-z0-9_.-]+==' python/requirements_compiled.txt \\ | |
| | awk 'BEGIN { n = split(ENVIRON["overridden"], a, "\\n"); for (i = 1; i <= n; i++) s[a[i]] = 1 } | |
| { name = tolower($0); sub(/==.*/, "", name); gsub(/_/, "-", name); if (!(name in s)) print }' \\ | |
| > "${parity_constraints}" |
| cryptography | ||
| pyopenssl | ||
|
|
||
| # pytest 7.x uses ast.Str, which Python 3.14 remove |
…ead of by hand (#66795) ## Why `python/requirements_compiled_py3.14.txt` is edited by hand. It copied most pins from the py3.11 lock, and only six were ever bumped for 3.14. About 25 other pins have no cp314 wheel (jax 0.4.33, h5py 3.12.1, pymongo 4.3.2, tensorflow 2.20, ...), and transformers was still at 4.36.2. Nobody noticed, because a constraints file only gets tested when some image actually requests a package. Once #65909 made the ray-torch py3.14 depset constrain on this file, the nightly `ray-torch.py3.14` build failed on `tokenizers==0.15.2` (no cp314 wheel). **Not a duplicate:** #66731 fixes the same failure with a uv `--override` file. An override replaces *every* requirement on a package, including the version bounds other packages declare, so conflicts compile cleanly. Its generated file pins `s3torchconnector` 1.4.3 with `s3torchconnectorclient` 1.5.0, `numcodecs` 0.17 against zarr's `<0.16`, and `numpy` 2.3.3 against lerobot's `<2.3`. This PR takes a different approach and uses no overrides, so uv enforces every dependent's bounds. ## What changed - **`ci/ci.sh compile_pip_dependencies_py314`** compiles the 3.14 file on its own, like `compile_313_pip_dependencies` did before #64257. It uses uv 0.9.26 (the version bazel pins) with `--python-version 3.14`, from the same source files as `compile_pip_dependencies`. - **Wheels only** (`--only-binary :all:`), except 12 packages that ship only an sdist for every Python version, so building them isn't a 3.14 regression. - Ray images are glibc 2.35, so it targets `manylinux_2_35`. - **Where a shared pin has no cp314 wheel, the source file gates it.** The pinned line gets `python_version < '3.14'`. Where 3.14 needs a replacement, an unpinned `python_version >= '3.14'` line is added and the resolver picks the version. This replaces the `py313/` directory copies 3.13 used to have. - **Source builds:** the 3.14 compile uses `--only-binary :all:`, so a package without a cp314 wheel fails the compile instead of quietly building from source. The exceptions are packages that never ship a wheel on any Python: sdist-only releases (crcmod, gsutil, ...) and `hyperopt`, which `tune-requirements.txt` pins to a git commit. Every Python builds those from source; the 3.10–3.13 compile just doesn't forbid it. - **The dependencies pipeline now fails if `requirements_compiled_py3.14.txt` is out of date**, the same check it already runs on the main file. - **`requirements_compiled.txt`:** marker-only changes (`python_version < "3.14"`). - **Non-3.14 deplocks:** 38 files change, marker annotations only. No versions change. - Docs: `dependency-management.md` gets a Python 3.14 section. ## 3.14 decisions (source files) | Change | Packages | |---|---| | Own pin on 3.14 (shared pin has no cp314 wheel; a `>= '3.14'` line pins the version that resolved) | numpy, numba, llvmlite, cupy-cuda12x, cffi, jax/jaxlib, h5py, mujoco, ale-py, pymunk, open-spiel, pymongo, tensordict, crc32c, pyiceberg, s3torchconnector, pytest | | Not installed on 3.14 (no usable release) | tensorflow, tf-keras, torchtext, pygame, minigrid, supersuit, tinyscaler, datasketches, fastrlock (cupy 14 dropped it), raydp (pins netifaces 0.11.0) | | Not installed on 3.14 (blocked by a dependency) | zarr + numcodecs (every zarr 2.x needs numcodecs <0.16; none has cp314 wheels), lerobot (every release caps numpy <2.3) | Notes for reviewers: - **Versions follow the existing 3.14 file:** uv keeps a pin from it whenever that pin still installs. numpy 2.3.3, numba 0.65.0, llvmlite 0.47.0, cupy 14.0.1 and pytest 8.3.3 stay where they were. Pins that had to move go to the latest release, e.g. transformers 5.19.0 (3.11 has 5.11.0) and jax 0.11.2. - **pytest 8.3.3** isn't needed for the reason #64750 gave: pytest 7.4.4 only uses `ast.Str` below Python 3.8. It's needed because locust ≥2.40 requires it, and older locust caps `gevent<25.8.1`, which has no cp314 wheel. - **urllib3 goes from 2.0.7 back to 1.26.20.** #64750 pinned 2.0.7 by hand with no stated reason. 1.26.20 imports and makes requests on CPython 3.14 with DeprecationWarnings turned into errors. - **Marker gotcha:** pip-compile writes the marker of the *last* source line, in compile order, that has a marker matching py3.11. Lines without a marker are ignored. Gating a bare `tf-keras` line after the pinned one rewrote `tf-keras==2.19.0`'s marker from `< "3.12"` to `< "3.14"`, which would have applied that pin on 3.12/3.13. So those lines are split at 3.12. - **Tests that can't run on 3.14:** with zarr, lerobot, datasketches, raydp, tensorflow and the RL env packages dropped, the tests that use them need 3.14 skips once 3.14 test jobs exist. ## User-visible change (py3.14 images) - **ray-torch py3.14:** transformers 4.57.6 → **5.19.0** (tokenizers 0.23.2, huggingface-hub 1.33.0). - **All py3.14 image locks** now install from wheels only, apart from packages that have never shipped a wheel. <details><summary>Full diff of requirements_compiled_py3.14.txt pins vs master (108 packages)</summary> **Changed (35):** accelerate 0.28.0→1.15.0, ale-py 0.10.1→0.12.1, array-record 0.5.1→0.8.3, click 8.3.2→8.5.0, crc32c 2.3→2.9.post0, cryptography 44.0.3→47.0.0, datasets 3.6.0→4.8.5, etils 1.5.2→1.14.0, evaluate 0.4.3→0.4.6, h5py 3.12.1→3.16.0, hf-xet 1.4.3→1.7.0, huggingface-hub 0.36.2→1.33.0, jax 0.4.33→0.11.2, jaxlib 0.4.33→0.11.2, mlflow / mlflow-skinny / mlflow-tracing 3.11.1→3.16.1, mujoco 3.2.4→3.15.0, onnx 1.16.0→1.23.2, open-spiel 1.4→2.0.2, py-spy 0.4.1→0.4.2, pyiceberg 0.11.0→0.12.0, pymongo 4.3.2→4.18.2, pymunk 6.2.1→7.3.0, pyopenssl 25.1.0→26.2.0, s3torchconnector 1.4.3→1.5.0, s3torchconnectorclient 1.4.3→1.5.0, safetensors 0.7.0→0.8.0, sentencepiece 0.1.96→0.2.1, snowflake-connector-python 4.3.0→4.8.0, tensordict 0.8.3→0.14.2, tokenizers 0.15.2→0.23.2, transformers 4.36.2→5.19.0, urllib3 2.0.7→1.26.20 (+ deepspeed marker only) **Added (13), all already in the shared sources:** audioop-lts, av, cuda-pathfinder, hf-gradio, mcap, obstore, onnx-ir, onnxscript, pymysql, pyvers, ray-haproxy, taskiq-redis, torchcodec **Removed (60):** the gated packages above and what only they pull in (tensorflow stack, RL envs, aim/mosaicml/hpbandster/uvloop which the sources already gate to <3.12), plus stale entries no current source requires (sphinx/myst/ruff family). </details> ## Testing Run on x86_64 Linux in a Python 3.11 venv: - `ci/ci.sh compile_pip_dependencies`, then `ci/ci.sh compile_pip_dependencies_py314`, then `bazelisk run //ci/raydepsets:raydepsets -- build --all-configs`. All succeed. - Running `compile_pip_dependencies_py314` a second time reproduces the committed file byte for byte, so the new CI check passes. This was also checked with `UV_NO_CACHE=1`, which is how CI runs it: a warm local uv cache had hidden the hyperopt failure below. - **Wheels-only install check:** each regenerated py3.14 lock passes `uv pip compile --no-deps --python-version 3.14 --python-platform x86_64-manylinux_2_35 --only-binary :all:` (minus the sdist-only list). That covers base_deps, base_extra, base_extra_testdeps, base_slim, ray_img, ray_img_cu130 and ray-torch. - **No version changes on other Pythons:** the pin sets of all 38 changed non-3.14 locks are identical to master, ignoring markers. - pytest 7.4.4 and urllib3 1.26.20 were checked on CPython 3.14.3. ## Not changed here - **datasketches in base-extra:** `docker/base-extra/requirements.in` lists it directly, so the base-extra py3.14 image still builds it from source, same as master. - **TPU py3.14 lock:** it doesn't use this constraints file, and `tensorboard-plugin-profile` there has no cp314 wheel. AI assistance (Claude Code) was used to investigate and write this change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: elliot-barn <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
Description
The nightly
wanda: ray-torch.py3.14.cu12.8.1-cudnn.basebuild fails while installingtokenizers==0.15.2. That release has no cp314 wheel, and uv can't parse its sdist'spyproject.toml.#65909 made the ray-torch depset take
requirements_compiled_py3.14.txtas constraints.That file was edited by hand and was stale. It still pinned
transformers==4.36.2from thepy313/requirements that #64257 removed. #64054 had already moved every other Pythonversion to transformers 5.x. The file also pinned other versions that can't install on 3.14
(tensorflow 2.20, tensordict 0.8.3, and others).
What changed
ci/ci.sh: newcompile_pip_dependencies_py314, which generates the file withuv pip compilefor Linux x86_64 / cp314. It uses the same sources ascompile_pip_dependencies, which now share aCOMPILE_PIP_SOURCESarray.requirements_compiled.txtis passed as a constraint. Apy3.14 pin can only differ from it if the package is listed in the overrides file, or
if the main lock gates the pin with a
python_versionmarker (grpcio, protobuf,pydantic, ...). Any other divergence fails the compile.
must install from a wheel.
python/requirements/py314-overrides.txt(new) lists every place 3.14 diverges, eachwith its reason:
ast.Str, which 3.14removed);
pygame, datasketches, ...).
ray_img, ray_img_cu130, base_deps, base_extra, base_extra_testdeps, base_slim). No
non-3.14 lock changed.
User-visible change (py3.14 ray-torch image)
The last image that built had transformers 4.57.6. It now gets transformers 5.11.0,
tokenizers 0.22.2, huggingface-hub 1.16.1, datasets 4.8.5 and sentence-transformers 6.1.0.
That matches the py3.11 ray-torch image and the rest of Ray's CI. It's a major-version bump
for anyone using the py3.14 image.
AI assistance (Claude Code) was used to investigate and write this change; I reviewed every changed line.