Operating Modes
There are many different ways of sending data to the Rerun Viewer depending on what you're trying to achieve and whether the Viewer is running in the same process as your code, in another process, or even as a separate web application.
In the official examples, these different modes of operation are exposed via a standardized set of flags that we'll cover below. We will also demonstrate how you can achieve the same behavior in your own code.
Before reading this document, you might want to familiarize yourself with the Rerun application model.
Operating modes operating-modes
The Rerun SDK provides 4 modes of operation: spawn
, connect
, serve
, and save
.
All four of them are optional: when none of these modes are active, the client will simply buffer the logged data in memory, waiting for one of these modes to be enabled so that it can flush it.
Spawn spawn
This is the default behavior you get when running all of our C++/Python/Rust examples, and is generally the most convenient when you're experimenting.
C++
RecordingStream::spawn
spawns a new Rerun Viewer process using an executable available in your PATH, then streams all the data to it via gRPC. If an external Viewer was already running, spawn
will connect to that one instead of spawning a new one.
Python
Call rr.spawn
once at the start of your program to start a Rerun Viewer in an external process and stream all the data to it via gRPC. If an external Viewer was already running, spawn
will connect to that one instead of spawning a new one.
Rust
RecordingStream::spawn
spawns a new Rerun Viewer process using an executable available in your PATH, then streams all the data to it via gRPC. If an external Viewer was already running, spawn
will connect to that one instead of spawning a new one.
Connect connect
Connects to a remote Rerun Viewer and streams all the data via gRPC.
You will need to start a stand-alone Viewer first by typing rerun
in your terminal.
C++
RecordingStream::connect
Python
Rust
Serve serve
There are two kinds of serve
calls:
serve_web
serve_grpc
Both will start a Rerun gRPC server in your process, and stream logged data to it.
The serve_web
call starts an additional server which hosts the assets required to run the Rerun Viewer in your browser.
C++
RecordingStream::serve_grpc
.serve_web
is not available.
Python
Rust
Save save
Streams all logging data into an .rrd
file on disk, which can then be loaded into a stand-alone viewer.
To view the saved file, use rerun path/to/file.rrd
.
ā ļø RRD files are not yet stable across different versions! ā ļø
C++
Use RecordingStream::save
.
Python
Use rr.save
.
Rust
Standard Input/Output standard-inputoutput
Streams all logging data to standard output, which can then be loaded by the Rerun Viewer by streaming it from standard input.
C++
Check out our dedicated example.
Python
Use rr.stdout
.
Check out our dedicated example.
Rust
Check out our dedicated example.
Adding the standard flags to your programs adding-the-standard-flags-to-your-programs
We provide helpers for both Python & Rust to effortlessly add and properly handle all of these flags in your programs.
- For Python, checkout the
script_helpers
module. - For Rust, checkout our
clap
integration.
Have a look at the official examples to see these helpers in action.