Migrating from 0.8 to 0.9
Rerun-0.9 introduces a new set of type-oriented logging APIs built on top of an updated, more concrete, data model.
Rather than using different functions to log different kinds of data, all data logging now goes through a singular log
function. The easiest way to use the log
function is with the Rerun-provided "Archetypes."
Archetypes are a newly introduced concept in the data model to go alongside "Components" and "DataTypes." Archetypes
represent common objects that are natively understood by the viewer, e.g. Image
or Points3D
. Every legacy logging
API has been replaced by one (or more) new Archetypes. You can find more information in the Entity Component section, and a list of available archetypes in the
Archetype Overview. All Archetypes are part of the top-level rerun
namespace.
In practice, the changes are mostly demonstrated in the following example:
import rerun as rr
# 0.8
rr.log_point("my_point", [1.0, 2.0, 3.0])
# 0.9
rr.log("my_point", rr.Points3D([1.0, 2.0, 3.0]))
Note that for any Archetype that supports batching the object names are now plural. For example, points are now logged
with the Points3D
archetype. Even if you are logging a single point, under the hood it is always implemented as a
batch of size 1.
For more information on the relationship between Archetypes, Components, and DataTypes, please see our guide to the Rerun Data Model.
Migrating Python code
All of the previous log_*
functions have been marked as deprecated and will be removed in 0.10
. We have done our
best to keep these functions working as thin wrappers on top of the new logging APIs, though there may be subtle
behavioral differences.
The log module has become the log function the-log-module-has-become-the-log-function
This is one area where we were forced to make breaking changes. Rerun previously had an internal log
module where the
assorted log-functions and helper classes were implemented. In general, these symbols were all re-exported to the
top-level rerun
namespace. However, in some cases these fully-qualified paths were used for imports. Because
rerun.log
is now a function rather than a module, any such imports will result in an import error. Look for the
corresponding symbol in the top-level rerun
namespace instead. For instance: rr.log.text.LoggingHandler
→ rr.LoggingHandler
Updating to the log APIs updating-to-the-log-apis
In most cases migrating your code to the new APIs should be straightforward. The legacy functions have been marked as deprecated and the deprecation warning should point you to the correct Archetype to use instead. Additionally, in most cases, the old parameter names match the parameters taken by the new Archetype constructors, though exceptions are noted below.
log_annotation_context logannotationcontext
Replace with AnnotationContext
Python docs: AnnotationContext
Notes:
class_descriptions
has becomecontext
rr.ClassDescription
now requiresinfo
to be provided rather than defaulting to 0.rr.AnnotationInfo
now requiresid
to be provided rather than defaulting to 0.
log_arrow logarrow
Replace with Arrows3D
Python docs: Arrows3D
Notes:
with_scale
has becomeradii
, which entails dividing by 2 as necessary.identifiers
has becomeinstance_keys
.
log_cleared logcleared
Replace with Clear
Python docs: Clear
log_depth_image logdepthimage
Replace with DepthImage
Python docs: DepthImage
Notes:
image
has becomedata
log_disconnected_space logdisconnectedspace
Replace with DisconnectedSpace
Python docs: DisconnectedSpace
log_extension_components logextensioncomponents
Replace with AnyValues
Python docs: AnyValues
Notes:
- Instead of passing
ext
as a dictionary,AnyValues
now maps all keyword arguments directly to components.rr.log_extension_components(…, ext={'mydata': 1})
becomesrr.log(… rr.AnyValues(mydata=1))
log_image logimage
Replace with Image
Python docs: Image
Notes:
image
has becomedata
jpeg_quality
is now handled by calling.compress(jpeg_quality=…)
on the image after constructing it.
log_image_file logimagefile
Replace with ImageEncoded
Python docs: ImageEncoded
Notes:
img_bytes
andimg_path
log_line_strip, log_line_strips_2d, log_line_strips_3d, log_line_segments loglinestrip-loglinestrips2d-loglinestrips3d-loglinesegments
Replace with LineStrips2D or LineStrips3D
Python docs: LineStrips2D, LineStrips3D
Notes:
log_line_segments
used to take an array of shape (2 * num_segments, 2 or 3) (where points were connected in even-odd pairs). Instead this is now handled by a batch ofLineStrips
all of length 2. Note thatLineStrips
now takes any sequence of arrays of shape (num_points_per_strip, 2 or 3). You can use convert to the new format using the snippets:
line_strips2d=line_segments.reshape(-1, 2, 2)
line_strips3d=line_segments.reshape(-1, 2, 3)
positions
has becomestrips
.stroke_width
has becomeradii
, which entails dividing by 2 as necessary.identifiers
has becomeinstance_keys
.
log_mesh, log_meshes logmesh-logmeshes
Replace with Mesh3D
Python docs: Mesh3D
Notes:
- Meshes are no longer batch objects. Instead they are treated as a batch of vertices, as such there is no longer a
direct equivalent of
log_meshes
. positions
has becomevertex_positions
.normals
has becomevertex_normals
.albedo_factor
has becomemesh_material
, and can be logged usingrr.Material(albedo_factor=…)
.identifiers
has becomeinstance_keys
.
log_mesh_file logmeshfile
Replace with Asset3D
Python docs: Asset3D
Notes:
mesh_bytes
andmesh_path
are both now jutdata
. Strings and paths will be opened as files, while file-descriptors or bytes objects will be read.mesh_format
is nowmedia_type
.transform
can now take anything that is compatible withrr.Transform3D
instead of an affine 3x4 matrix.- To convert an existing affine 3x4 matrix to an
rr.Transform3D
, you can use,rr.Transform3D(translation=transform[:,3], mat3x3=transform[:,0:3])
- To convert an existing affine 3x4 matrix to an
log_obb, log_obbs logobb-logobbs
Replace with Boxes3D
Python docs: Boxes3D
Notes:
positions
has becomecenters
.rotations_q
has becomerotations
and can now take anyRotation3DArrayLike
such asrr.Quaternion
orrr.RotationAxisAngle
.stroke_width
has becomeradii
, which entails dividing by 2 as necessary.identifiers
has becomeinstance_keys
.
log_pinhole logpinhole
Replace with Pinhole
Python docs: Pinhole
Notes:
child_from_parent
has becomeimage_from_parent
.focal_length_px
has becomefocal_length
.principal_point_px
has becomeprincipal_point
.- New argument
resolution
to specify width and height usingVec2D
camera_xyz
no longer take a string. Now use one of the constants fromrr.ViewCoordinates
log_point, log_points logpoint-logpoints
Replace with Points2D or Points3D.
Python docs: Points2D, Points3D
Notes:
stroke_width
has becomeradii
, which entails dividing by 2 as necessary.identifiers
has becomeinstance_keys
log_rect, log_rects logrect-logrects
Replace with Boxes2D
Python docs: Boxes2D
Notes:
- Can now be constructed with 2 arrays:
centers
, and eitherhalf_sizes
osizes
.- The legacy behavior of a single array can be matched by using the params
array
andarray_format
.array_format
takes anrr.Box2DFormat
.
- The legacy behavior of a single array can be matched by using the params
identifiers
has becomeinstance_keys
.
log_scalar logscalar
Replace with TimeSeriesScalar
log_segmentation_image logsegmentationimage
Replace with SegmentationImage
Python docs: SegmentationImage
Notes:
image
has becomedata
log_tensor logtensor
Replace with Tensor
Python docs: Tensor
Notes:
tensor
has becomedata
.names
has becomedim_names
.meter
is no longer supported -- userr.DepthImage
instead.- 1D Tensors can now be logged with BarChart
log_text_entry logtextentry
Replace with TextLog
Python docs: TextLog
log_transform3d logtransform3d
Replace with Transform3D
Python docs: Transform3D
Notes:
- Now takes optional parameters for
translation
,rotation
,scale
, ormat3x3
to simplify construction.
log_view_coordinates logviewcoordinates
Replace with ViewCoordinates
Python docs: ViewCoordinates
Notes:
- Rather than providing
xyz
orup
as strings,rr.ViewCoordinates
exposes a large number of constants that can be logged directly. For example:rr.ViewCoordinates.RDF
orrr.ViewCoordinates.RIGHT_HAND_Z_DOWN)
Migrating Rust code
Rust already used a more type oriented interface, so the changes are not as drastic as to the Python API.
Removal of MsgSender removal-of-msgsender
The biggest change that MsgSender
is gone and all logging happens instead directly on the RecordingStream::RecordingStream
using its log
and RecordingStream::log_timeless
functions.
Logging time logging-time
The new log
function logs time implicitly. log_time
and log_tick
are always included, as well as any custom timeline set using RecordingStream::set_timepoint
, or one of the shorthands RecordingStream::set_time_sequence
/RecordingStream::set_time_seconds
/RecordingStream::set_time_nanos
Components -> archetypes components--archetypes
The new log messages consume any type that implements the AsComponents
trait
which is implemented by all archetypes.
All previously separately logged components have corresponding types and are used in one or more archetypes.
See the respective API docs as well as the Archetype Overview to learn more and find self-contained code examples.
For continuing to log collections of components without implementing the AsComponents
trait, use RecordingStream::log_component_batches
Splatting splatting
Splatting is no longer done explicitly (before MsgSender::splat
), but automatically inferred whenever
there is a single component together with larger component batches on the same entity path.
See also RecordingStream::log_component_batches
for more information.