Skip to content

Commit

Permalink
Add support for Python 3.12 (#4146)
Browse files Browse the repository at this point in the history
### What

* Bumps arrow to 14.0.2
* Fixes #3699
* Relates to #2445

I added a bunch of fixes to `scripts/run_all.py`, which has a marked
tendency to bit rot:
* #4710

Some workaround introduced to deal with PyTorch not 3.12 ready, see:
- #4704

TODO:
- [x] `nox -s tests-3.12` passing
- [x] `nox -s run_all-3.12 --save` passing
- [x] `nox -s roundtrips-3.12` passing
- [x] Solve this:
  ```
  ❯ pixi add pyarrow==14.0.0 
× could not determine any available versions for pyarrow on linux-64.
Either the package could not be found or version constraints on other
dependencies result in a conflict.
╰─▶ Cannot solve the request because of: No candidates were found for
pyarrow ==14.0.0.
  ```
- [x] Test won't pass until torch is updated for 3.12:
pytorch/pytorch#110436

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/4146) (if
applicable)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG

- [PR Build Summary](https://build.rerun.io/pr/4146)
- [Docs
preview](https://rerun.io/preview/c0e892a228fcc83e9bef7faff1e17998926ffe52/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/c0e892a228fcc83e9bef7faff1e17998926ffe52/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://ref.rerun.io/dev/bench/)
- [Wasm size tracking](https://ref.rerun.io/dev/sizes/)
  • Loading branch information
abey79 authored Jan 5, 2024
1 parent ffa74a4 commit 67d6dd8
Show file tree
Hide file tree
Showing 19 changed files with 1,878 additions and 1,032 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/contrib_rerun_py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
# TODO(jleibs): understand why deps can't be installed in the same step as the wheel
shell: bash
run: |
pip install attrs>=23.1.0 numpy>=1.23 pillow pyarrow==10.0.1 pytest==7.1.2 torch==2.1.0 typing_extensions>=4.5
pip install attrs>=23.1.0 numpy>=1.23 pillow pyarrow==14.0.2 pytest==7.1.2 torch==2.1.0 typing_extensions>=4.5
- name: Get version
id: get-version
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_build_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
shell: bash
run: |
pixi run pip uninstall rerun-sdk -y
pixi run pip install deprecated numpy>=1.23 pyarrow==10.0.1 pytest==7.1.2
pixi run pip install deprecated numpy>=1.23 pyarrow==14.0.2 pytest==7.1.2
pixi run pip install rerun-sdk --no-index --find-links wheel
- name: Verify built wheel version
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_publish_web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
run: |
pixi run pip install -r scripts/ci/requirements.txt
pixi run pip uninstall rerun-sdk -y
pixi run pip install deprecated numpy>=1.23 pyarrow==10.0.1 pytest==7.1.2
pixi run pip install deprecated numpy>=1.23 pyarrow==14.0.2 pytest==7.1.2
pixi run pip install rerun-sdk --no-index --find-links wheel
- name: Installed wheel version
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_run_notebook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
# TODO(jleibs): pull these deps from pyproject.toml
shell: bash
run: |
pip install deprecated numpy>=1.23 pillow>=9.5.0 pyarrow==10.0.1 pytest==7.1.2
pip install deprecated numpy>=1.23 pillow>=9.5.0 pyarrow==14.0.2 pytest==7.1.2
- name: Install downloaded wheel_artifact
# Now install the wheel using a specific version and --no-index to guarantee we get the version from
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_test_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ jobs:
# TODO(jleibs): understand why deps can't be installed in the same step as the wheel
shell: bash
run: |
pip install attrs>=23.1.0 numpy>=1.23 pillow pyarrow==10.0.1 pytest==7.1.2 torch==2.1.0 typing_extensions>=4.5
pip install attrs>=23.1.0 numpy>=1.23 pillow pyarrow==14.0.2 pytest==7.1.2 torch==2.1.0 typing_extensions>=4.5
- name: Get version
id: get-version
Expand Down
3 changes: 2 additions & 1 deletion examples/python/controlnet/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ opencv-python
pillow
diffusers
numpy
torch
#TODO(#4704): clean that up when pytorch is available for 3.12
torch ; python_version < "3.12"
transformers
rerun-sdk
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ pillow
requests>=2.31,<3
rerun-sdk
scipy
torch>=1.13.0
#TODO(#4704): clean that up when pytorch is available for 3.12
torch>1.13.0; python_version < "3.12"
transformers>=4.26.0
3 changes: 2 additions & 1 deletion examples/python/detect_and_track_objects/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ pillow
requests>=2.31,<3
rerun-sdk
timm==0.9.11
torch>=1.13.0
#TODO(#4704): clean that up when pytorch is available for 3.12
torch>=1.13.0 ; python_version < "3.12"
transformers
3 changes: 2 additions & 1 deletion examples/python/llm_embedding_ner/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
rerun-sdk
torch
#TODO(#4704): clean that up when pytorch is available for 3.12
torch ; python_version < "3.12"
transformers
umap-learn
5 changes: 3 additions & 2 deletions examples/python/segment_anything_model/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ numpy
opencv-python
requests>=2.31,<3
rerun-sdk
torch
torchvision
#TODO(#4704): clean that up when pytorch is available for 3.12
torch ; python_version < "3.12"
torchvision ; python_version < "3.12"
tqdm
2 changes: 1 addition & 1 deletion examples/python/signed_distance_fields/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
numpy
requests>=2.31,<3
rerun-sdk
scikit-learn==1.1.3
scikit-learn>=1.1.3
trimesh==3.15.2
51 changes: 49 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,64 @@
import nox # type: ignore


@nox.session(python=["3.8", "3.9", "3.10", "3.11"])
PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11", "3.12"]


@nox.session(python=PYTHON_VERSIONS)
def tests(session: nox.Session) -> None:
"""Run the Python test suite"""
session.install("-r", "rerun_py/requirements-build.txt")

# TODO(#4704): clean that up when torch is 3.12 compatible
if session.python == "3.12":
session.run(
"pip", "install", "torch", "torchvision", "--pre", "--index-url", "https://download.pytorch.org/whl/nightly"
)

session.install("./rerun_py")
session.run("just", "py-test", external=True)


@nox.session(python=["3.8", "3.9", "3.10", "3.11"])
@nox.session(python=PYTHON_VERSIONS)
def run_all(session: nox.Session) -> None:
"""Run all examples through the run_all.py script (pass args with: "-- <args>")"""

# TODO(#4704): clean that up when torch is 3.12 compatible
if session.python == "3.12":
session.run(
"pip", "install", "torch", "torchvision", "--pre", "--index-url", "https://download.pytorch.org/whl/nightly"
)

# Note: the run_all.py scripts installs all dependencies itself. In particular, we can install from
# examples/python/requirements.txt because it includes pyrealsense2, which is not available for mac.
session.run("python", "scripts/run_all.py", "--install-requirements", *session.posargs)


roundtrip_cpp_built = False


@nox.session(python=PYTHON_VERSIONS)
def roundtrips(session: nox.Session) -> None:
"""Run all roundtrip tests (C++ will be built only once / skip with: "-- --no-cpp-build")"""

global roundtrip_cpp_built

session.install("-r", "rerun_py/requirements-build.txt")
session.install("opencv-python")

# TODO(#4704): clean that up when torch is 3.12 compatible
if session.python == "3.12":
session.run(
"pip", "install", "torch", "torchvision", "--pre", "--index-url", "https://download.pytorch.org/whl/nightly"
)
session.install("./rerun_py")

extra_args = []
if roundtrip_cpp_built and "--no-cpp-build" not in session.posargs:
extra_args.append("--no-cpp-build")
extra_args.extend(session.posargs)

session.run("python", "tests/roundtrips.py", "--no-py-build", *extra_args)
session.run("python", "docs/code-examples/roundtrips.py", "--no-py-build", *extra_args)

roundtrip_cpp_built = True
Loading

0 comments on commit 67d6dd8

Please sign in to comment.