Catalog object model

This page covers the Rerun DB server's object model, which Rerun DB Local and Rerun DB share; the page notes where they differ. The rest of this section also applies to both servers, apart from the Rerun DB Local page. For logging and recording basics, see Recordings. For API details, see the Catalog SDK reference.

Catalog

We refer to the contents stored in a given Rerun DB server as the catalog. The catalog contains top-level objects called entries.

There are currently two types of entries: tables and datasets.

Entries share a few common properties:

  • id: a globally unique identifier
  • name: a user-provided name, which must be unique within the catalog

Renaming a catalog entry

The id of a catalog entry is immutable, but the name can be changed provided it remains unique. In Python, call set_name() on an entry to rename it on the Rerun DB server, for example:

client = rr.catalog.CatalogClient(…)
dataset = client.get_dataset("old_name")
dataset.set_name("new_name")

Structuring datasets

When working with larger amounts of data, it can be useful to organize catalog entries in a directory-like structure. This can be done by using . delimiters in the names. The screenshot below is an example of a dot-delimited dataset name showing up as a directory tree in the viewer's data source browser:

Data source browser with the tree hiw_500, episodes, revision_1 and revision_2 beside a table of the two dataset entries

Table entries

Table entries model a single table of data. They use the Arrow data model, so a table is logically equivalent to an Arrow table. As a result, tables possess an Arrow schema.

Through the Catalog SDK, you can append rows to a table, overwrite it, or upsert rows based on an index column. Thanks to DataFusion, tables also support most database operations such as querying, filtering, joining, etc. See Catalog tables for how to create, read, and update them, and Storing query results in a catalog table for a complete example.

Datasets

Dataset entries model a collection of Rerun data organized in episodes such as recorded runs of a given robotic task. These episodes within datasets are called segments, which are identified by a segment ID.

Segments are added to datasets by the process of registering a recording (typically stored in some object store such as S3) to the dataset using the Catalog SDK. By default, the recording ID of the .rrd file is used as its segment ID. To register it under another segment ID, pass segment_id to register(): see How can I register a recording under another segment ID?. Keep one recording per registered .rrd file. Only the first recording of a file is registered, as a single segment named after it.

Recordings registered to a given segment are organized by layers, identified by a layer name. By default, the "base" layer name is used. Registering two .rrd files under the same segment ID to the same dataset, and using the same layer name, throws an error by default. Pass on_duplicate=OnDuplicateSegmentLayer.REPLACE to register() to overwrite the existing layer, or SKIP to leave it in place. Additive registration can be achieved by using different layer names for different .rrds registered under the same segment ID.

Diagram of a catalog dataset with segment_a and segment_b, whose base and extra layers each point to an .rrd file in an object store Diagram of a catalog dataset with segment_a and segment_b, whose base and extra layers each point to an .rrd file in an object store

Layers are immutable and can only be overwritten by registering a new .rrd file. In other words, datasets support the following mutation operations:

  • create segment: by registering a .rrd under a "new" segment ID
  • append to segment: by registering a .rrd under a matching segment ID to a new layer name
  • overwrite segment layer: by registering a .rrd under a matching segment ID to an existing layer name, with on_duplicate=OnDuplicateSegmentLayer.REPLACE

Managing segment layers with the Python catalog API

Use DatasetEntry.segment() to get a handle to a segment, inspect its current layers, or get its Viewer URL. Call delete_layer() to unregister one layer from that segment, then wait for the returned handle to track completion. Unregistering removes catalog references but does not delete the underlying source objects.

segment = dataset.segment(segment_id)
print(segment.layers())
print(segment.url)

unregistration = segment.delete_layer("predictions")
unregistration.wait()

To inspect a named layer across the dataset, use dataset.layer(name).segment_ids(). The layer handle reads current membership on each call, including registrations and removals made after the handle was created. See finding segments in a layer for an example.

See the Segment API reference for details.

Schema

Datasets are based on the Rerun data model, which consists of a collection of chunks of Arrow data. These chunks hold data for various entities and components corresponding to various indexes (or timelines). A given collection of chunks, say, a dataset segment, defines an Arrow schema. We refer to this as schema-on-read, because the schema proceeds from the data, and not the other way around. This differs from the table model, where the schema is defined upfront (schema-on-write).

