From 16a56151c9cb8286168abb26889b4852eee2b08c Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Thu, 25 Jul 2024 17:49:13 +0200 Subject: [PATCH 1/2] plot_dashboard_stress: --blueprint --- tests/python/plot_dashboard_stress/main.py | 81 ++++++++++++++++++++-- 1 file changed, 74 insertions(+), 7 deletions(-) diff --git a/tests/python/plot_dashboard_stress/main.py b/tests/python/plot_dashboard_stress/main.py index 36c55fe01359..cb87596158d8 100755 --- a/tests/python/plot_dashboard_stress/main.py +++ b/tests/python/plot_dashboard_stress/main.py @@ -29,10 +29,35 @@ rr.script_add_args(parser) parser.add_argument("--num-plots", type=int, default=1, help="How many different plots?") -parser.add_argument("--num-series-per-plot", type=int, default=1, help="How many series in each single plot?") -parser.add_argument("--num-points-per-series", type=int, default=100000, help="How many points in each single series?") -parser.add_argument("--freq", type=float, default=1000, help="Frequency of logging (applies to all series)") -parser.add_argument("--temporal-batch-size", type=int, default=None, help="Number of rows to include in each log call") +parser.add_argument( + "--num-series-per-plot", + type=int, + default=1, + help="How many series in each single plot?", +) +parser.add_argument( + "--num-points-per-series", + type=int, + default=100000, + help="How many points in each single series?", +) +parser.add_argument( + "--freq", + type=float, + default=1000, + help="Frequency of logging (applies to all series)", +) +parser.add_argument( + "--temporal-batch-size", + type=int, + default=None, + help="Number of rows to include in each log call", +) +parser.add_argument( + "--blueprint", + action="store_true", + help="Setup a blueprint for a 5s window", +) order = [ "forwards", @@ -40,7 +65,11 @@ "random", ] parser.add_argument( - "--order", type=str, default=order[0], help="What order to log the data in (applies to all series)", choices=order + "--order", + type=str, + default=order[0], + help="What order to log the data in (applies to all series)", + choices=order, ) series_type = [ @@ -68,6 +97,37 @@ def main() -> None: plot_paths = [f"plot_{i}" for i in range(0, args.num_plots)] series_paths = [f"series_{i}" for i in range(0, args.num_series_per_plot)] + if args.blueprint: + from rerun.blueprint import ( + Blueprint, + BlueprintPanel, + Grid, + SelectionPanel, + TimeRangeBoundary, + TimeSeriesView, + VisibleTimeRange, + ) + + print("logging blueprint!") + rr.send_blueprint( + Blueprint( + Grid(*[ + TimeSeriesView( + name=p, + origin=f"/{p}", + time_ranges=VisibleTimeRange( + "sim_time", + start=TimeRangeBoundary.cursor_relative(offset=rr.TimeInt(seconds=-2.5)), + end=TimeRangeBoundary.cursor_relative(offset=rr.TimeInt(seconds=2.5)), + ), + ) + for p in plot_paths + ]), + BlueprintPanel(state="collapsed"), + SelectionPanel(state="collapsed"), + ) + ) + time_per_sim_step = 1.0 / args.freq stop_time = args.num_points_per_series * time_per_sim_step @@ -110,7 +170,10 @@ def main() -> None: ticks = enumerate(sim_times) else: offsets = range(0, len(sim_times), args.temporal_batch_size) - ticks = zip(offsets, (sim_times[offset : offset + args.temporal_batch_size] for offset in offsets)) + ticks = zip( + offsets, + (sim_times[offset : offset + args.temporal_batch_size] for offset in offsets), + ) time_batch = None @@ -129,7 +192,11 @@ def main() -> None: else: value_index = slice(index, index + args.temporal_batch_size) value_batch = rr.components.ScalarBatch(values[value_index, plot_idx, series_idx]) - rr.log_temporal_batch(f"{plot_path}/{series_path}", times=[time_batch], components=[value_batch]) + rr.log_temporal_batch( + f"{plot_path}/{series_path}", + times=[time_batch], + components=[value_batch], + ) # Progress report From 673632c85c65ce9e23e3049f6550cf69263b5956 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Mon, 29 Jul 2024 14:41:28 +0200 Subject: [PATCH 2/2] review --- examples/python/blueprint/blueprint.py | 26 +++++++++++++-------- tests/python/plot_dashboard_stress/main.py | 27 ++++++++-------------- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/examples/python/blueprint/blueprint.py b/examples/python/blueprint/blueprint.py index 62310fd2fcb0..d13f4f3f80dc 100755 --- a/examples/python/blueprint/blueprint.py +++ b/examples/python/blueprint/blueprint.py @@ -7,7 +7,7 @@ import numpy as np import rerun as rr # pip install rerun-sdk -from rerun.blueprint import Blueprint, BlueprintPanel, Grid, SelectionPanel, Spatial2DView, TimePanel +import rerun.blueprint as rrb def main() -> None: @@ -26,10 +26,10 @@ def main() -> None: # # If auto_space_views is True, the blueprint will automatically add one of the heuristic # space views, which will include the image and both rectangles. - blueprint = Blueprint( - Grid( - Spatial2DView(name="Rect 0", origin="/", contents=["image", "rect/0"]), - Spatial2DView( + blueprint = rrb.Blueprint( + rrb.Grid( + rrb.Spatial2DView(name="Rect 0", origin="/", contents=["image", "rect/0"]), + rrb.Spatial2DView( name="Rect 1", origin="/", contents=["/**"], @@ -37,9 +37,9 @@ def main() -> None: overrides={"rect/0": [rr.components.Radius(1)]}, # Override the radius of rect/0 to be 1 ), ), - BlueprintPanel(state="collapsed"), - SelectionPanel(state="collapsed"), - TimePanel(state="collapsed"), + rrb.BlueprintPanel(state="collapsed"), + rrb.SelectionPanel(state="collapsed"), + rrb.TimePanel(state="collapsed"), auto_space_views=args.auto_space_views, ) @@ -49,8 +49,14 @@ def main() -> None: for i in range(8): img[(i * 16) + 4 : (i * 16) + 12, :] = (0, 0, 200) rr.log("image", rr.Image(img)) - rr.log("rect/0", rr.Boxes2D(mins=[16, 16], sizes=[64, 64], labels="Rect0", colors=(255, 0, 0))) - rr.log("rect/1", rr.Boxes2D(mins=[48, 48], sizes=[64, 64], labels="Rect1", colors=(0, 255, 0))) + rr.log( + "rect/0", + rr.Boxes2D(mins=[16, 16], sizes=[64, 64], labels="Rect0", colors=(255, 0, 0)), + ) + rr.log( + "rect/1", + rr.Boxes2D(mins=[48, 48], sizes=[64, 64], labels="Rect1", colors=(0, 255, 0)), + ) if __name__ == "__main__": diff --git a/tests/python/plot_dashboard_stress/main.py b/tests/python/plot_dashboard_stress/main.py index cb87596158d8..f34c2636e1a5 100755 --- a/tests/python/plot_dashboard_stress/main.py +++ b/tests/python/plot_dashboard_stress/main.py @@ -24,6 +24,7 @@ import numpy as np import rerun as rr # pip install rerun-sdk +import rerun.blueprint as rrb parser = argparse.ArgumentParser(description="Plot dashboard stress test") rr.script_add_args(parser) @@ -98,33 +99,23 @@ def main() -> None: series_paths = [f"series_{i}" for i in range(0, args.num_series_per_plot)] if args.blueprint: - from rerun.blueprint import ( - Blueprint, - BlueprintPanel, - Grid, - SelectionPanel, - TimeRangeBoundary, - TimeSeriesView, - VisibleTimeRange, - ) - print("logging blueprint!") rr.send_blueprint( - Blueprint( - Grid(*[ - TimeSeriesView( + rrb.Blueprint( + rrb.Grid(*[ + rrb.TimeSeriesView( name=p, origin=f"/{p}", - time_ranges=VisibleTimeRange( + time_ranges=rrb.VisibleTimeRange( "sim_time", - start=TimeRangeBoundary.cursor_relative(offset=rr.TimeInt(seconds=-2.5)), - end=TimeRangeBoundary.cursor_relative(offset=rr.TimeInt(seconds=2.5)), + start=rrb.TimeRangeBoundary.cursor_relative(offset=rr.TimeInt(seconds=-2.5)), + end=rrb.TimeRangeBoundary.cursor_relative(offset=rr.TimeInt(seconds=2.5)), ), ) for p in plot_paths ]), - BlueprintPanel(state="collapsed"), - SelectionPanel(state="collapsed"), + rrb.BlueprintPanel(state="collapsed"), + rrb.SelectionPanel(state="collapsed"), ) )