Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --blueprint to plot_dashboard_stress #311

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions examples/python/blueprint/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -26,20 +26,20 @@ 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=["/**"],
defaults=[rr.components.Radius(2)], # Default all rectangles to have a radius of 2
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,
)

Expand All @@ -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__":
Expand Down
72 changes: 65 additions & 7 deletions tests/python/plot_dashboard_stress/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,53 @@

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)

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",
"backwards",
"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 = [
Expand Down Expand Up @@ -68,6 +98,27 @@ 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:
print("logging blueprint!")
rr.send_blueprint(
rrb.Blueprint(
rrb.Grid(*[
rrb.TimeSeriesView(
name=p,
origin=f"/{p}",
time_ranges=rrb.VisibleTimeRange(
"sim_time",
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
]),
rrb.BlueprintPanel(state="collapsed"),
rrb.SelectionPanel(state="collapsed"),
)
)

time_per_sim_step = 1.0 / args.freq
stop_time = args.num_points_per_series * time_per_sim_step

Expand Down Expand Up @@ -110,7 +161,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

Expand All @@ -129,7 +183,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

Expand Down
Loading