In this context, the schema of a dataset is the union of schemas of its segments, which themselves are the union of the schemas of their layers.

Use segment.schema() to fetch a snapshot of one segment's schema across its registered layers. Referenced assets are excluded from the segment's schema. Use dataset.layer(name).schema() to fetch the union of one layer's schemas across the segments that contain it.

segment_schema = dataset.segment(segment_id).schema()
print(segment_schema)
print(dataset.layer("base").schema())
print(dataset.schema())
print(dataset.schema().to_arrow())
Diagram of my_dataset schema stacked on segment_a schema (base and extra layer schemas) and segment_b schema (base schema) Diagram of my_dataset schema stacked on segment_a schema (base and extra layer schemas) and segment_b schema (base schema)

Datasets maintain a minimal level of schema self-consistency. Registering a .rrd whose schema is incompatible with the current dataset schema will result in an error. In this context, incompatible means that the schema of the new .rrd contains a column for the same entity, archetype, and component, but with a different Arrow type. Such an occurrence is rare, and practically impossible when using standard Rerun archetypes.

Blueprints

You can add blueprints to a dataset by registering .rbl blueprint files, typically stored in object storage. A dedicated API exists for this in the Catalog SDK: DatasetEntry.register_blueprint(). You can also set one as the default, which is then loaded with each segment of the dataset.

The registered blueprints show up in the Viewer in a dropdown in the top bar.

A separate table blueprint can be used to configure the segment table itself: columns, card layouts, and embedded segment previews. See Configure table layouts and segment previews for the complete save-and-register workflow.

Assets

An asset is static data registered on a dataset and shared by its segments, such as a robot URDF, a room mesh, or a calibration. Registering it once as an asset means it does not have to be copied into every recording.

Like blueprints, assets live in their own dataset, owned by the dataset they belong to. Deleting the dataset also deletes its asset dataset and the asset storage.

Assets are registered from a .rrd file that the server can read, using DatasetEntry.register_asset():

dataset = client.get_dataset("my_dataset")

# e.g. "s3://bucket/robot_mesh.rrd"
asset_id = dataset.register_asset(robot_mesh_uri)
print(dataset.assets())

dataset.unregister_asset(asset_id)

Asset datasets have some restrictions to keep them light, and the server rejects registrations that:

  • contain temporal data, since an asset may only contain static data
  • are larger than 300 MiB
  • would bring the dataset above 12 assets

Assets can apply to all segments except selected ones (mode="opt_out", the default), or only to selected segments (mode="opt_in"). Choose coverage during registration or change it later using add_segments_to_asset() and remove_segments_from_asset().

When the Rerun Viewer opens a segment, it loads the assets that apply to it along with the segment's own data. The asset data is cached, so opening another segment of the same dataset does not download it again. The assets tab of a dataset lists the registered assets and their coverage, and lets you register and unregister them and edit their coverage in the Viewer. If the server accepts uploads, the viewer can also upload a .rrd from your machine and register it as an asset.

Assets also show up in the python chunk processing api if include_assets is True:

segment_id = dataset.segment_ids()[0]

# Covers the chunks of both the segment and the dataset's assets.
store = dataset.segment_store(segment_id)
for chunk in store.stream().to_chunks():
    print(chunk.entity_path)

# Covers only the segment, and no asset manifests are fetched.
segment_only = dataset.segment_store(
    segment_id, include_assets=False
)

Fetching an asset's manifest costs one request per asset, so include_assets=False is worth it when you only care about the segment's own data.

The dataframe query APIs are the exception: they stay on the dataset's own segments, so assets never show up there. DatasetEntry.schema(), DatasetEntry.segment_ids(), DatasetEntry.segment_table() and DatasetEntry.reader() all ignore the asset dataset. The asset dataset is hidden, so it is also left out of CatalogClient.datasets() unless you pass include_hidden=True.

To query asset data, target the asset dataset itself, which is a regular dataset with one segment per registered asset:

asset_dataset = dataset.asset_dataset()
assert asset_dataset is not None

print(asset_dataset.schema())

# Assets only hold static data, so there is no index to read along.
df = asset_dataset.reader(index=None)