Spans
rerun.experimental.spans
Annotate and query time spans within dataset recordings.
Curation
A selection of inclusive training intervals, independent of editable span annotations.
Resolve datasets, views, and selected spans with from_source().
Create local selections with from_arrow() or from_parquet(), or save and open tagged selections
in the catalog. Tags are case-sensitive and scoped to the dataset. Saved selections are ordinary
tables; direct table APIs can still modify them. Tag lookup relies on their generated names.
Boundaries select sample anchors; field windows may extend beyond them.
Dataset contents must remain immutable for reproducible loading.
index_type
property
index_type: DataType
Integer steps or nanosecond-resolution timestamps/durations.
table
property
table: TableEntry
The underlying catalog table; local Arrow and Parquet selections have no catalog entry.
from_arrow
classmethod
def from_arrow(
dataset: DatasetEntry, data: Table | RecordBatch
) -> Curation
Validate, sort, and deduplicate exported coordinates without querying the dataset.
from_parquet
classmethod
def from_parquet(
dataset: DatasetEntry, path: str | PathLike[str]
) -> Curation
Read a portable selection together with its dataset and timeline identity.
from_source
classmethod
def from_source(
source: DatasetEntry | DatasetSelection,
*,
index: str,
spans: Curation | Table | RecordBatch | None = None,
) -> Curation
Resolve a dataset or view and optional span selection into a training manifest.
Reads recording metadata to freeze the selected recordings' inclusive timeline ranges. Selected spans are intersected with those ranges; missing recordings and disjoint intervals are omitted. The resulting Arrow coordinates can be saved without retaining the source view or annotation query. Content filters, training fields, and sampling settings are not stored in the manifest.
| PARAMETER | DESCRIPTION |
|---|---|
source
|
Dataset or filtered selection whose recordings are eligible for training.
TYPE:
|
index
|
Timeline on which to select intervals.
TYPE:
|
spans
|
Optional curation or canonical Arrow coordinates from
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
The timeline is missing or the selected spans have a different dataset or timeline identity. |
materialize
def materialize() -> Curation
Read once and return a local selection whose subsequent operations need no source reads.
num_spans
def num_spans() -> int
Number of distinct selected intervals; catalog selections are read to determine this count.
open
classmethod
def open(dataset: DatasetEntry, *, tag: str) -> Curation
Open a saved selection without looking up the dataset's annotation table or reading rows.
save
classmethod
def save(
dataset: DatasetEntry,
data: Table | RecordBatch,
*,
tag: str,
) -> Curation
Save exported coordinates under a new tag without reading annotation data.
Existing tags raise AlreadyExistsError. Creation and writing are separate operations;
failed writes can leave an incomplete table, which to_arrow() rejects.
to_arrow
def to_arrow() -> Table
Return canonical coordinates and identity metadata, rejecting incomplete saved writes.
SpanTable
Time span annotations for a dataset.
Data columns and one timeline are fixed at creation.
Every row requires inclusive start and end boundaries, stored in the timeline's own datatype:
int64 steps for sequence timelines, and nanoseconds for duration and timestamp timelines.
Span annotations have an independent lifecycle from their dataset.
__init__
def __init__(dataset: DatasetEntry, table: TableEntry) -> None
Wrap an existing span table; SpanTable.open finds a table by name.
| PARAMETER | DESCRIPTION |
|---|---|
dataset
|
The dataset whose segments the spans annotate.
TYPE:
|
table
|
A table with a span schema, as created by
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
append
def append(
*,
segment_id: str,
start: int | integer,
end: int | integer,
data: Mapping[str, Any] | None = None,
) -> str
def append(
*,
segment_id: str,
start: timedelta | timedelta64,
end: timedelta | timedelta64,
data: Mapping[str, Any] | None = None,
) -> str
def append(
*,
segment_id: str,
start: datetime | datetime64,
end: datetime | datetime64,
data: Mapping[str, Any] | None = None,
) -> str
def append(
*,
segment_id: str,
start: _Boundary,
end: _Boundary,
data: Mapping[str, Any] | None = None,
) -> str
Append one span and return its generated ID; data values populate declared columns.
segment_id must name a segment of the dataset.
start and end are inclusive.
Sequence timelines take int or numpy.integer boundaries, stored as given.
Duration timelines take datetime.timedelta or numpy.timedelta64 boundaries.
Timestamp timelines take datetime.datetime or numpy.datetime64 boundaries; naive datetimes are UTC.
Duration and timestamp values convert exactly to nanoseconds.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If a boundary type does not match the timeline kind. |
ValueError
|
If a boundary does not fit in 64 bits or is not exact in nanoseconds, |
arrow_schema
def arrow_schema() -> Schema
Returns the Arrow schema of the underlying table entry, which is fixed at creation.
create
classmethod
def create(
dataset: DatasetEntry,
index: str,
*,
name: str | None = None,
schema: Schema | None = None,
url: str | None = None,
) -> SpanTable
Create an empty table on the timeline index; schema declares data columns.
name defaults to a name in the catalog's spans folder derived from the dataset ID.
| RAISES | DESCRIPTION |
|---|---|
AlreadyExistsError
|
If a table named |
ValueError
|
If |
delete
def delete() -> None
Delete this table without deleting its dataset.
open
classmethod
def open(
dataset: DatasetEntry, *, name: str | None = None
) -> SpanTable
Open a span table of dataset.
name defaults to a name in the catalog's spans folder derived from the dataset ID.
| RAISES | DESCRIPTION |
|---|---|
LookupError
|
If no table named |
reader
def reader() -> DataFrame
Build a lazy DataFusion query on one timeline, joined with recording properties.
Filtering selects whole spans without altering boundaries or subtracting overlaps. Spans on segments no longer in the dataset are omitted, as are properties named like a span column. Low-level table writes remain responsible for valid span rows.
to_curation_arrow
def to_curation_arrow(
spans: Table | RecordBatch, *, index: str
) -> Table
Export selected coordinates with dataset and timeline identity, without source reads.
Input requires rerun_segment_id and the table's typed <index>:start/end columns.
Annotation data is discarded; Curation sorts and deduplicates the exported coordinates.
upsert
def upsert(
*,
segment_id: str,
start: int | integer,
end: int | integer,
span_id: str,
data: Mapping[str, Any] | None = None,
) -> str
def upsert(
*,
segment_id: str,
start: timedelta | timedelta64,
end: timedelta | timedelta64,
span_id: str,
data: Mapping[str, Any] | None = None,
) -> str
def upsert(
*,
segment_id: str,
start: datetime | datetime64,
end: datetime | datetime64,
span_id: str,
data: Mapping[str, Any] | None = None,
) -> str
def upsert(
*,
segment_id: str,
start: _Boundary,
end: _Boundary,
span_id: str,
data: Mapping[str, Any] | None = None,
) -> str
Insert or fully replace a row by its required ID; omitted nullable data columns become null.
start and end follow the same typed boundary rules as SpanTable.append.
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If |
ValueError
|
If |
write
def write(
spans: Table | RecordBatch,
*,
mode: Literal[
"append", "upsert", "overwrite"
] = "append",
) -> None
Write Arrow rows; overwrite with empty input clears the table.
Append and overwrite generate UUID4 IDs and reject supplied non-null IDs. Upsert requires IDs and replaces entire rows rather than patching columns.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If a column is undeclared, duplicated, or has the wrong ID type; a boundary column is not an integer or the
timeline's kind of time; a required column contains nulls; an ID is empty; a start is the minimum 64-bit
value or after its end; or a |