Skip to content

Commit 7293f69

Browse files
authored
Python: remove legacy send_columns and update everything left (#8799)
Title.
1 parent d9fefc3 commit 7293f69

37 files changed

+160
-455
lines changed

crates/store/re_types/definitions/rerun/components/video_timestamp.fbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ namespace rerun.components;
44
/// Timestamp inside a [archetypes.AssetVideo].
55
struct VideoTimestamp (
66
"attr.arrow.transparent",
7+
"attr.python.array_aliases": "npt.NDArray[np.int64]",
78
"attr.rust.derive": "Copy, PartialEq, Eq, Default",
89
"attr.rust.repr": "transparent"
910
) {

crates/store/re_types/definitions/rerun/datatypes/video_timestamp.fbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace rerun.datatypes;
77
struct VideoTimestamp (
88
"attr.arrow.transparent",
99
"attr.python.aliases": "int",
10+
"attr.python.array_aliases": "npt.NDArray[np.int64]",
1011
"attr.rust.derive": "Default, Copy, PartialEq, Eq, PartialOrd, Ord",
1112
"attr.rust.tuple_struct"
1213
) {

docs/content/getting-started/data-out/analyze-and-send.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ Here is how to send the data as a scalar:
4646
```python
4747
rr.send_columns(
4848
"/jaw_open_state",
49-
times=[rr.TimeSequenceColumn("frame_nr", df["frame_nr"])],
50-
components=[
51-
rr.components.ScalarBatch(df["jawOpenState"]),
52-
],
49+
indexes=[rr.TimeSequenceColumn("frame_nr", df["frame_nr"])],
50+
columns=rr.Scalar.columns(scalar=df["jawOpenState"]),
5351
)
5452
```
5553

@@ -59,17 +57,15 @@ Next, let's send the same data as `Text` component:
5957

6058
```python
6159
target_entity = "/video/detector/faces/0/bbox"
62-
rr.log(target_entity, [rr.components.ShowLabels(True)], static=True)
60+
rr.log(target_entity, rr.Boxes2D.update_fields(show_labels=True), static=True)
6361
rr.send_columns(
6462
target_entity,
65-
times=[rr.TimeSequenceColumn("frame_nr", df["frame_nr"])],
66-
components=[
67-
rr.components.TextBatch(np.where(df["jawOpenState"], "OPEN", "CLOSE")),
68-
],
63+
indexes=[rr.TimeSequenceColumn("frame_nr", df["frame_nr"])],
64+
columns=rr.Boxes2D.columns(labels=np.where(df["jawOpenState"], "OPEN", "CLOSE")),
6965
)
7066
```
7167

72-
Here we first log the [`ShowLabel`](../../reference/types/components/show_labels.md) component as static to enable the display of the label. Then, we use `rr.send_column()` again to send an entire batch of text labels. We use the [`np.where()`](https://numpy.org/doc/stable/reference/generated/numpy.where.html) to produce a label matching the state for each timestamp.
68+
Here we first log the [`ShowLabel`](../../reference/types/components/show_labels.md) component as static to enable the display of the label. Then, we use `rr.send_column()` again to send an entire batch of text labels. We use [`np.where()`](https://numpy.org/doc/stable/reference/generated/numpy.where.html) to produce a label matching the state for each timestamp.
7369

7470
### Final result
7571

docs/snippets/INDEX.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/snippets/all/archetypes/image_send_columns.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@
1717

1818
# Log the ImageFormat and indicator once, as static.
1919
format_static = rr.components.ImageFormat(width=width, height=height, color_model="RGB", channel_datatype="U8")
20-
rr.log("images", [format_static, rr.Image.indicator()], static=True)
20+
rr.send_columns("images", indexes=[], columns=rr.Image.columns(format=format_static))
2121

2222
# Send all images at once.
2323
rr.send_columns(
2424
"images",
25-
times=[rr.TimeSequenceColumn("step", times)],
26-
# Reshape the images so `ImageBufferBatch` can tell that this is several blobs.
25+
indexes=[rr.TimeSequenceColumn("step", times)],
26+
# Reshape the images so `Image` can tell that this is several blobs.
2727
#
28-
# Note that the `ImageBufferBatch` consumes arrays of bytes,
29-
# so if you have a different channel datatype than `U8`, you need to make sure
30-
# that the data is converted to arrays of bytes before passing it to `ImageBufferBatch`.
31-
components=[rr.components.ImageBufferBatch(images.reshape(len(times), -1))],
28+
# Note that the `Image` consumes arrays of bytes, so if you have a different channel
29+
# datatype than `U8`, you need to make sure that the data is converted to arrays of bytes
30+
# before passing it to `Image`.
31+
columns=rr.Image.columns(buffer=images.reshape(len(times), -1)),
3232
)

docs/snippets/all/archetypes/mesh3d_partial_updates.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import numpy as np
44
import rerun as rr
5-
from rerun.components import Position3DBatch
65

76
rr.init("rerun_example_mesh3d_partial_updates", spawn=True)
87

@@ -23,4 +22,4 @@
2322
factors = np.abs(np.sin(np.arange(1, 300, dtype=np.float32) * 0.04))
2423
for i, factor in enumerate(factors):
2524
rr.set_time_sequence("frame", i)
26-
rr.log("triangle", [Position3DBatch(vertex_positions * factor)])
25+
rr.log("triangle", rr.Mesh3D.update_fields(vertex_positions=vertex_positions * factor))

docs/snippets/all/archetypes/points3d_partial_updates_legacy.cpp

Lines changed: 0 additions & 58 deletions
This file was deleted.

docs/snippets/all/archetypes/points3d_partial_updates_legacy.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

docs/snippets/all/archetypes/points3d_partial_updates_legacy.rs

Lines changed: 0 additions & 51 deletions
This file was deleted.

docs/snippets/all/archetypes/points3d_send_columns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
colors = [0xFF0000FF, 0x00FF00FF, 0x0000FFFF, 0xFFFF00FF, 0x00FFFFFF]
2424
radii = [0.05, 0.01, 0.2, 0.1, 0.3]
2525

26-
rr.send_columns_v2(
26+
rr.send_columns(
2727
"points",
2828
indexes=[rr.TimeSecondsColumn("time", times)],
2929
columns=[

docs/snippets/all/archetypes/scalar_send_columns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
times = np.arange(0, 64)
1111
scalars = np.sin(times / 10.0)
1212

13-
rr.send_columns_v2(
13+
rr.send_columns(
1414
"scalars",
1515
indexes=[rr.TimeSequenceColumn("step", times)],
1616
columns=rr.Scalar.columns(scalar=scalars),

docs/snippets/all/archetypes/video_auto_frames.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"""Log a video asset using automatically determined frame references."""
2-
# TODO(#7298): ⚠️ Video is currently only supported in the Rerun web viewer.
32

43
import sys
54

@@ -21,6 +20,6 @@
2120
rr.send_columns(
2221
"video",
2322
# Note timeline values don't have to be the same as the video timestamps.
24-
times=[rr.TimeNanosColumn("video_time", frame_timestamps_ns)],
25-
components=[rr.VideoFrameReference.indicator(), rr.components.VideoTimestamp.nanoseconds(frame_timestamps_ns)],
23+
indexes=[rr.TimeNanosColumn("video_time", frame_timestamps_ns)],
24+
columns=rr.VideoFrameReference.columns_nanoseconds(frame_timestamps_ns),
2625
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rr.send_columns("skybox", times=[], components=generate_skybox_mesh())
1+
rr.send_columns("skybox", indexes=[], columns=generate_skybox_mesh())

docs/snippets/all/howto/any_batch_value_send_columns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
one_per_timestamp = np.sin(timestamps / 10.0)
1313
ten_per_timestamp = np.cos(np.arange(0, N * 10) / 100.0)
1414

15-
rr.send_columns_v2(
15+
rr.send_columns(
1616
"/",
1717
indexes=[rr.TimeSequenceColumn("step", timestamps)],
1818
columns=[

docs/snippets/all/howto/any_values_send_columns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
timestamps = np.arange(0, 64)
1111

1212
# Log two component columns, named "sin" and "cos", with the corresponding values
13-
rr.send_columns_v2(
13+
rr.send_columns(
1414
"/",
1515
indexes=[rr.TimeSequenceColumn("step", timestamps)],
1616
columns=rr.AnyValues.columns(sin=np.sin(timestamps / 10.0), cos=np.cos(timestamps / 10.0)),

docs/snippets/all/tutorials/data_out.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,15 @@
3232
# log the jaw open state signal as a scalar
3333
rr.send_columns(
3434
"/jaw_open_state",
35-
times=[rr.TimeSequenceColumn("frame_nr", df["frame_nr"])],
36-
components=[
37-
rr.components.ScalarBatch(df["jawOpenState"]),
38-
],
35+
indexes=[rr.TimeSequenceColumn("frame_nr", df["frame_nr"])],
36+
columns=rr.Scalar.columns(scalar=df["jawOpenState"]),
3937
)
4038

4139
# log a `Label` component to the face bounding box entity
4240
target_entity = "/video/detector/faces/0/bbox"
43-
rr.log(target_entity, [rr.components.ShowLabels(True)], static=True)
41+
rr.log(target_entity, rr.Boxes2D.update_fields(show_labels=True), static=True)
4442
rr.send_columns(
4543
target_entity,
46-
times=[rr.TimeSequenceColumn("frame_nr", df["frame_nr"])],
47-
components=[
48-
rr.components.TextBatch(np.where(df["jawOpenState"], "OPEN", "CLOSE")),
49-
],
44+
indexes=[rr.TimeSequenceColumn("frame_nr", df["frame_nr"])],
45+
columns=rr.Boxes2D.columns(labels=np.where(df["jawOpenState"], "OPEN", "CLOSE")),
5046
)

docs/snippets/snippets.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ quick_start = [ # These examples don't have exactly the same implementation.
279279
]
280280
"archetypes/image_send_columns" = [ # This mixes `log` and `send_columns`. Since `log` is suspect to delays by the batcher, this test gets flaky.
281281
"cpp",
282-
"py",
283282
"rust",
284283
]
285284
"archetypes/mesh3d_instancing" = [ # TODO(#3235): Slight floating point differences in deg to rad conversion.

0 commit comments

Comments
 (0)