Skip to content

Commit ac06d5e

Browse files
authored
Docs: "How-to: reuse blueprints across languages" (#7886)
By popular demand. * Fixes #7858 * DNM: requires #7882
1 parent 27ea795 commit ac06d5e

File tree

6 files changed

+84
-3
lines changed

6 files changed

+84
-3
lines changed

docs/content/concepts/blueprint.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Blueprint
2+
title: Blueprints
33
order: 600
44
---
55

docs/content/howto/visualization/configure-viewer-through-code.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Configure the Viewer through code
2+
title: Configure the Viewer through code (Blueprints)
33
order: 100
44
---
55

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
title: Re-use blueprints across sessions and SDKs
3+
order: 150
4+
---
5+
6+
While the [blueprint APIs](configure-viewer-through-code) are currently only available through [🐍 Python](https://ref.rerun.io/docs/python/stable/common/blueprint_apis/), blueprints can be saved to file and then re-logged as needed from any language our SDKs support.
7+
8+
This enables you to re-use your saved blueprints both from any language we support as well as across different recordings that share a similar-enough structure, and makes it possible to share those blueprints with other users.
9+
10+
For this you'll need to 1) create a blueprint file and B) _import_ that file when needed.
11+
12+
13+
## Creating a blueprint file
14+
15+
Blueprint files (`.rbl`, by convention) can currently be created in two ways.
16+
17+
One is to use the Rerun viewer to interactively build the blueprint you want (e.g. by moving panels around, changing view settings, etc), and then using `Menu > Save blueprint` (or the equivalent palette command) to save the blueprint as a file.
18+
19+
The other is to use the [🐍 Python blueprint API](https://ref.rerun.io/docs/python/stable/common/blueprint_apis/) to programmatically build the blueprint, and then use the [`Blueprint.save`](https://ref.rerun.io/docs/python/0.19.0/common/blueprint_apis/#rerun.blueprint.Blueprint.save) method to save it as a file:
20+
21+
snippet: tutorials/visualization/save_blueprint
22+
23+
24+
## (Re)Using a blueprint file
25+
26+
There are two ways to re-use a blueprint file.
27+
28+
The interactive way is to import the blueprint file directly into the Rerun viewer, using either `Menu > Import…` (or the equivalent palette command) or simply by drag-and-dropping the blueprint file into your recording.
29+
30+
The programmatic way works by calling `log_file_from_path`:
31+
* [🐍 Python `log_file_from_path`](https://ref.rerun.io/docs/python/stable/common/logging_functions/#rerun.log_file_from_path)
32+
* [🦀 Rust `log_file_from_path`](https://docs.rs/rerun/latest/rerun/struct.RecordingStream.html#method.log_file_from_path)
33+
* [🌊 C++ `log_file_from_path`](https://ref.rerun.io/docs/cpp/stable/classrerun_1_1RecordingStream.html#a20798d7ea74cce5c8174e5cacd0a2c47)
34+
35+
This method allows you to log any file that contains data that Rerun understands (in this case, blueprint data) as part of your current recording:
36+
37+
snippet: tutorials/visualization/load_blueprint
38+
39+
40+
## Limitation: dynamic blueprints
41+
42+
Sometimes, you might need your blueprint to dynamically react to the data you receive at runtime (e.g. you want to create one view per anomaly detected, and there is no way of knowing how many anomalies you're going to detect until the program actually runs).
43+
44+
The only way to deal with these situations today is to use the [🐍 Python](https://ref.rerun.io/docs/python/stable/common/blueprint_apis/) API.

docs/content/reference/dataframes.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ snippet: reference/dataframe_view_query
4848
4949
#### Aside: re-using blueprint files from other SDKs
5050
51-
While the blueprint APIs are currently only available in Python, blueprints can be saved and re-logged as needed from any language our SDKs support.
51+
While the blueprint APIs are currently only available through Python, blueprints can be saved and re-logged as needed from any language our SDKs support.
5252
5353
First, save the blueprint to a file (`.rbl` by convention) using either the viewer (`Menu > Save blueprint`) or the python API:
5454
@@ -64,6 +64,8 @@ Check out the blueprint API and `log_file_from_path` references to learn more:
6464
* [🦀 Rust `log_file_from_path`](https://docs.rs/rerun/latest/rerun/struct.RecordingStream.html#method.log_file_from_path)
6565
* [🌊 C++ `log_file_from_path`](https://ref.rerun.io/docs/cpp/stable/classrerun_1_1RecordingStream.html#a20798d7ea74cce5c8174e5cacd0a2c47)
6666
67+
You can learn more in our [dedicated page about blueprint re-use](../howto/visualization/reuse-blueprints).
68+
6769
6870
### Setting up dataframe view manually in the UI
6971
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""Demonstrates how to programmatically re-use a blueprint stored in a file."""
2+
3+
import sys
4+
5+
import rerun as rr
6+
7+
path_to_rbl = sys.argv[1]
8+
9+
rr.init("rerun_example_reuse_blueprint_file", spawn=True)
10+
rr.log_file_from_path(path_to_rbl)
11+
12+
# … log some data as usual …
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""Craft an example blueprint with the python API and save it to a file for future use."""
2+
3+
import sys
4+
5+
import rerun.blueprint as rrb
6+
7+
path_to_rbl = sys.argv[1]
8+
9+
rrb.Blueprint(
10+
rrb.Horizontal(
11+
rrb.Grid(
12+
rrb.BarChartView(name="Bar Chart", origin="/bar_chart"),
13+
rrb.TimeSeriesView(
14+
name="Curves",
15+
origin="/curves",
16+
),
17+
),
18+
rrb.TextDocumentView(name="Description", origin="/description"),
19+
column_shares=[3, 1],
20+
),
21+
rrb.SelectionPanel(state="collapsed"),
22+
rrb.TimePanel(state="collapsed"),
23+
).save("your_blueprint_name", path_to_rbl)

0 commit comments

Comments
 (0)