Skip to content

Commit d324b84

Browse files
emilkgrtlr
andauthored
Python/CI: Raise exception on warning, e.g. call of @deprecated (#9384)
### Related * #9338 ### What We do not want to call deprecated functions from our examples and snippets (it sets a bad example!). Unfortunately there is nothing stopping us from doing so right now. Until this PR. With `PYTHONWARNINGS="error"` _any_ Python `warning` results in an exception, which should fail the example/snippet. ### TODO * [x] `@rerun-bot full-check` --------- Co-authored-by: Jochen Görtler <[email protected]>
1 parent 244676d commit d324b84

File tree

15 files changed

+31
-15
lines changed

15 files changed

+31
-15
lines changed

.github/workflows/reusable_test_wheels.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ jobs:
195195
- name: Check for release checklist
196196
if: ${{ inputs.FAST }}
197197
# Only check that the release checklist executes successfully
198-
run: RUST_LOG=warn RERUN_STRICT=1 pixi run -e wheel-test-min python tests/python/release_checklist/main.py --stdout > /dev/null
198+
run: RUST_LOG=warn RERUN_STRICT=1 PYTHONWARNINGS=error pixi run -e wheel-test-min python tests/python/release_checklist/main.py --stdout > /dev/null
199199

200200
- name: Build C++ roundtrips
201201
if: ${{ !inputs.FAST }}

crates/build/re_dev_tools/src/build_examples/rrd.rs

+4
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ impl Example {
9090
cmd.env("RERUN_FLUSH_TICK_SECS", 1_000_000_000.to_string());
9191
cmd.env("RERUN_FLUSH_NUM_BYTES", (128 * 1024).to_string());
9292

93+
cmd.env("PYTHONWARNINGS", "error"); // raise exception on warnings, e.g. when using a @deprecated function
94+
cmd.env("RERUN_PANIC_ON_WARN", "1"); // any logged warnings/errors should cause a failure
95+
cmd.env("RERUN_STRICT", "1"); // any misuse of the API should cause a failure
96+
9397
wait_for_output(cmd, &self.name, progress)?;
9498
}
9599

crates/build/re_dev_tools/src/build_examples/snippets.rs

+1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ impl Snippet {
167167
cmd.args(&self.extra_args);
168168

169169
cmd.envs([
170+
("PYTHONWARNINGS", "error"), // raise exception on warnings, e.g. when using a @deprecated function
170171
("RERUN_FLUSH_NUM_ROWS", "0"),
171172
("RERUN_STRICT", "1"),
172173
("RERUN_PANIC_ON_WARN", "1"),

docs/snippets/all/archetypes/transform3d_hierarchy.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@
4848
"sun/planet/moon",
4949
rr.Transform3D(
5050
translation=[np.cos(r_moon) * d_moon, np.sin(r_moon) * d_moon, 0.0],
51-
from_parent=True,
51+
relation=rr.TransformRelation.ChildFromParent,
5252
),
5353
)

examples/python/arkit_scenes/arkit_scenes/__main__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def read_camera_from_world(traj_string: str) -> tuple[str, rr.Transform3D]:
141141
camera_from_world = rr.Transform3D(
142142
translation=translation,
143143
rotation=rr.Quaternion(xyzw=rotation.as_quat()),
144-
from_parent=True,
144+
relation=rr.TransformRelation.ChildFromParent,
145145
)
146146

147147
return (ts, camera_from_world)

examples/python/live_depth_sensor/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ rr.log(
4949
rr.Transform3D(
5050
translation=rgb_from_depth.translation,
5151
mat3x3=np.reshape(rgb_from_depth.rotation, (3, 3)),
52-
from_parent=True,
52+
relation=rr.TransformRelation.ChildFromParent,
5353
),
5454
static=True,
5555
)

examples/python/live_depth_sensor/live_depth_sensor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def run_realsense(num_frames: int | None) -> None:
4444
rr.Transform3D(
4545
translation=rgb_from_depth.translation,
4646
mat3x3=np.reshape(rgb_from_depth.rotation, (3, 3)),
47-
from_parent=True,
47+
relation=rr.TransformRelation.ChildFromParent,
4848
),
4949
static=True,
5050
)

examples/python/structure_from_motion/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ This defines how to go from the 3D camera frame to the 2D image plane. The extri
5858
[`Transform3D`](https://www.rerun.io/docs/reference/types/archetypes/transform3d) to the `camera` entity.
5959

6060
```python
61-
rr.log("camera", rr.Transform3D(translation=image.tvec, rotation=rr.Quaternion(xyzw=quat_xyzw), from_parent=True))
61+
rr.log("camera", rr.Transform3D(translation=image.tvec, rotation=rr.Quaternion(xyzw=quat_xyzw), relation=rr.TransformRelation.ChildFromParent))
6262
```
6363

6464
```python

examples/python/structure_from_motion/structure_from_motion/__main__.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,11 @@ def read_and_log_sparse_reconstruction(dataset_path: Path, filter_output: bool,
145145
# COLMAP's camera transform is "camera from world"
146146
rr.log(
147147
"camera",
148-
rr.Transform3D(translation=image.tvec, rotation=rr.Quaternion(xyzw=quat_xyzw), from_parent=True),
148+
rr.Transform3D(
149+
translation=image.tvec,
150+
rotation=rr.Quaternion(xyzw=quat_xyzw),
151+
relation=rr.TransformRelation.ChildFromParent,
152+
),
149153
)
150154
rr.log("camera", rr.ViewCoordinates.RDF, static=True) # X=Right, Y=Down, Z=Forward
151155

pixi.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -457,13 +457,13 @@ cpp-build-log-benchmark = { cmd = "cmake --build build/release --config Release
457457
cpp-build-plot-dashboard-stress = { cmd = "cmake --build build/release --config Release --target plot_dashboard_stress", depends-on = [
458458
"cpp-prepare-release",
459459
] }
460-
cpp-test = { cmd = "export RERUN_STRICT=1 && ./build/debug/rerun_cpp/tests/rerun_sdk_tests", depends-on = [
460+
cpp-test = { cmd = "export RERUN_STRICT=1 PYTHONWARNINGS=error && ./build/debug/rerun_cpp/tests/rerun_sdk_tests", depends-on = [
461461
"cpp-build-tests",
462462
] }
463-
cpp-log-benchmark = { cmd = "export RERUN_STRICT=1 && ./build/release/tests/cpp/log_benchmark/log_benchmark", depends-on = [
463+
cpp-log-benchmark = { cmd = "export RERUN_STRICT=1 PYTHONWARNINGS=error && ./build/release/tests/cpp/log_benchmark/log_benchmark", depends-on = [
464464
"cpp-build-log-benchmark",
465465
] }
466-
cpp-plot-dashboard = { cmd = "export RERUN_STRICT=1 && ./build/release/tests/cpp/plot_dashboard_stress/plot_dashboard_stress", depends-on = [
466+
cpp-plot-dashboard = { cmd = "export RERUN_STRICT=1 PYTHONWARNINGS=error && ./build/release/tests/cpp/plot_dashboard_stress/plot_dashboard_stress", depends-on = [
467467
"cpp-build-plot-dashboard-stress",
468468
] }
469469
cpp-build-and-test-all = { depends-on = ["cpp-build-all", "cpp-test"] }

rerun_py/rerun_sdk/rerun/archetypes/transform3d.py

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/roundtrip_utils.py

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ def run(
5151
def roundtrip_env(*, save_path: str | None = None) -> dict[str, str]:
5252
env = os.environ.copy()
5353

54+
# raise exception on warnings, e.g. when using a @deprecated function:
55+
env["PYTHONWARNINGS"] = "error"
56+
5457
# NOTE: Make sure to disable batching, otherwise the Arrow concatenation logic within
5558
# the batcher will happily insert uninitialized padding bytes as needed!
5659
env["RERUN_FLUSH_NUM_ROWS"] = "0"

scripts/run_python_e2e_test.py

+4
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ def main() -> None:
7878

7979
def run_example(example: str, extra_args: list[str]) -> None:
8080
env = os.environ.copy()
81+
82+
# raise exception on warnings, e.g. when using a @deprecated function:
83+
env["PYTHONWARNINGS"] = "error"
84+
8185
env["RERUN_STRICT"] = "1"
8286
env["RERUN_PANIC_ON_WARN"] = "1"
8387

tests/python/roundtrips/transform3d/main.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def main() -> None:
2020

2121
rr.log(
2222
"transform/translation",
23-
rr.Transform3D(translation=[1, 2, 3], from_parent=True),
23+
rr.Transform3D(translation=[1, 2, 3], relation=rr.TransformRelation.ChildFromParent),
2424
)
2525

2626
rr.log(
@@ -30,7 +30,7 @@ def main() -> None:
3030

3131
rr.log(
3232
"transform/translation_scale",
33-
rr.Transform3D(translation=[1, 2, 3], scale=42, from_parent=True),
33+
rr.Transform3D(translation=[1, 2, 3], scale=42, relation=rr.TransformRelation.ChildFromParent),
3434
)
3535

3636
rr.log(
@@ -47,7 +47,7 @@ def main() -> None:
4747
translation=[1, 2, 3],
4848
rotation=RotationAxisAngle([0.2, 0.2, 0.8], pi),
4949
scale=42,
50-
from_parent=True,
50+
relation=rr.TransformRelation.ChildFromParent,
5151
),
5252
)
5353

tests/python/test_api/test_api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def transforms() -> None:
111111
# Log a transform from parent to child with a translation and skew along y and x.
112112
rr.log(
113113
"transforms/child_from_parent_translation",
114-
rr.Transform3D(translation=(-1, 0, 0), from_parent=True),
114+
rr.Transform3D(translation=(-1, 0, 0), relation=rr.TransformRelation.ChildFromParent),
115115
)
116116

117117
# Log translation only.

0 commit comments

Comments
 (0)