-
Notifications
You must be signed in to change notification settings - Fork 370
/
noxfile.py
73 lines (50 loc) · 2.46 KB
/
noxfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
"""
Nox sessions.
This file is used by `nox` to run tests and examples against multiple Python versions.
See: http://nox.thea.codes
"""
from __future__ import annotations
import nox # type: ignore
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=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/compare_code_example_output.py", "--no-py-build", *extra_args)
roundtrip_cpp_built = True