From 76d3864d6cd92c479cb74156817af87a8f34aacf Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Tue, 4 Jul 2023 15:52:19 +0200 Subject: [PATCH 01/20] add roundtrip test for points2d archetype (py) --- .gitignore | 1 + justfile | 2 +- tests/python/roundtrips/points2d/main.py | 54 ++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100755 tests/python/roundtrips/points2d/main.py diff --git a/.gitignore b/.gitignore index 9aa1f538de1a..69b54b688e42 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ screenshot*.png web_demo .nox/ +out.rrd diff --git a/justfile b/justfile index b3c0f522f7b0..2677a8f629f5 100644 --- a/justfile +++ b/justfile @@ -27,7 +27,7 @@ cpp-format: ### Python -py_folders := "examples rerun_py scripts docs/code-examples" +py_folders := "docs/code-examples examples rerun_py scripts tests" # Set up a Pythonvirtual environment for development py-dev-env: diff --git a/tests/python/roundtrips/points2d/main.py b/tests/python/roundtrips/points2d/main.py new file mode 100755 index 000000000000..2cfe10df13f6 --- /dev/null +++ b/tests/python/roundtrips/points2d/main.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 + +from __future__ import annotations + +import argparse +import itertools + +import numpy as np +import rerun as rr +from rerun._rerun2 import components as rrc + + +def main() -> None: + points = np.array([1, 2, 3, 4], dtype=np.float32) + radii = np.array([0.42, 0.43], dtype=np.float32) + colors = np.array( + [ + 0xAA0000CC, + 0x00BB00DD, + ], + dtype=np.uint32, + ) + labels = ["hello", "friend"] + draw_order = 300 + class_ids = np.array([126, 127], dtype=np.uint64) + keypoint_ids = np.array([2, 3], dtype=np.uint64) + instance_keys = np.array([66, 666], dtype=np.uint64) + + points2d = rr.Points2D( + points, # type: ignore[arg-type] + radii=radii, # type: ignore[arg-type] + colors=colors, # type: ignore[arg-type] + labels=labels, # type: ignore[arg-type] + draw_order=draw_order, # type: ignore[arg-type] + class_ids=class_ids, # type: ignore[arg-type] + keypoint_ids=keypoint_ids, # type: ignore[arg-type] + instance_keys=instance_keys, # type: ignore[arg-type] + ) + + parser = argparse.ArgumentParser(description="Logs rich data using the Rerun SDK.") + rr.script_add_args(parser) + args = parser.parse_args() + + rr.script_setup(args, "roundtrip_points2d") + + rr.log_any("points2d", points2d) + # Hack to establish 2d view bounds + rr.log_rect("rect", [0, 0, 4, 6]) + + rr.script_teardown(args) + + +if __name__ == "__main__": + main() From e4ac8fadae2079fb4a30f7de0c1122e37c67625c Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Tue, 4 Jul 2023 15:53:47 +0200 Subject: [PATCH 02/20] add roundtrip test for points2d archetype (rs) --- Cargo.lock | 9 +++++ Cargo.toml | 1 + tests/rust/roundtrips/points2d/Cargo.toml | 13 ++++++ tests/rust/roundtrips/points2d/src/main.rs | 47 ++++++++++++++++++++++ tests/rust/test_api/Cargo.toml | 8 ++-- 5 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 tests/rust/roundtrips/points2d/Cargo.toml create mode 100644 tests/rust/roundtrips/points2d/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index f1800979efac..5021473ac689 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4943,6 +4943,15 @@ dependencies = [ "serde", ] +[[package]] +name = "roundtrip_points2d" +version = "0.8.0-alpha.0" +dependencies = [ + "anyhow", + "clap", + "rerun", +] + [[package]] name = "run_wasm" version = "0.8.0-alpha.0" diff --git a/Cargo.toml b/Cargo.toml index 17d93fcf4703..9c868d7d89d0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ members = [ "rerun_py", "run_wasm", "tests/rust/test_*", + "tests/rust/roundtrips/points2d", ] [workspace.package] diff --git a/tests/rust/roundtrips/points2d/Cargo.toml b/tests/rust/roundtrips/points2d/Cargo.toml new file mode 100644 index 000000000000..b30f9b2b3c69 --- /dev/null +++ b/tests/rust/roundtrips/points2d/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "roundtrip_points2d" +edition.workspace = true +license.workspace = true +publish = false +rust-version.workspace = true +version.workspace = true + +[dependencies] +rerun = { path = "../../../../crates/rerun", features = ["native_viewer"] } + +anyhow = "1.0" +clap = { version = "4.0", features = ["derive"] } diff --git a/tests/rust/roundtrips/points2d/src/main.rs b/tests/rust/roundtrips/points2d/src/main.rs new file mode 100644 index 000000000000..cf86a5208de7 --- /dev/null +++ b/tests/rust/roundtrips/points2d/src/main.rs @@ -0,0 +1,47 @@ +use rerun::{ + components::Rect2D, experimental::archetypes::Points2D, external::re_log, MsgSender, + RecordingStream, +}; + +#[derive(Debug, clap::Parser)] +#[clap(author, version, about)] +struct Args { + #[command(flatten)] + rerun: rerun::clap::RerunArgs, +} + +fn run(rec_stream: &RecordingStream, _args: &Args) -> anyhow::Result<()> { + MsgSender::from_archetype( + "points2d", + &Points2D::new([(1.0, 2.0), (3.0, 4.0)]) + .with_radii([0.42, 0.43]) + .with_colors([0xAA0000CC, 0x00BB00DD]) + .with_labels(["hello", "friend"]) + .with_draw_order(300.0) + .with_class_ids([126, 127]) + .with_keypoint_ids([2, 3]) + .with_instance_keys([66, 666]), + )? + .send(rec_stream)?; + + // Hack to establish 2d view bounds + MsgSender::new("rect") + .with_component(&[Rect2D::from_xywh(0.0, 0.0, 4.0, 6.0)])? + .send(rec_stream)?; + + Ok(()) +} + +fn main() -> anyhow::Result<()> { + re_log::setup_native_logging(); + + use clap::Parser as _; + let args = Args::parse(); + + let default_enabled = true; + args.rerun + .clone() + .run("roundtrip_points2d", default_enabled, move |rec_stream| { + run(&rec_stream, &args).unwrap(); + }) +} diff --git a/tests/rust/test_api/Cargo.toml b/tests/rust/test_api/Cargo.toml index c0a36e6f95af..0442b77beca1 100644 --- a/tests/rust/test_api/Cargo.toml +++ b/tests/rust/test_api/Cargo.toml @@ -1,10 +1,10 @@ [package] name = "test_api" -version = "0.8.0-alpha.0" -edition = "2021" -rust-version = "1.69" -license = "MIT OR Apache-2.0" +edition.workspace = true +license.workspace = true publish = false +rust-version.workspace = true +version.workspace = true [dependencies] rerun = { path = "../../../crates/rerun", features = [ From c3ed91f372ec66f053d43e98b1285179508940c3 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Tue, 4 Jul 2023 17:10:02 +0200 Subject: [PATCH 03/20] add scripts/ci/run_e2e_roundtrip_tests.py --- scripts/ci/run_e2e_roundtrip_tests.py | 91 +++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100755 scripts/ci/run_e2e_roundtrip_tests.py diff --git a/scripts/ci/run_e2e_roundtrip_tests.py b/scripts/ci/run_e2e_roundtrip_tests.py new file mode 100755 index 000000000000..dcaaf5d76991 --- /dev/null +++ b/scripts/ci/run_e2e_roundtrip_tests.py @@ -0,0 +1,91 @@ +#!/usr/bin/env python3 + +""" +This runs our end-to-end cross-language roundtrip tests for all SDKs. + +The list of archetypes is read directly from `crates/re_types/definitions/rerun/archetypes`. +If you create a new archetype definition without end-to-end tests, this will fail. +""" + +from __future__ import annotations + +import argparse +import os +import subprocess +import sys +import time +from os import listdir +from os.path import isfile, join + +ARCHETYPES_PATH = "crates/re_types/definitions/rerun/archetypes" + + +def main() -> None: + parser = argparse.ArgumentParser(description="Runs end-to-end tests of select python example.") + parser.add_argument("--no-build", action="store_true", help="Skip building rerun-sdk") + + if parser.parse_args().no_build: + print("Skipping building rerun-sdk - assuming it is already built and up-to-date!") + else: + build_env = os.environ.copy() + if "RUST_LOG" in build_env: + del build_env["RUST_LOG"] # The user likely only meant it for the actual tests; not the setup + + print("----------------------------------------------------------") + print("Building rerun-sdk…") + start_time = time.time() + subprocess.Popen(["just", "py-build", "--quiet"], env=build_env).wait() + elapsed = time.time() - start_time + print(f"rerun-sdk built in {elapsed:.1f} seconds") + print("") + + files = [f for f in listdir(ARCHETYPES_PATH) if isfile(join(ARCHETYPES_PATH, f))] + archetypes = [filename for filename, extension in [os.path.splitext(file) for file in files] if extension == ".fbs"] + + for arch in archetypes: + python_output_path = run_roundtrip_python(arch) + rust_output_path = run_roundtrip_rust(arch) + run_comparison(python_output_path, rust_output_path) + + +def run_roundtrip_python(arch: str) -> str: + main_path = f"tests/python/roundtrips/{arch}/main.py" + output_path = f"tests/python/roundtrips/{arch}/out.rrd" + + # sys.executable: the absolute path of the executable binary for the Python interpreter + python_executable = sys.executable + if python_executable is None: + python_executable = "python3" + + cmd = [python_executable, main_path, "--save", output_path] + roundtrip_process = subprocess.Popen(cmd) + print(cmd) + returncode = roundtrip_process.wait(timeout=30) + assert returncode == 0, f"python roundtrip process exited with error code {returncode}" + + return output_path + + +def run_roundtrip_rust(arch: str) -> str: + project_name = f"roundtrip_{arch}" + output_path = f"tests/rust/roundtrips/{arch}/out.rrd" + + cmd = ["cargo", "r", "--quiet", "-p", project_name, "--", "--save", output_path] + roundtrip_process = subprocess.Popen(cmd) + print(cmd) + returncode = roundtrip_process.wait(timeout=30) + assert returncode == 0, f"rust roundtrip process exited with error code {returncode}" + + return output_path + + +def run_comparison(python_output_path: str, rust_output_path: str): + cmd = ["cargo", "r", "-p", "rerun-cli", "--quiet", "--", "compare", python_output_path, rust_output_path] + roundtrip_process = subprocess.Popen(cmd) + print(cmd) + returncode = roundtrip_process.wait(timeout=30) + assert returncode == 0, f"comparison process exited with error code {returncode}" + + +if __name__ == "__main__": + main() From f351991e24ab96ffdf38850debebdbd7c94918c7 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Tue, 4 Jul 2023 17:10:49 +0200 Subject: [PATCH 04/20] update build_and_test_wheels to run roundtrip tests --- .github/workflows/reusable_build_and_test_wheels.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/reusable_build_and_test_wheels.yml b/.github/workflows/reusable_build_and_test_wheels.yml index 196a9f03425c..98377094953b 100644 --- a/.github/workflows/reusable_build_and_test_wheels.yml +++ b/.github/workflows/reusable_build_and_test_wheels.yml @@ -273,6 +273,11 @@ jobs: shell: bash run: RUST_LOG=debug scripts/run_python_e2e_test.py --no-build # rerun-sdk is already built and installed + - name: Run e2e roundtrip tests + if: needs.set-config.outputs.RUN_TESTS == 'true' + shell: bash + run: RUST_LOG=debug scripts/ci/run_e2e_roundtrip_tests.py --no-build # rerun-sdk is already built and installed + - name: Cache RRD dataset if: needs.set-config.outputs.RUN_TESTS == 'true' id: dataset From 4f7a1dac11c0ed259ebb461acc0353d315012df7 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Tue, 4 Jul 2023 17:11:05 +0200 Subject: [PATCH 05/20] make the roundtrip test fail on purpose --- tests/python/roundtrips/points2d/main.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/python/roundtrips/points2d/main.py b/tests/python/roundtrips/points2d/main.py index 2cfe10df13f6..99d96e218eb6 100755 --- a/tests/python/roundtrips/points2d/main.py +++ b/tests/python/roundtrips/points2d/main.py @@ -3,11 +3,9 @@ from __future__ import annotations import argparse -import itertools import numpy as np import rerun as rr -from rerun._rerun2 import components as rrc def main() -> None: From da8c6c7a177703ee2ab724cc1a7bc41532ba08f6 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Tue, 4 Jul 2023 17:14:54 +0200 Subject: [PATCH 06/20] apparently 'this' is a forbidden word, scary times --- scripts/ci/run_e2e_roundtrip_tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/ci/run_e2e_roundtrip_tests.py b/scripts/ci/run_e2e_roundtrip_tests.py index dcaaf5d76991..224b8b4c5c26 100755 --- a/scripts/ci/run_e2e_roundtrip_tests.py +++ b/scripts/ci/run_e2e_roundtrip_tests.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -This runs our end-to-end cross-language roundtrip tests for all SDKs. +Run our end-to-end cross-language roundtrip tests for all SDKs. The list of archetypes is read directly from `crates/re_types/definitions/rerun/archetypes`. If you create a new archetype definition without end-to-end tests, this will fail. @@ -21,7 +21,7 @@ def main() -> None: - parser = argparse.ArgumentParser(description="Runs end-to-end tests of select python example.") + parser = argparse.ArgumentParser(description="Run our end-to-end cross-language roundtrip tests for all SDK") parser.add_argument("--no-build", action="store_true", help="Skip building rerun-sdk") if parser.parse_args().no_build: From 5139c951a592bc64e2342b43b54344f8fde6a6c4 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Tue, 4 Jul 2023 17:16:48 +0200 Subject: [PATCH 07/20] missing docs --- tests/python/roundtrips/points2d/main.py | 2 ++ tests/rust/roundtrips/points2d/src/main.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/python/roundtrips/points2d/main.py b/tests/python/roundtrips/points2d/main.py index 99d96e218eb6..b3323cfc6408 100755 --- a/tests/python/roundtrips/points2d/main.py +++ b/tests/python/roundtrips/points2d/main.py @@ -1,3 +1,5 @@ +"""Logs a `Points2D` archetype for roundtrip checks.""" + #!/usr/bin/env python3 from __future__ import annotations diff --git a/tests/rust/roundtrips/points2d/src/main.rs b/tests/rust/roundtrips/points2d/src/main.rs index cf86a5208de7..d9eb15624442 100644 --- a/tests/rust/roundtrips/points2d/src/main.rs +++ b/tests/rust/roundtrips/points2d/src/main.rs @@ -1,3 +1,5 @@ +//! Logs a `Points2D` archetype for roundtrip checks. + use rerun::{ components::Rect2D, experimental::archetypes::Points2D, external::re_log, MsgSender, RecordingStream, From accc5e8337cf94eb7c39416ded946dc46b66a379 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Tue, 4 Jul 2023 17:44:52 +0200 Subject: [PATCH 08/20] go easy on the timeouts, the ci is _SLOW_ --- scripts/ci/run_e2e_roundtrip_tests.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/ci/run_e2e_roundtrip_tests.py b/scripts/ci/run_e2e_roundtrip_tests.py index 224b8b4c5c26..6b2dbd2cdec4 100755 --- a/scripts/ci/run_e2e_roundtrip_tests.py +++ b/scripts/ci/run_e2e_roundtrip_tests.py @@ -60,7 +60,7 @@ def run_roundtrip_python(arch: str) -> str: cmd = [python_executable, main_path, "--save", output_path] roundtrip_process = subprocess.Popen(cmd) print(cmd) - returncode = roundtrip_process.wait(timeout=30) + returncode = roundtrip_process.wait(timeout=600) assert returncode == 0, f"python roundtrip process exited with error code {returncode}" return output_path @@ -73,7 +73,7 @@ def run_roundtrip_rust(arch: str) -> str: cmd = ["cargo", "r", "--quiet", "-p", project_name, "--", "--save", output_path] roundtrip_process = subprocess.Popen(cmd) print(cmd) - returncode = roundtrip_process.wait(timeout=30) + returncode = roundtrip_process.wait(timeout=600) assert returncode == 0, f"rust roundtrip process exited with error code {returncode}" return output_path @@ -83,7 +83,7 @@ def run_comparison(python_output_path: str, rust_output_path: str): cmd = ["cargo", "r", "-p", "rerun-cli", "--quiet", "--", "compare", python_output_path, rust_output_path] roundtrip_process = subprocess.Popen(cmd) print(cmd) - returncode = roundtrip_process.wait(timeout=30) + returncode = roundtrip_process.wait(timeout=600) assert returncode == 0, f"comparison process exited with error code {returncode}" From 0ee89839bc2b75ac91ff46a941a2f14491db83ea Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Tue, 4 Jul 2023 18:05:52 +0200 Subject: [PATCH 09/20] bruh wth is the CI even doing --- scripts/ci/run_e2e_roundtrip_tests.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/ci/run_e2e_roundtrip_tests.py b/scripts/ci/run_e2e_roundtrip_tests.py index 6b2dbd2cdec4..7e2d47854b16 100755 --- a/scripts/ci/run_e2e_roundtrip_tests.py +++ b/scripts/ci/run_e2e_roundtrip_tests.py @@ -34,7 +34,7 @@ def main() -> None: print("----------------------------------------------------------") print("Building rerun-sdk…") start_time = time.time() - subprocess.Popen(["just", "py-build", "--quiet"], env=build_env).wait() + subprocess.Popen(["just", "py-build"], env=build_env).wait() elapsed = time.time() - start_time print(f"rerun-sdk built in {elapsed:.1f} seconds") print("") @@ -58,8 +58,8 @@ def run_roundtrip_python(arch: str) -> str: python_executable = "python3" cmd = [python_executable, main_path, "--save", output_path] - roundtrip_process = subprocess.Popen(cmd) print(cmd) + roundtrip_process = subprocess.Popen(cmd) returncode = roundtrip_process.wait(timeout=600) assert returncode == 0, f"python roundtrip process exited with error code {returncode}" @@ -70,19 +70,19 @@ def run_roundtrip_rust(arch: str) -> str: project_name = f"roundtrip_{arch}" output_path = f"tests/rust/roundtrips/{arch}/out.rrd" - cmd = ["cargo", "r", "--quiet", "-p", project_name, "--", "--save", output_path] - roundtrip_process = subprocess.Popen(cmd) + cmd = ["cargo", "r", "-p", project_name, "--", "--save", output_path] print(cmd) - returncode = roundtrip_process.wait(timeout=600) + roundtrip_process = subprocess.Popen(cmd) + returncode = roundtrip_process.wait(timeout=6000) assert returncode == 0, f"rust roundtrip process exited with error code {returncode}" return output_path def run_comparison(python_output_path: str, rust_output_path: str): - cmd = ["cargo", "r", "-p", "rerun-cli", "--quiet", "--", "compare", python_output_path, rust_output_path] - roundtrip_process = subprocess.Popen(cmd) + cmd = ["cargo", "r", "-p", "rerun-cli", "--", "compare", python_output_path, rust_output_path] print(cmd) + roundtrip_process = subprocess.Popen(cmd) returncode = roundtrip_process.wait(timeout=600) assert returncode == 0, f"comparison process exited with error code {returncode}" From 784b3fcd23cec36f2c7b8938df3fd050a6a3dc72 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Tue, 4 Jul 2023 18:25:25 +0200 Subject: [PATCH 10/20] make the roundtrip test fail on purpose --- tests/python/roundtrips/points2d/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/python/roundtrips/points2d/main.py b/tests/python/roundtrips/points2d/main.py index b3323cfc6408..7312f036816a 100755 --- a/tests/python/roundtrips/points2d/main.py +++ b/tests/python/roundtrips/points2d/main.py @@ -16,7 +16,7 @@ def main() -> None: colors = np.array( [ 0xAA0000CC, - 0x00BB00DD, + 0x00BB00DE, ], dtype=np.uint32, ) From 354fe63dddb574dfe54ae5df5625baf547aa4f3d Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Wed, 5 Jul 2023 09:18:43 +0200 Subject: [PATCH 11/20] no need to build the cli for the ultimate comparison --- scripts/ci/run_e2e_roundtrip_tests.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/ci/run_e2e_roundtrip_tests.py b/scripts/ci/run_e2e_roundtrip_tests.py index 7e2d47854b16..1d33b68a25d4 100755 --- a/scripts/ci/run_e2e_roundtrip_tests.py +++ b/scripts/ci/run_e2e_roundtrip_tests.py @@ -60,7 +60,7 @@ def run_roundtrip_python(arch: str) -> str: cmd = [python_executable, main_path, "--save", output_path] print(cmd) roundtrip_process = subprocess.Popen(cmd) - returncode = roundtrip_process.wait(timeout=600) + returncode = roundtrip_process.wait(timeout=30) assert returncode == 0, f"python roundtrip process exited with error code {returncode}" return output_path @@ -73,17 +73,17 @@ def run_roundtrip_rust(arch: str) -> str: cmd = ["cargo", "r", "-p", project_name, "--", "--save", output_path] print(cmd) roundtrip_process = subprocess.Popen(cmd) - returncode = roundtrip_process.wait(timeout=6000) + returncode = roundtrip_process.wait(timeout=12000) assert returncode == 0, f"rust roundtrip process exited with error code {returncode}" return output_path def run_comparison(python_output_path: str, rust_output_path: str): - cmd = ["cargo", "r", "-p", "rerun-cli", "--", "compare", python_output_path, rust_output_path] + cmd = ["rerun", "compare", python_output_path, rust_output_path] print(cmd) roundtrip_process = subprocess.Popen(cmd) - returncode = roundtrip_process.wait(timeout=600) + returncode = roundtrip_process.wait(timeout=30) assert returncode == 0, f"comparison process exited with error code {returncode}" From e3794f658a1de7ffef6e8579be8f99490454d874 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Wed, 5 Jul 2023 09:28:25 +0200 Subject: [PATCH 12/20] accept a custom --target-dir --- scripts/ci/run_e2e_roundtrip_tests.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/ci/run_e2e_roundtrip_tests.py b/scripts/ci/run_e2e_roundtrip_tests.py index 1d33b68a25d4..5707b135b6b3 100755 --- a/scripts/ci/run_e2e_roundtrip_tests.py +++ b/scripts/ci/run_e2e_roundtrip_tests.py @@ -23,8 +23,11 @@ def main() -> None: parser = argparse.ArgumentParser(description="Run our end-to-end cross-language roundtrip tests for all SDK") parser.add_argument("--no-build", action="store_true", help="Skip building rerun-sdk") + parser.add_argument("--target-dir", type=str, default=None, help="Target directory used for cargo invocations") - if parser.parse_args().no_build: + args = parser.parse_args() + + if args.no_build: print("Skipping building rerun-sdk - assuming it is already built and up-to-date!") else: build_env = os.environ.copy() @@ -44,7 +47,7 @@ def main() -> None: for arch in archetypes: python_output_path = run_roundtrip_python(arch) - rust_output_path = run_roundtrip_rust(arch) + rust_output_path = run_roundtrip_rust(arch, args.target_dir) run_comparison(python_output_path, rust_output_path) @@ -66,11 +69,14 @@ def run_roundtrip_python(arch: str) -> str: return output_path -def run_roundtrip_rust(arch: str) -> str: +def run_roundtrip_rust(arch: str, target_dir: str | None) -> str: project_name = f"roundtrip_{arch}" output_path = f"tests/rust/roundtrips/{arch}/out.rrd" - cmd = ["cargo", "r", "-p", project_name, "--", "--save", output_path] + if target_dir is not None: + cmd = ["cargo", "r", "-p", project_name, "--target-dir", target_dir, "--", "--save", output_path] + else: + cmd = ["cargo", "r", "-p", project_name, "--", "--save", output_path] print(cmd) roundtrip_process = subprocess.Popen(cmd) returncode = roundtrip_process.wait(timeout=12000) From 10ab4a9c661fb5d3c3cdde35a241a8e594d83f64 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Wed, 5 Jul 2023 09:48:19 +0200 Subject: [PATCH 13/20] support --release --- scripts/ci/run_e2e_roundtrip_tests.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/scripts/ci/run_e2e_roundtrip_tests.py b/scripts/ci/run_e2e_roundtrip_tests.py index 5707b135b6b3..84d765f56151 100755 --- a/scripts/ci/run_e2e_roundtrip_tests.py +++ b/scripts/ci/run_e2e_roundtrip_tests.py @@ -23,6 +23,7 @@ def main() -> None: parser = argparse.ArgumentParser(description="Run our end-to-end cross-language roundtrip tests for all SDK") parser.add_argument("--no-build", action="store_true", help="Skip building rerun-sdk") + parser.add_argument("--release", action="store_true", help="Run cargo invocations with --release") parser.add_argument("--target-dir", type=str, default=None, help="Target directory used for cargo invocations") args = parser.parse_args() @@ -47,7 +48,7 @@ def main() -> None: for arch in archetypes: python_output_path = run_roundtrip_python(arch) - rust_output_path = run_roundtrip_rust(arch, args.target_dir) + rust_output_path = run_roundtrip_rust(arch, args.release, args.target_dir) run_comparison(python_output_path, rust_output_path) @@ -69,14 +70,20 @@ def run_roundtrip_python(arch: str) -> str: return output_path -def run_roundtrip_rust(arch: str, target_dir: str | None) -> str: +def run_roundtrip_rust(arch: str, release: bool, target_dir: str | None) -> str: project_name = f"roundtrip_{arch}" output_path = f"tests/rust/roundtrips/{arch}/out.rrd" + cmd = ["cargo", "r", "-p", project_name] + if target_dir is not None: - cmd = ["cargo", "r", "-p", project_name, "--target-dir", target_dir, "--", "--save", output_path] - else: - cmd = ["cargo", "r", "-p", project_name, "--", "--save", output_path] + cmd += ["--target-dir", target_dir] + + if release: + cmd += ["--release"] + + cmd += ["--", "--save", output_path] + print(cmd) roundtrip_process = subprocess.Popen(cmd) returncode = roundtrip_process.wait(timeout=12000) From 0509eaf715784d198af03ebad642835d08e0c26a Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Wed, 5 Jul 2023 09:49:34 +0200 Subject: [PATCH 14/20] run the workflow with --release to hopefully inherit artifacts --- .github/workflows/reusable_build_and_test_wheels.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/reusable_build_and_test_wheels.yml b/.github/workflows/reusable_build_and_test_wheels.yml index 98377094953b..40a31d9d119d 100644 --- a/.github/workflows/reusable_build_and_test_wheels.yml +++ b/.github/workflows/reusable_build_and_test_wheels.yml @@ -276,7 +276,8 @@ jobs: - name: Run e2e roundtrip tests if: needs.set-config.outputs.RUN_TESTS == 'true' shell: bash - run: RUST_LOG=debug scripts/ci/run_e2e_roundtrip_tests.py --no-build # rerun-sdk is already built and installed + # NOTE: run with --release so we can reuse some of the "Build Wheel"'s job artifacts, hopefully + run: RUST_LOG=debug scripts/ci/run_e2e_roundtrip_tests.py --release --no-build # rerun-sdk is already built and installed - name: Cache RRD dataset if: needs.set-config.outputs.RUN_TESTS == 'true' From 2585152c23287b9cfad33d5d6c0578d0d3f762b3 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Wed, 5 Jul 2023 10:10:37 +0200 Subject: [PATCH 15/20] format --- scripts/ci/run_e2e_roundtrip_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/run_e2e_roundtrip_tests.py b/scripts/ci/run_e2e_roundtrip_tests.py index 84d765f56151..708d47455cb2 100755 --- a/scripts/ci/run_e2e_roundtrip_tests.py +++ b/scripts/ci/run_e2e_roundtrip_tests.py @@ -77,7 +77,7 @@ def run_roundtrip_rust(arch: str, release: bool, target_dir: str | None) -> str: cmd = ["cargo", "r", "-p", project_name] if target_dir is not None: - cmd += ["--target-dir", target_dir] + cmd += ["--target-dir", target_dir] if release: cmd += ["--release"] From 9e15c6cff093683f4da05dfb8ca15be36a5b2f52 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Wed, 5 Jul 2023 11:03:22 +0200 Subject: [PATCH 16/20] Revert "make the roundtrip test fail on purpose" This reverts commit c95310cfc9247e6412adc640f84f492529b68838. --- tests/python/roundtrips/points2d/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/python/roundtrips/points2d/main.py b/tests/python/roundtrips/points2d/main.py index 7312f036816a..b3323cfc6408 100755 --- a/tests/python/roundtrips/points2d/main.py +++ b/tests/python/roundtrips/points2d/main.py @@ -16,7 +16,7 @@ def main() -> None: colors = np.array( [ 0xAA0000CC, - 0x00BB00DE, + 0x00BB00DD, ], dtype=np.uint32, ) From e79bba607de415aad64945b909c730d67cbcd028 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Wed, 5 Jul 2023 11:15:11 +0200 Subject: [PATCH 17/20] add support for --target --- scripts/ci/run_e2e_roundtrip_tests.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/ci/run_e2e_roundtrip_tests.py b/scripts/ci/run_e2e_roundtrip_tests.py index 708d47455cb2..91737a337552 100755 --- a/scripts/ci/run_e2e_roundtrip_tests.py +++ b/scripts/ci/run_e2e_roundtrip_tests.py @@ -24,6 +24,7 @@ def main() -> None: parser = argparse.ArgumentParser(description="Run our end-to-end cross-language roundtrip tests for all SDK") parser.add_argument("--no-build", action="store_true", help="Skip building rerun-sdk") parser.add_argument("--release", action="store_true", help="Run cargo invocations with --release") + parser.add_argument("--target", type=str, default=None, help="Target used for cargo invocations") parser.add_argument("--target-dir", type=str, default=None, help="Target directory used for cargo invocations") args = parser.parse_args() @@ -48,7 +49,7 @@ def main() -> None: for arch in archetypes: python_output_path = run_roundtrip_python(arch) - rust_output_path = run_roundtrip_rust(arch, args.release, args.target_dir) + rust_output_path = run_roundtrip_rust(arch, args.release, args.target, args.target_dir) run_comparison(python_output_path, rust_output_path) @@ -70,12 +71,15 @@ def run_roundtrip_python(arch: str) -> str: return output_path -def run_roundtrip_rust(arch: str, release: bool, target_dir: str | None) -> str: +def run_roundtrip_rust(arch: str, release: bool, target: str | None, target_dir: str | None) -> str: project_name = f"roundtrip_{arch}" output_path = f"tests/rust/roundtrips/{arch}/out.rrd" cmd = ["cargo", "r", "-p", project_name] + if target is not None: + cmd += ["--target", target] + if target_dir is not None: cmd += ["--target-dir", target_dir] From b77534e3c7e8cf5318c73b75dfc7800b7fef6eee Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Wed, 5 Jul 2023 11:19:29 +0200 Subject: [PATCH 18/20] srsly cargo? --- .github/workflows/reusable_build_and_test_wheels.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/reusable_build_and_test_wheels.yml b/.github/workflows/reusable_build_and_test_wheels.yml index 40a31d9d119d..52727569fb01 100644 --- a/.github/workflows/reusable_build_and_test_wheels.yml +++ b/.github/workflows/reusable_build_and_test_wheels.yml @@ -276,8 +276,11 @@ jobs: - name: Run e2e roundtrip tests if: needs.set-config.outputs.RUN_TESTS == 'true' shell: bash + # --release so we can inherit from some of the artifacts that maturin has just built before + # --target x86_64-unknown-linux-gnu because otherwise cargo loses the target cache... even though this is the target anyhow... + # --no-build because rerun-sdk is already built and installed # NOTE: run with --release so we can reuse some of the "Build Wheel"'s job artifacts, hopefully - run: RUST_LOG=debug scripts/ci/run_e2e_roundtrip_tests.py --release --no-build # rerun-sdk is already built and installed + run: RUST_LOG=debug scripts/ci/run_e2e_roundtrip_tests.py --release --target x86_64-unknown-linux-gnu --no-build - name: Cache RRD dataset if: needs.set-config.outputs.RUN_TESTS == 'true' From 91ede575c919badaab25963a671295202bba9286 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Thu, 6 Jul 2023 11:55:28 +0200 Subject: [PATCH 19/20] get rid of type:ignore clauses --- tests/python/roundtrips/points2d/main.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/python/roundtrips/points2d/main.py b/tests/python/roundtrips/points2d/main.py index b3323cfc6408..5ac14cbfe96a 100755 --- a/tests/python/roundtrips/points2d/main.py +++ b/tests/python/roundtrips/points2d/main.py @@ -27,14 +27,14 @@ def main() -> None: instance_keys = np.array([66, 666], dtype=np.uint64) points2d = rr.Points2D( - points, # type: ignore[arg-type] - radii=radii, # type: ignore[arg-type] - colors=colors, # type: ignore[arg-type] - labels=labels, # type: ignore[arg-type] - draw_order=draw_order, # type: ignore[arg-type] - class_ids=class_ids, # type: ignore[arg-type] - keypoint_ids=keypoint_ids, # type: ignore[arg-type] - instance_keys=instance_keys, # type: ignore[arg-type] + points, + radii=radii, + colors=colors, + labels=labels, + draw_order=draw_order, + class_ids=class_ids, + keypoint_ids=keypoint_ids, + instance_keys=instance_keys, ) parser = argparse.ArgumentParser(description="Logs rich data using the Rerun SDK.") From dab19ddf0101782123c90e891b590a6f35666fc9 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Thu, 6 Jul 2023 11:58:38 +0200 Subject: [PATCH 20/20] fmt --- tests/python/roundtrips/points2d/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/python/roundtrips/points2d/main.py b/tests/python/roundtrips/points2d/main.py index 5ac14cbfe96a..f1b191e21781 100755 --- a/tests/python/roundtrips/points2d/main.py +++ b/tests/python/roundtrips/points2d/main.py @@ -32,7 +32,7 @@ def main() -> None: colors=colors, labels=labels, draw_order=draw_order, - class_ids=class_ids, + class_ids=class_ids, keypoint_ids=keypoint_ids, instance_keys=instance_keys, )