Skip to content

Commit 3eb08b7

Browse files
authored
Finish dataframe reference page (#7865)
We were missing a bunch of features and assets to be able to finish this, but now we have it all.
1 parent ea91bcd commit 3eb08b7

8 files changed

+162
-11
lines changed

docs/content/reference/dataframes.md

+36-7
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,54 @@ For an in-depth introduction to the dataframe API and the possible workflows it
2121
2222
### Using the dataframe API
2323
24-
The following snippet demonstrates how to query the first 10 rows in a Rerun recording:
24+
The following snippet demonstrates how to query the first 10 rows in a Rerun recording using latest-at (i.e. time-aligned) semantics:
2525
2626
snippet: reference/dataframe_query
2727
2828
Check out the API reference to learn more about all the ways that data can be searched and filtered:
2929
* [🐍 Python API reference](https://ref.rerun.io/docs/python/stable/common/dataframe/)
30-
* [🐍 Python example](https://github.com/rerun-io/rerun/blob/c00a9f649fd4463f91620e8e2eac11355b245ac5/examples/python/dataframe_query/dataframe_query.py)
31-
* [🦀 Rust API reference](https://docs.rs/crate/rerun/latest)
32-
* [🦀 Rust example](https://github.com/rerun-io/rerun/blob/c00a9f649fd4463f91620e8e2eac11355b245ac5/examples/rust/dataframe_query/src/main.rs)
30+
* [Example](https://github.com/rerun-io/rerun/blob/c00a9f649fd4463f91620e8e2eac11355b245ac5/examples/python/dataframe_query/dataframe_query.py)
31+
* [🦀 Rust API reference](https://docs.rs/rerun/latest/rerun/dataframe/index.html)
32+
* [Example](https://github.com/rerun-io/rerun/blob/c00a9f649fd4463f91620e8e2eac11355b245ac5/examples/rust/dataframe_query/src/main.rs)
3333
3434
3535
### Using the blueprint API to configure a dataframe view
3636
37-
TODO(cmc): incoming.
37+
The following snippet demonstrates how visualize an entire Rerun recording using latest-at (i.e. time-aligned) semantics by displaying the results in a [dataframe view](types/views/dataframe_view):
3838
39-
Check out the blueprint API reference to learn more about all the ways that data can be searched and filtered:
39+
snippet: reference/dataframe_view_query
40+
41+
<picture>
42+
<img src="https://static.rerun.io/dataframe_query_example/d3dc908edb09377fbdc4c8f16b1b35a7a35a5e7d/full.png" alt="">
43+
<source media="(max-width: 480px)" srcset="https://static.rerun.io/dataframe_query_example/d3dc908edb09377fbdc4c8f16b1b35a7a35a5e7d/480w.png">
44+
<source media="(max-width: 768px)" srcset="https://static.rerun.io/dataframe_query_example/d3dc908edb09377fbdc4c8f16b1b35a7a35a5e7d/768w.png">
45+
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/dataframe_query_example/d3dc908edb09377fbdc4c8f16b1b35a7a35a5e7d/1024w.png">
46+
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/dataframe_query_example/d3dc908edb09377fbdc4c8f16b1b35a7a35a5e7d/1200w.png">
47+
</picture>
48+
49+
#### Aside: re-using blueprint files from other SDKs
50+
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.
52+
53+
First, save the blueprint to a file (`.rbl` by convention) using either the viewer (`Menu > Save blueprint`) or the python API:
54+
55+
snippet: reference/dataframe_save_blueprint
56+
57+
Then log that blueprint file in addition to the data itself:
58+
59+
snippet: reference/dataframe_view_query_external
60+
61+
Check out the blueprint API and `log_file_from_path` references to learn more:
4062
* [🐍 Python blueprint API reference](https://ref.rerun.io/docs/python/latest/common/blueprint_apis/)
63+
* [🐍 Python `log_file_from_path`](https://ref.rerun.io/docs/python/latest/common/logging_functions/#rerun.log_file_from_path)
64+
* [🦀 Rust `log_file_from_path`](https://docs.rs/rerun/latest/rerun/struct.RecordingStream.html#method.log_file_from_path)
65+
* [🌊 C++ `log_file_from_path`](https://ref.rerun.io/docs/cpp/stable/classrerun_1_1RecordingStream.html#a20798d7ea74cce5c8174e5cacd0a2c47)
4166
4267
4368
### Setting up dataframe view manually in the UI
4469
45-
TODO(cmc): incoming.
70+
The same [dataframe view](types/views/dataframe_view) shown above can be configured purely from the UI:
71+
72+
<video width="100%" autoplay loop muted controls>
73+
<source src="https://static.rerun.io/dataframe/df-dna-demo.webm" type="video/webm" />
74+
</video>

docs/snippets/all/reference/dataframe_query.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//! Query and display the first 10 rows of a recording.
22
3-
#![allow(clippy::unwrap_used)]
4-
53
use rerun::{
64
dataframe::{QueryCache, QueryEngine, QueryExpression, SparseFillStrategy, Timeline},
75
ChunkStore, ChunkStoreConfig, VersionPolicy,
@@ -18,7 +16,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
1816
path_to_rrd,
1917
VersionPolicy::Warn,
2018
)?;
21-
let (_, store) = stores.first_key_value().unwrap();
19+
let Some((_, store)) = stores.first_key_value() else {
20+
return Ok(());
21+
};
2222

2323
let query_cache = QueryCache::new(store);
2424
let query_engine = QueryEngine {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""Craft a 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.DataframeView(
11+
origin="/",
12+
query=rrb.archetypes.DataframeQuery(
13+
timeline="log_time",
14+
apply_latest_at=True,
15+
),
16+
),
17+
).save("rerun_example_dataframe_view_query", path_to_rbl)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""Query and display the first 10 rows of a recording in a dataframe view."""
2+
3+
import sys
4+
5+
import rerun as rr
6+
import rerun.blueprint as rrb
7+
8+
path_to_rrd = sys.argv[1]
9+
10+
rr.init("rerun_example_dataframe_view_query", spawn=True)
11+
12+
rr.log_file_from_path(path_to_rrd)
13+
14+
blueprint = rrb.Blueprint(
15+
rrb.DataframeView(
16+
origin="/",
17+
query=rrb.archetypes.DataframeQuery(
18+
timeline="log_time",
19+
apply_latest_at=True,
20+
),
21+
),
22+
)
23+
24+
rr.send_blueprint(blueprint)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//! Query and display the first 10 rows of a recording in a dataframe view.
2+
//!
3+
//! The blueprint is being loaded from an existing blueprint recording file.
4+
5+
// ./dataframe_view_query_external /tmp/dna.rrd /tmp/dna.rbl
6+
7+
#include <string>
8+
9+
#include <rerun.hpp>
10+
11+
int main(int argc, char** argv) {
12+
if (argc < 3) {
13+
return 1;
14+
}
15+
16+
std::string path_to_rrd = argv[1];
17+
std::string path_to_rbl = argv[2];
18+
19+
const auto rec = rerun::RecordingStream("rerun_example_dataframe_view_query_external");
20+
rec.spawn().exit_on_failure();
21+
22+
// Log the files
23+
rec.log_file_from_path(path_to_rrd);
24+
rec.log_file_from_path(path_to_rbl);
25+
26+
return 0;
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""
2+
Query and display the first 10 rows of a recording in a dataframe view.
3+
4+
The blueprint is being loaded from an existing blueprint recording file.
5+
"""
6+
7+
# python dataframe_view_query_external.py /tmp/dna.rrd /tmp/dna.rbl
8+
9+
import sys
10+
11+
import rerun as rr
12+
13+
path_to_rrd = sys.argv[1]
14+
path_to_rbl = sys.argv[2]
15+
16+
rr.init("rerun_example_dataframe_view_query_external", spawn=True)
17+
18+
rr.log_file_from_path(path_to_rrd)
19+
rr.log_file_from_path(path_to_rbl)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//! Query and display the first 10 rows of a recording in a dataframe view.
2+
//!
3+
//! The blueprint is being loaded from an existing blueprint recording file.
4+
5+
// cargo r -p snippets -- dataframe_view_query_external /tmp/dna.rrd /tmp/dna.rbl
6+
7+
fn main() -> Result<(), Box<dyn std::error::Error>> {
8+
let args = std::env::args().collect::<Vec<_>>();
9+
10+
let path_to_rrd = &args[1];
11+
let path_to_rbl = &args[2];
12+
13+
let rec = rerun::RecordingStreamBuilder::new("rerun_example_dataframe_view_query_external")
14+
.spawn()?;
15+
16+
rec.log_file_from_path(path_to_rrd, None /* prefix */, false /* static */)?;
17+
rec.log_file_from_path(path_to_rbl, None /* prefix */, false /* static */)?;
18+
19+
Ok(())
20+
}

docs/snippets/snippets.toml

+16-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,22 @@ views = [
4242
"rust",
4343
"py",
4444
]
45-
"reference/dataframe_query" = [ # Requires RRD files, which are unstable
45+
"reference/dataframe_query" = [ # No output
46+
"cpp",
47+
"rust",
48+
"py",
49+
]
50+
"reference/dataframe_save_blueprint" = [ # No output
51+
"cpp",
52+
"rust",
53+
"py",
54+
]
55+
"reference/dataframe_view_query" = [ # No output
56+
"cpp",
57+
"rust",
58+
"py",
59+
]
60+
"reference/dataframe_view_query_external" = [ # No output
4661
"cpp",
4762
"rust",
4863
"py",

0 commit comments

Comments
 (0)