From 4a8bb0f0e06bdf109fd6c57bdb54b3c000944712 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Mon, 3 Jul 2023 11:00:50 +0200 Subject: [PATCH 1/7] examples/rust/api_demo is now tests/rust/test_api --- Cargo.lock | 28 +++++++++---------- examples/rust/api_demo/README.md | 22 --------------- .../rust/test_api}/Cargo.toml | 2 +- .../rust/test_api}/src/main.rs | 6 ++-- 4 files changed, 18 insertions(+), 40 deletions(-) delete mode 100644 examples/rust/api_demo/README.md rename {examples/rust/api_demo => tests/rust/test_api}/Cargo.toml (95%) rename {examples/rust/api_demo => tests/rust/test_api}/src/main.rs (99%) diff --git a/Cargo.lock b/Cargo.lock index f4c7f4cb54de..832a1cb7555b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -170,20 +170,6 @@ version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" -[[package]] -name = "api_demo" -version = "0.8.0-alpha.0" -dependencies = [ - "anyhow", - "clap", - "glam", - "itertools 0.11.0", - "ndarray", - "ndarray-rand", - "rand", - "rerun", -] - [[package]] name = "arboard" version = "3.2.0" @@ -5474,6 +5460,20 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "test_api" +version = "0.8.0-alpha.0" +dependencies = [ + "anyhow", + "clap", + "glam", + "itertools 0.11.0", + "ndarray", + "ndarray-rand", + "rand", + "rerun", +] + [[package]] name = "test_image_memory" version = "0.8.0-alpha.0" diff --git a/examples/rust/api_demo/README.md b/examples/rust/api_demo/README.md deleted file mode 100644 index 171da5646e61..000000000000 --- a/examples/rust/api_demo/README.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -title: API Demo -python: https://github.com/rerun-io/rerun/tree/latest/examples/python/api_demo/main.py -rust: https://github.com/rerun-io/rerun/tree/latest/examples/rust/api_demo/src/main.rs -thumbnail: https://static.rerun.io/d41179fb380bc6bdeda950d7d69e3c457ff295e9_api_demo_480w.png ---- - - - - - - - API demo example screenshot - - -This is a swiss-army-knife example showing the usage of most of the Rerun SDK APIs. The data logged is static and meaningless. - -Multiple sub-examples are available (See the instructions by running with the `--help` flag). - -```bash -cargo run --release -``` diff --git a/examples/rust/api_demo/Cargo.toml b/tests/rust/test_api/Cargo.toml similarity index 95% rename from examples/rust/api_demo/Cargo.toml rename to tests/rust/test_api/Cargo.toml index 38ab9d203bd5..c0a36e6f95af 100644 --- a/examples/rust/api_demo/Cargo.toml +++ b/tests/rust/test_api/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "api_demo" +name = "test_api" version = "0.8.0-alpha.0" edition = "2021" rust-version = "1.69" diff --git a/examples/rust/api_demo/src/main.rs b/tests/rust/test_api/src/main.rs similarity index 99% rename from examples/rust/api_demo/src/main.rs rename to tests/rust/test_api/src/main.rs index c64c3982e912..24b99ae613f2 100644 --- a/examples/rust/api_demo/src/main.rs +++ b/tests/rust/test_api/src/main.rs @@ -4,12 +4,12 @@ //! //! Run all demos: //! ``` -//! cargo run -p api_demo +//! cargo run -p test_api //! ``` //! //! Run specific demo: //! ``` -//! cargo run -p api_demo -- --demo rects +//! cargo run -p test_api -- --demo rects //! ``` use std::{collections::HashSet, f32::consts::TAU}; @@ -696,7 +696,7 @@ fn main() -> anyhow::Result<()> { let default_enabled = true; args.rerun .clone() - .run("api_demo_rs", default_enabled, move |rec_stream| { + .run("test_api_rs", default_enabled, move |rec_stream| { run(&rec_stream, &args).unwrap(); }) } From 9c6b636c667c5a99de931dfd51c6b179419097ef Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Mon, 3 Jul 2023 11:03:15 +0200 Subject: [PATCH 2/7] examples/python/api_demo is now tests/python/test_api --- examples/python/api_demo/README.md | 22 ------------------- .../python/test_api}/main.py | 10 ++++----- .../python/test_api}/requirements.txt | 0 3 files changed, 5 insertions(+), 27 deletions(-) delete mode 100644 examples/python/api_demo/README.md rename {examples/python/api_demo => tests/python/test_api}/main.py (98%) rename {examples/python/api_demo => tests/python/test_api}/requirements.txt (100%) diff --git a/examples/python/api_demo/README.md b/examples/python/api_demo/README.md deleted file mode 100644 index 175b266a2a24..000000000000 --- a/examples/python/api_demo/README.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -title: API Demo -python: https://github.com/rerun-io/rerun/tree/latest/examples/python/api_demo/main.py -rust: https://github.com/rerun-io/rerun/tree/latest/examples/rust/api_demo/src/main.rs -thumbnail: https://static.rerun.io/d41179fb380bc6bdeda950d7d69e3c457ff295e9_api_demo_480w.png ---- - - - - - - - API demo example screenshot - - -This is a swiss-army-knife example showing the usage of most of the Rerun SDK APIs. The data logged is static and meaningless. - -Multiple sub-examples are available (See the instructions by running with the `--help` flag). - -```bash -python examples/python/api_demo/main.py -``` diff --git a/examples/python/api_demo/main.py b/tests/python/test_api/main.py similarity index 98% rename from examples/python/api_demo/main.py rename to tests/python/test_api/main.py index 578df1e1cc8c..73d769307ccf 100755 --- a/examples/python/api_demo/main.py +++ b/tests/python/test_api/main.py @@ -5,8 +5,8 @@ It uses a lot of different aspects of the Rerun API in order to test it. Example usage: -* Run all demos: `examples/python/api_demo/main.py` -* Run specific demo: `examples/python/api_demo/main.py --demo rects` +* Run all demos: `examples/python/test_api/main.py` +* Run specific demo: `examples/python/test_api/main.py --demo rects` """ from __future__ import annotations @@ -458,7 +458,7 @@ def main() -> None: args = parser.parse_args() if not args.split_recordings: - rec = rr.script_setup(args, "api_demo") + rec = rr.script_setup(args, "test_api") if args.demo in ["most", "all"]: print(f"Running {args.demo} demos…") @@ -470,7 +470,7 @@ def main() -> None: continue if args.split_recordings: - rec = rr.script_setup(args, f"api_demo/{name}") + rec = rr.script_setup(args, f"test_api/{name}") if args.multithread: t = threading.Thread( @@ -491,7 +491,7 @@ def main() -> None: t.join() else: if args.split_recordings: - with rr.script_setup(args, f"api_demo/{args.demo}"): + with rr.script_setup(args, f"test_api/{args.demo}"): demos[args.demo]() else: demos[args.demo]() diff --git a/examples/python/api_demo/requirements.txt b/tests/python/test_api/requirements.txt similarity index 100% rename from examples/python/api_demo/requirements.txt rename to tests/python/test_api/requirements.txt From 64bcc5ed74f9f0dfad58b1eff90f418befc21368 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Mon, 3 Jul 2023 11:19:07 +0200 Subject: [PATCH 3/7] update all scripts accordingly --- examples/manifest.yml | 4 ---- examples/python/requirements.txt | 1 - examples/rust/README.md | 12 ++---------- scripts/run_all.py | 2 +- scripts/run_python_e2e_test.py | 4 ++-- 5 files changed, 5 insertions(+), 18 deletions(-) diff --git a/examples/manifest.yml b/examples/manifest.yml index b12802eefabe..f0a44d35d7cc 100644 --- a/examples/manifest.yml +++ b/examples/manifest.yml @@ -108,10 +108,6 @@ root: python: python/minimal rust: rust/minimal - - name: api-demo - python: python/api_demo - rust: rust/api_demo - - name: car python: python/car diff --git a/examples/python/requirements.txt b/examples/python/requirements.txt index 9ae0ccd5b96b..97c46f96f06f 100644 --- a/examples/python/requirements.txt +++ b/examples/python/requirements.txt @@ -1,4 +1,3 @@ --r api_demo/requirements.txt -r arkit_scenes/requirements.txt -r blueprint/requirements.txt -r car/requirements.txt diff --git a/examples/rust/README.md b/examples/rust/README.md index cc35206725d5..bf4ab808fb14 100644 --- a/examples/rust/README.md +++ b/examples/rust/README.md @@ -8,14 +8,14 @@ To try out any example in the list that follows, simply run `cargo run -p -### [`api_demo`](api_demo) - -`cargo run -p api_demo` - -An amalgamation of various usages of the API with synthetic "data" without any particular focus. - -It demonstrates a lot of different aspects of the Rerun API. - ### [`objectron`](objectron) `cargo run -p objectron` diff --git a/scripts/run_all.py b/scripts/run_all.py index 129d114c5f57..fff780a3ac30 100755 --- a/scripts/run_all.py +++ b/scripts/run_all.py @@ -91,7 +91,7 @@ def collect_examples(fast: bool) -> list[str]: if fast: # cherry-picked return [ - "examples/python/api_demo", + "tests/python/test_api", "examples/python/car", "examples/python/clock", "examples/python/dicom_mri", diff --git a/scripts/run_python_e2e_test.py b/scripts/run_python_e2e_test.py index 346223a65b76..f81f3d611cac 100755 --- a/scripts/run_python_e2e_test.py +++ b/scripts/run_python_e2e_test.py @@ -41,7 +41,7 @@ def main() -> None: if not parser.parse_args().no_pip_reqs: requirements = [ - "examples/python/api_demo/requirements.txt", + "tests/python/test_api/requirements.txt", "examples/python/car/requirements.txt", "examples/python/minimal_options/requirements.txt", "examples/python/multithreading/requirements.txt", @@ -60,7 +60,7 @@ def main() -> None: examples = [ # Trivial examples that don't require weird dependencies, or downloading data - ("examples/python/api_demo/main.py", ["--demo", "all"]), + ("tests/python/test_api/main.py", ["--demo", "all"]), ("examples/python/car/main.py", []), ("examples/python/minimal_options/main.py", []), ("examples/python/multithreading/main.py", []), From 24f0a9bd935f67ff01756599776c1980d62181ef Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Mon, 3 Jul 2023 11:22:39 +0200 Subject: [PATCH 4/7] fix custom_space_view thumbnail links --- examples/rust/custom_space_view/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/rust/custom_space_view/README.md b/examples/rust/custom_space_view/README.md index e5ad1a3c515c..f966263fc28a 100644 --- a/examples/rust/custom_space_view/README.md +++ b/examples/rust/custom_space_view/README.md @@ -1,14 +1,14 @@ --- title: Custom Space View UI rust: https://github.com/rerun-io/rerun/tree/latest/examples/rust/custom_space_view/src/main.rs -thumbnail: https://static.rerun.io/d41179fb380bc6bdeda950d7d69e3c457ff295e9_api_demo_480w.png +thumbnail: https://static.rerun.io/0ddce48924e92e4509c4caea3266d414ad76d961_custom_space_view_480w.jpeg --- - - - - + + + + Custom Space View UI example screenshot From 4403fc98465259de2eefe2172bd97521480b589f Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Mon, 3 Jul 2023 12:01:16 +0200 Subject: [PATCH 5/7] demo -> test --- tests/python/test_api/main.py | 98 ++++++++++++++++----------------- tests/rust/test_api/src/main.rs | 96 ++++++++++++++++---------------- 2 files changed, 97 insertions(+), 97 deletions(-) diff --git a/tests/python/test_api/main.py b/tests/python/test_api/main.py index 73d769307ccf..1200edf8beee 100755 --- a/tests/python/test_api/main.py +++ b/tests/python/test_api/main.py @@ -5,8 +5,8 @@ It uses a lot of different aspects of the Rerun API in order to test it. Example usage: -* Run all demos: `examples/python/test_api/main.py` -* Run specific demo: `examples/python/test_api/main.py --demo rects` +* Run all tests: `examples/python/test_api/main.py` +* Run specific test: `examples/python/test_api/main.py --test rects` """ from __future__ import annotations @@ -30,67 +30,67 @@ def run_segmentation() -> None: segmentation_img[10:20, 30:50] = 13 segmentation_img[80:100, 60:80] = 42 segmentation_img[20:50, 90:110] = 99 - rr.log_segmentation_image("seg_demo/img", segmentation_img) + rr.log_segmentation_image("seg_test/img", segmentation_img) # Log a bunch of classified 2D points if rr.ENABLE_NEXT_GEN_API: # Note: this uses the new, WIP object-oriented API - rr.log_any("seg_demo/single_point", rr.Points2D([64, 64], class_ids=13)) - rr.log_any("seg_demo/single_point_labeled", rr.Points2D([90, 50], class_ids=13, labels="labeled point")) - rr.log_any("seg_demo/several_points0", rr.Points2D([[20, 50], [100, 70], [60, 30]], class_ids=42)) + rr.log_any("seg_test/single_point", rr.Points2D([64, 64], class_ids=13)) + rr.log_any("seg_test/single_point_labeled", rr.Points2D([90, 50], class_ids=13, labels="labeled point")) + rr.log_any("seg_test/several_points0", rr.Points2D([[20, 50], [100, 70], [60, 30]], class_ids=42)) rr.log_any( - "seg_demo/several_points1", + "seg_test/several_points1", rr.Points2D([[40, 50], [120, 70], [80, 30]], class_ids=np.array([13, 42, 99], dtype=np.uint8)), ) rr.log_any( - "seg_demo/many points", + "seg_test/many points", rr.Points2D( [[100 + (int(i / 5)) * 2, 100 + (i % 5) * 2] for i in range(25)], class_ids=np.array([42], dtype=np.uint8), ), ) else: - rr.log_point("seg_demo/single_point", np.array([64, 64]), class_id=13) - rr.log_point("seg_demo/single_point_labeled", np.array([90, 50]), class_id=13, label="labeled point") - rr.log_points("seg_demo/several_points0", np.array([[20, 50], [100, 70], [60, 30]]), class_ids=42) + rr.log_point("seg_test/single_point", np.array([64, 64]), class_id=13) + rr.log_point("seg_test/single_point_labeled", np.array([90, 50]), class_id=13, label="labeled point") + rr.log_points("seg_test/several_points0", np.array([[20, 50], [100, 70], [60, 30]]), class_ids=42) rr.log_points( - "seg_demo/several_points1", + "seg_test/several_points1", np.array([[40, 50], [120, 70], [80, 30]]), class_ids=np.array([13, 42, 99], dtype=np.uint8), ) rr.log_points( - "seg_demo/many points", + "seg_test/many points", np.array([[100 + (int(i / 5)) * 2, 100 + (i % 5) * 2] for i in range(25)]), class_ids=np.array([42], dtype=np.uint8), ) - rr.log_text_entry("logs/seg_demo_log", "default colored rects, default colored points, a single point has a label") + rr.log_text_entry("logs/seg_test_log", "default colored rects, default colored points, a single point has a label") # Log an initial segmentation map with arbitrary colors rr.set_time_seconds("sim_time", 2) - rr.log_annotation_context("seg_demo", [(13, "label1"), (42, "label2"), (99, "label3")], timeless=False) + rr.log_annotation_context("seg_test", [(13, "label1"), (42, "label2"), (99, "label3")], timeless=False) rr.log_text_entry( - "logs/seg_demo_log", + "logs/seg_test_log", "default colored rects, default colored points, " "all points except the bottom right clusters have labels", ) # Log an updated segmentation map with specific colors rr.set_time_seconds("sim_time", 3) rr.log_annotation_context( - "seg_demo", + "seg_test", [(13, "label1", (255, 0, 0)), (42, "label2", (0, 255, 0)), (99, "label3", (0, 0, 255))], timeless=False, ) - rr.log_text_entry("logs/seg_demo_log", "points/rects with user specified colors") + rr.log_text_entry("logs/seg_test_log", "points/rects with user specified colors") # Log with a mixture of set and unset colors / labels rr.set_time_seconds("sim_time", 4) rr.log_annotation_context( - "seg_demo", + "seg_test", [rr.AnnotationInfo(13, color=(255, 0, 0)), (42, "label2", (0, 255, 0)), rr.AnnotationInfo(99, label="label3")], timeless=False, ) - rr.log_text_entry("logs/seg_demo_log", "label1 disappears and everything with label3 is now default colored again") + rr.log_text_entry("logs/seg_test_log", "label1 disappears and everything with label3 is now default colored again") def small_image() -> None: @@ -212,7 +212,7 @@ def run_3d_points() -> None: def raw_mesh() -> None: rr.log_mesh( - "mesh_demo/triangle", + "mesh_test/triangle", positions=[[0, 0, 0], [0, 0.7, 0], [1.0, 0.0, 0]], vertex_colors=[[255, 0, 0], [0, 255, 0], [0, 0, 255]], ) @@ -226,7 +226,7 @@ def run_rects() -> None: # Add an image img = np.zeros([1024, 1024, 3], dtype="uint8") img[:, :] = (128, 128, 128) - rr.log_image("rects_demo/img", img) + rr.log_image("rects_test/img", img) # 20 random rectangles rr.set_time_seconds("sim_time", 2) @@ -234,11 +234,11 @@ def run_rects() -> None: rects_wh = np.random.rand(20, 2) * (1024 - rects_xy + 1) rects = np.hstack((rects_xy, rects_wh)) colors = np.array([[random.randrange(255) for _ in range(3)] for _ in range(20)]) - rr.log_rects("rects_demo/rects", rects, colors=colors, rect_format=rr.RectFormat.XYWH) + rr.log_rects("rects_test/rects", rects, colors=colors, rect_format=rr.RectFormat.XYWH) # Clear the rectangles by logging an empty set rr.set_time_seconds("sim_time", 3) - rr.log_rects("rects_demo/rects", []) + rr.log_rects("rects_test/rects", []) def run_text_logs() -> None: @@ -252,16 +252,16 @@ def run_text_logs() -> None: def run_log_cleared() -> None: rr.set_time_seconds("sim_time", 1) - rr.log_rect("null_demo/rect/0", [5, 5, 4, 4], label="Rect1", color=(255, 0, 0)) - rr.log_rect("null_demo/rect/1", [10, 5, 4, 4], label="Rect2", color=(0, 255, 0)) + rr.log_rect("null_test/rect/0", [5, 5, 4, 4], label="Rect1", color=(255, 0, 0)) + rr.log_rect("null_test/rect/1", [10, 5, 4, 4], label="Rect2", color=(0, 255, 0)) rr.set_time_seconds("sim_time", 2) - rr.log_cleared("null_demo/rect/0") + rr.log_cleared("null_test/rect/0") rr.set_time_seconds("sim_time", 3) - rr.log_cleared("null_demo/rect", recursive=True) + rr.log_cleared("null_test/rect", recursive=True) rr.set_time_seconds("sim_time", 4) - rr.log_rect("null_demo/rect/0", [5, 5, 4, 4]) + rr.log_rect("null_test/rect/0", [5, 5, 4, 4]) rr.set_time_seconds("sim_time", 5) - rr.log_rect("null_demo/rect/1", [10, 5, 4, 4]) + rr.log_rect("null_test/rect/1", [10, 5, 4, 4]) def transforms_rigid_3d() -> None: @@ -339,7 +339,7 @@ def transforms_rigid_3d() -> None: def run_bounding_box() -> None: rr.set_time_seconds("sim_time", 0) rr.log_obb( - "bbox_demo/bbox", + "bbox_test/bbox", half_size=[1.0, 0.5, 0.25], position=np.array([0.0, 0.0, 0.0]), rotation_q=np.array([0, 0, np.sin(np.pi / 4), np.cos(np.pi / 4)]), @@ -350,7 +350,7 @@ def run_bounding_box() -> None: rr.set_time_seconds("sim_time", 1) rr.log_obb( - "bbox_demo/bbox", + "bbox_test/bbox", half_size=[1.0, 0.5, 0.25], position=np.array([1.0, 0.0, 0.0]), rotation_q=np.array([0, 0, np.sin(np.pi / 4), np.cos(np.pi / 4)]), @@ -414,13 +414,13 @@ def run_image_tensors() -> None: rr.log_image(f"img_gray_{dtype}", img_gray.astype(dtype)) -def spawn_demo(demo: Callable[[], None], rec: rr.RecordingStream) -> None: +def spawn_test(test: Callable[[], None], rec: rr.RecordingStream) -> None: with rec: - demo() + test() def main() -> None: - demos = { + tests = { "2d_lines": run_2d_lines, "3d_points": run_3d_points, "bbox": run_bounding_box, @@ -439,19 +439,19 @@ def main() -> None: parser = argparse.ArgumentParser(description="Logs rich data using the Rerun SDK.") parser.add_argument( - "--demo", type=str, default="most", help="What demo to run", choices=["most", "all"] + list(demos.keys()) + "--test", type=str, default="most", help="What test to run", choices=["most", "all"] + list(tests.keys()) ) parser.add_argument( "--multithread", dest="multithread", action="store_true", - help="If specified, each demo will be run from its own python thread", + help="If specified, each test will be run from its own python thread", ) parser.add_argument( "--split-recordings", dest="split_recordings", action="store_true", - help="If specified, each demo will be its own recording", + help="If specified, each test will be its own recording", ) rr.script_add_args(parser) @@ -460,13 +460,13 @@ def main() -> None: if not args.split_recordings: rec = rr.script_setup(args, "test_api") - if args.demo in ["most", "all"]: - print(f"Running {args.demo} demos…") + if args.test in ["most", "all"]: + print(f"Running {args.test} tests…") threads = [] - for name, demo in demos.items(): - # Some demos are just a bit… too much - if args.demo == "most" and name in ["image_tensors", "transform_test"]: + for name, test in tests.items(): + # Some tests are just a bit… too much + if args.test == "most" and name in ["image_tensors", "transform_test"]: continue if args.split_recordings: @@ -474,9 +474,9 @@ def main() -> None: if args.multithread: t = threading.Thread( - target=spawn_demo, + target=spawn_test, args=( - demo, + test, rec, ), ) @@ -485,16 +485,16 @@ def main() -> None: else: logging.info(f"Starting {name}") with rec: - demo() + test() for t in threads: t.join() else: if args.split_recordings: - with rr.script_setup(args, f"test_api/{args.demo}"): - demos[args.demo]() + with rr.script_setup(args, f"test_api/{args.test}"): + tests[args.test]() else: - demos[args.demo]() + tests[args.test]() rr.script_teardown(args) diff --git a/tests/rust/test_api/src/main.rs b/tests/rust/test_api/src/main.rs index 24b99ae613f2..1f654c74f7f9 100644 --- a/tests/rust/test_api/src/main.rs +++ b/tests/rust/test_api/src/main.rs @@ -2,14 +2,14 @@ //! //! It uses a lot of different aspects of the Rerun API in order to test it. //! -//! Run all demos: +//! Run all tests: //! ``` //! cargo run -p test_api //! ``` //! -//! Run specific demo: +//! Run specific test: //! ``` -//! cargo run -p test_api -- --demo rects +//! cargo run -p test_api -- --test rects //! ``` use std::{collections::HashSet, f32::consts::TAU}; @@ -32,9 +32,9 @@ use rerun::{ // --- Rerun logging --- -fn demo_bbox(rec_stream: &RecordingStream) -> anyhow::Result<()> { +fn test_bbox(rec_stream: &RecordingStream) -> anyhow::Result<()> { rec_stream.set_time_seconds("sim_time", 0f64); - MsgSender::new("bbox_demo/bbox") + MsgSender::new("bbox_test/bbox") .with_component(&[Box3D::new(1.0, 0.5, 0.25)])? .with_component(&[Transform3D::new(RotationAxisAngle::new( glam::Vec3::Z, @@ -46,7 +46,7 @@ fn demo_bbox(rec_stream: &RecordingStream) -> anyhow::Result<()> { .send(rec_stream)?; rec_stream.set_time_seconds("sim_time", 1f64); - MsgSender::new("bbox_demo/bbox") + MsgSender::new("bbox_test/bbox") .with_component(&[Box3D::new(1.0, 0.5, 0.25)])? .with_component(&[Transform3D::new(TranslationRotationScale3D::rigid( Vec3D::new(1.0, 0.0, 0.0), @@ -60,7 +60,7 @@ fn demo_bbox(rec_stream: &RecordingStream) -> anyhow::Result<()> { Ok(()) } -fn demo_extension_components(rec_stream: &RecordingStream) -> anyhow::Result<()> { +fn test_extension_components(rec_stream: &RecordingStream) -> anyhow::Result<()> { // Hack to establish 2d view bounds rec_stream.set_time_seconds("sim_time", 0f64); MsgSender::new("extension_components") @@ -133,7 +133,7 @@ fn demo_extension_components(rec_stream: &RecordingStream) -> anyhow::Result<()> Ok(()) } -fn demo_log_cleared(rec_stream: &RecordingStream) -> anyhow::Result<()> { +fn test_log_cleared(rec_stream: &RecordingStream) -> anyhow::Result<()> { // TODO(cmc): need abstractions for this fn log_cleared(rec_stream: &RecordingStream, ent_path: impl Into, recursive: bool) { use rerun::external::re_log_types::PathOp; @@ -141,37 +141,37 @@ fn demo_log_cleared(rec_stream: &RecordingStream) -> anyhow::Result<()> { } rec_stream.set_time_seconds("sim_time", 1f64); - MsgSender::new("null_demo/rect/0") + MsgSender::new("null_test/rect/0") .with_component(&[Rect2D::from_xywh(5.0, 5.0, 4.0, 4.0)])? .with_component(&[ColorRGBA::from_rgb(255, 0, 0)])? .with_component(&[Label("Rect1".into())])? .send(rec_stream)?; - MsgSender::new("null_demo/rect/1") + MsgSender::new("null_test/rect/1") .with_component(&[Rect2D::from_xywh(10.0, 5.0, 4.0, 4.0)])? .with_component(&[ColorRGBA::from_rgb(0, 255, 0)])? .with_component(&[Label("Rect2".into())])? .send(rec_stream)?; rec_stream.set_time_seconds("sim_time", 2f64); - log_cleared(rec_stream, "null_demo/rect/0", false); + log_cleared(rec_stream, "null_test/rect/0", false); rec_stream.set_time_seconds("sim_time", 3f64); - log_cleared(rec_stream, "null_demo/rect", true); + log_cleared(rec_stream, "null_test/rect", true); rec_stream.set_time_seconds("sim_time", 4f64); - MsgSender::new("null_demo/rect/0") + MsgSender::new("null_test/rect/0") .with_component(&[Rect2D::from_xywh(5.0, 5.0, 4.0, 4.0)])? .send(rec_stream)?; rec_stream.set_time_seconds("sim_time", 5f64); - MsgSender::new("null_demo/rect/1") + MsgSender::new("null_test/rect/1") .with_component(&[Rect2D::from_xywh(10.0, 5.0, 4.0, 4.0)])? .send(rec_stream)?; Ok(()) } -fn demo_3d_points(rec_stream: &RecordingStream) -> anyhow::Result<()> { +fn test_3d_points(rec_stream: &RecordingStream) -> anyhow::Result<()> { rec_stream.set_time_seconds("sim_time", 1f64); MsgSender::new("3d_points/single_point_unlabeled") @@ -222,14 +222,14 @@ fn demo_3d_points(rec_stream: &RecordingStream) -> anyhow::Result<()> { Ok(()) } -fn demo_rects(rec_stream: &RecordingStream) -> anyhow::Result<()> { +fn test_rects(rec_stream: &RecordingStream) -> anyhow::Result<()> { use ndarray::prelude::*; use ndarray_rand::{rand_distr::Uniform, RandomExt as _}; // Add an image rec_stream.set_time_seconds("sim_time", 1f64); let img = Array::::from_elem((1024, 1024, 3, 1).f(), 128); - MsgSender::new("rects_demo/img") + MsgSender::new("rects_test/img") .with_component(&[Tensor::try_from(img.as_standard_layout().view())?])? .send(rec_stream)?; @@ -247,14 +247,14 @@ fn demo_rects(rec_stream: &RecordingStream) -> anyhow::Result<()> { .collect::>(); rec_stream.set_time_seconds("sim_time", 2f64); - MsgSender::new("rects_demo/rects") + MsgSender::new("rects_test/rects") .with_component(&rects)? .with_component(&colors)? .send(rec_stream)?; // Clear the rectangles by logging an empty set rec_stream.set_time_seconds("sim_time", 3f64); - MsgSender::new("rects_demo/rects") + MsgSender::new("rects_test/rects") .with_component(&Vec::::new())? .send(rec_stream)?; @@ -276,7 +276,7 @@ fn colored_tensor [u8; 3]>( .unwrap() } -fn demo_2d_layering(rec_stream: &RecordingStream) -> anyhow::Result<()> { +fn test_2d_layering(rec_stream: &RecordingStream) -> anyhow::Result<()> { use ndarray::prelude::*; rec_stream.set_time_seconds("sim_time", 1f64); @@ -337,14 +337,14 @@ fn demo_2d_layering(rec_stream: &RecordingStream) -> anyhow::Result<()> { Ok(()) } -fn demo_segmentation(rec_stream: &RecordingStream) -> anyhow::Result<()> { +fn test_segmentation(rec_stream: &RecordingStream) -> anyhow::Result<()> { // TODO(cmc): All of these text logs should really be going through `re_log` and automagically // fed back into rerun via a `tracing` backend. At the _very_ least we should have a helper // available for this. // In either case, this raises the question of tracking time at the SDK level, akin to what the // python SDK does. fn log_info(rec_stream: &RecordingStream, text: &str) -> anyhow::Result<()> { - MsgSender::new("logs/seg_demo_log") + MsgSender::new("logs/seg_test_log") .with_component(&[TextEntry::new(text, Some("INFO".into()))])? .send(rec_stream) .map_err(Into::into) @@ -361,36 +361,36 @@ fn demo_segmentation(rec_stream: &RecordingStream) -> anyhow::Result<()> { let mut tensor = Tensor::try_from(segmentation_img.as_standard_layout().view())?; tensor.meaning = TensorDataMeaning::ClassId; - MsgSender::new("seg_demo/img") + MsgSender::new("seg_test/img") .with_component(&[tensor])? .send(rec_stream)?; // Log a bunch of classified 2D points use rerun::experimental::archetypes::Points2D; MsgSender::from_archetype( - "seg_demo/single_point", + "seg_test/single_point", &Points2D::new([(64.0, 64.0)]).with_class_ids([13]), )? .send(rec_stream)?; MsgSender::from_archetype( - "seg_demo/single_point_labeled", + "seg_test/single_point_labeled", &Points2D::new([(90.0, 50.0)]) .with_class_ids([13]) .with_labels(["labeled point"]), )? .send(rec_stream)?; MsgSender::from_archetype( - "seg_demo/several_points0", + "seg_test/several_points0", &Points2D::new([(20.0, 50.0), (100.0, 70.0), (60.0, 30.0)]).with_class_ids([42]), )? .send(rec_stream)?; MsgSender::from_archetype( - "seg_demo/several_points1", + "seg_test/several_points1", &Points2D::new([(40.0, 50.0), (120.0, 70.0), (80.0, 30.0)]).with_class_ids([13, 42, 99]), )? .send(rec_stream)?; MsgSender::from_archetype( - "seg_demo/many points", + "seg_test/many points", &Points2D::new( (0..25).map(|i| (100.0 + (i / 5) as f32 * 2.0, 100.0 + (i % 5) as f32 * 2.0)), ) @@ -424,7 +424,7 @@ fn demo_segmentation(rec_stream: &RecordingStream) -> anyhow::Result<()> { }, ) } - MsgSender::new("seg_demo") + MsgSender::new("seg_test") .with_component(&[AnnotationContext { class_map: [ create_class(13, "label1".into(), None), @@ -444,7 +444,7 @@ fn demo_segmentation(rec_stream: &RecordingStream) -> anyhow::Result<()> { rec_stream.set_time_seconds("sim_time", 3f64); // Log an updated segmentation map with specific colors - MsgSender::new("seg_demo") + MsgSender::new("seg_test") .with_component(&[AnnotationContext { class_map: [ create_class(13, "label1".into(), [255, 0, 0].into()), @@ -460,7 +460,7 @@ fn demo_segmentation(rec_stream: &RecordingStream) -> anyhow::Result<()> { rec_stream.set_time_seconds("sim_time", 4f64); // Log with a mixture of set and unset colors / labels - MsgSender::new("seg_demo") + MsgSender::new("seg_test") .with_component(&[AnnotationContext { class_map: [ create_class(13, None, [255, 0, 0].into()), @@ -479,7 +479,7 @@ fn demo_segmentation(rec_stream: &RecordingStream) -> anyhow::Result<()> { Ok(()) } -fn demo_text_logs(rec_stream: &RecordingStream) -> anyhow::Result<()> { +fn test_text_logs(rec_stream: &RecordingStream) -> anyhow::Result<()> { // TODO(cmc): the python SDK has some magic that glues the standard logger directly into rerun // logs; we're gonna need something similar for rust (e.g. `tracing` backend). @@ -500,7 +500,7 @@ fn demo_text_logs(rec_stream: &RecordingStream) -> anyhow::Result<()> { Ok(()) } -fn demo_transforms_3d(rec_stream: &RecordingStream) -> anyhow::Result<()> { +fn test_transforms_3d(rec_stream: &RecordingStream) -> anyhow::Result<()> { let sun_to_planet_distance = 6.0; let planet_to_moon_distance = 3.0; let rotation_speed_planet = 2.0; @@ -658,29 +658,29 @@ struct Args { #[command(flatten)] rerun: rerun::clap::RerunArgs, - /// Which demo should we run? All of them by default. + /// Which test should we run? All of them by default. #[clap(long, value_enum)] - demo: Option>, + test: Option>, } fn run(rec_stream: &RecordingStream, args: &Args) -> anyhow::Result<()> { use clap::ValueEnum as _; - let demos: HashSet = args.demo.as_ref().map_or_else( + let tests: HashSet = args.test.as_ref().map_or_else( || Demo::value_variants().iter().copied().collect(), - |demos| demos.iter().cloned().collect(), + |tests| tests.iter().cloned().collect(), ); - for demo in demos { - match demo { - Demo::BoundingBox => demo_bbox(rec_stream)?, - Demo::ExtensionComponents => demo_extension_components(rec_stream)?, - Demo::LogCleared => demo_log_cleared(rec_stream)?, - Demo::Points3D => demo_3d_points(rec_stream)?, - Demo::Rects => demo_rects(rec_stream)?, - Demo::TwoDOrdering => demo_2d_layering(rec_stream)?, - Demo::Segmentation => demo_segmentation(rec_stream)?, - Demo::TextLogs => demo_text_logs(rec_stream)?, - Demo::Transforms3D => demo_transforms_3d(rec_stream)?, + for test in tests { + match test { + Demo::BoundingBox => test_bbox(rec_stream)?, + Demo::ExtensionComponents => test_extension_components(rec_stream)?, + Demo::LogCleared => test_log_cleared(rec_stream)?, + Demo::Points3D => test_3d_points(rec_stream)?, + Demo::Rects => test_rects(rec_stream)?, + Demo::TwoDOrdering => test_2d_layering(rec_stream)?, + Demo::Segmentation => test_segmentation(rec_stream)?, + Demo::TextLogs => test_text_logs(rec_stream)?, + Demo::Transforms3D => test_transforms_3d(rec_stream)?, } } From 246ace7a6883832d32cc64d8062b4d0633f3b682 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Mon, 3 Jul 2023 12:02:53 +0200 Subject: [PATCH 6/7] add tests/python/requirements.txt --- tests/python/requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 tests/python/requirements.txt diff --git a/tests/python/requirements.txt b/tests/python/requirements.txt new file mode 100644 index 000000000000..2da31733cced --- /dev/null +++ b/tests/python/requirements.txt @@ -0,0 +1 @@ +-r test_api/requirements.txt From b70ee608321d7cdbed7797938cf9fa18daa20e85 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Mon, 3 Jul 2023 17:35:07 +0200 Subject: [PATCH 7/7] missed one --- scripts/run_python_e2e_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/run_python_e2e_test.py b/scripts/run_python_e2e_test.py index f81f3d611cac..3a927dcc7463 100755 --- a/scripts/run_python_e2e_test.py +++ b/scripts/run_python_e2e_test.py @@ -60,7 +60,7 @@ def main() -> None: examples = [ # Trivial examples that don't require weird dependencies, or downloading data - ("tests/python/test_api/main.py", ["--demo", "all"]), + ("tests/python/test_api/main.py", ["--test", "all"]), ("examples/python/car/main.py", []), ("examples/python/minimal_options/main.py", []), ("examples/python/multithreading/main.py", []),