|
| 1 | +from __future__ import annotations |
| 2 | + |
| 3 | +import os |
| 4 | +from argparse import Namespace |
| 5 | +from uuid import uuid4 |
| 6 | + |
| 7 | +import rerun as rr |
| 8 | +import rerun.blueprint as rrb |
| 9 | + |
| 10 | +README = """\ |
| 11 | +# Blueprint overrides |
| 12 | +
|
| 13 | +This checks that overrides work as expected when sent via blueprint APIs. |
| 14 | +
|
| 15 | +Expected behavior: |
| 16 | +* The `sin` plot should be a blue line (set via defaults) |
| 17 | +* The `cos` plot should be a green points with cross markers (set via overrides) |
| 18 | +""" |
| 19 | + |
| 20 | + |
| 21 | +def log_readme() -> None: |
| 22 | + rr.log("readme", rr.TextDocument(README, media_type=rr.MediaType.MARKDOWN), static=True) |
| 23 | + |
| 24 | + |
| 25 | +def log_plots() -> None: |
| 26 | + from math import cos, sin, tau |
| 27 | + |
| 28 | + for t in range(0, int(tau * 2 * 10.0)): |
| 29 | + rr.set_time_sequence("frame_nr", t) |
| 30 | + |
| 31 | + sin_of_t = sin(float(t) / 10.0) |
| 32 | + rr.log("plots/sin", rr.Scalar(sin_of_t)) |
| 33 | + |
| 34 | + cos_of_t = cos(float(t) / 10.0) |
| 35 | + rr.log("plots/cos", rr.Scalar(cos_of_t)) |
| 36 | + |
| 37 | + rr.send_blueprint( |
| 38 | + rrb.Blueprint( |
| 39 | + rrb.Grid( |
| 40 | + rrb.TextDocumentView(origin="readme", name="Instructions"), |
| 41 | + rrb.TimeSeriesView( |
| 42 | + name="Plots", |
| 43 | + defaults=[rr.components.Color([0, 0, 255])], |
| 44 | + overrides={ |
| 45 | + "plots/cos": [ |
| 46 | + rrb.VisualizerOverrides("SeriesPoint"), |
| 47 | + rr.components.Color([0, 255, 0]), |
| 48 | + # TODDO(#6670): This should just be `rr.components.MarkerShape.Cross` |
| 49 | + rr.components.MarkerShapeBatch("cross"), |
| 50 | + ], |
| 51 | + }, |
| 52 | + ), |
| 53 | + ) |
| 54 | + ) |
| 55 | + ) |
| 56 | + |
| 57 | + |
| 58 | +def run(args: Namespace) -> None: |
| 59 | + rr.script_setup(args, f"{os.path.basename(__file__)}", recording_id=uuid4()) |
| 60 | + |
| 61 | + log_readme() |
| 62 | + log_plots() |
| 63 | + |
| 64 | + |
| 65 | +if __name__ == "__main__": |
| 66 | + import argparse |
| 67 | + |
| 68 | + parser = argparse.ArgumentParser(description="Interactive release checklist") |
| 69 | + rr.script_add_args(parser) |
| 70 | + args = parser.parse_args() |
| 71 | + run(args) |
0 commit comments