Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static data 4: static-aware Rust SDK #5540

Merged
merged 5 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/re_data_source/src/data_loader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ impl DataLoaderSettings {

if let Some(timepoint) = timepoint {
if timepoint.is_static() {
args.push("--timeless".to_owned());
args.push("--timeless".to_owned()); // for backwards compatibility
args.push("--static".to_owned());
}

for (timeline, time) in timepoint.iter() {
Expand Down
2 changes: 1 addition & 1 deletion crates/re_query_cache/tests/latest_at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn static_query() {
DataRow::from_cells1_sized(RowId::new(), entity_path, timepoint, 2, positions).unwrap();
insert_and_react(&mut store, &mut caches, &row);

// Assign one of them a color with an explicit instance.. statically!
// Assign one of them a color with an explicit instance.. static_!
let color_instances = vec![InstanceKey(1)];
let colors = vec![MyColor::from_rgb(255, 0, 0)];
let row = DataRow::from_cells2_sized(
Expand Down
2 changes: 1 addition & 1 deletion crates/re_query_cache/tests/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ fn static_range() {
.unwrap();
insert_and_react(&mut store, &mut caches, &row);

// Insert statically too!
// Insert static_ too!
let row = DataRow::from_cells2_sized(
RowId::new(),
entity_path.clone(),
Expand Down
82 changes: 52 additions & 30 deletions crates/re_sdk/src/recording_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ impl RecordingStreamBuilder {
/// The WebSocket server will buffer all log data in memory so that late connecting viewers will get all the data.
/// You can limit the amount of data buffered by the WebSocket server with the `server_memory_limit` argument.
/// Once reached, the earliest logged data will be dropped.
/// Note that this means that timeless data may be dropped if logged early.
/// Note that this means that static data may be dropped if logged early (see <https://github.com/rerun-io/rerun/issues/5531>).
///
/// ## Example
///
Expand All @@ -499,6 +499,8 @@ impl RecordingStreamBuilder {
/// true)?;
/// # Ok::<(), Box<dyn std::error::Error>>(())
/// ```
//
// # TODO(#5531): keep static data around.
#[cfg(feature = "web_viewer")]
pub fn serve(
self,
Expand Down Expand Up @@ -860,7 +862,7 @@ impl RecordingStream {
/// or an [`EntityPath`] constructed with [`crate::entity_path`].
/// See <https://www.rerun.io/docs/concepts/entity-path> for more on entity paths.
///
/// See also: [`Self::log_timeless`] for logging timeless data.
/// See also: [`Self::log_static`] for logging static data.
///
/// Internally, the stream will automatically micro-batch multiple log calls to optimize
/// transport.
Expand All @@ -885,16 +887,27 @@ impl RecordingStream {
ent_path: impl Into<EntityPath>,
arch: &impl AsComponents,
) -> RecordingStreamResult<()> {
self.log_with_timeless(ent_path, false, arch)
self.log_with_static(ent_path, false, arch)
}

#[deprecated(since = "0.16.0", note = "use `log_static` instead")]
#[doc(hidden)]
#[inline]
pub fn log_timeless(
&self,
ent_path: impl Into<EntityPath>,
arch: &impl AsComponents,
) -> RecordingStreamResult<()> {
self.log_static(ent_path, arch)
}

/// Log data to Rerun.
///
/// It can be used to log anything
/// that implements the [`AsComponents`], such as any [archetype](https://docs.rs/rerun/latest/rerun/archetypes/index.html).
///
/// Timeless data is present on all timelines and behaves as if it was recorded infinitely far
/// into the past.
/// Static data has no time associated with it, exists on all timelines, and unconditionally shadows
/// any temporal data of the same type.
/// All timestamp data associated with this message will be dropped right before sending it to Rerun.
///
/// This is most often used for [`rerun::ViewCoordinates`](https://docs.rs/rerun/latest/rerun/archetypes/struct.ViewCoordinates.html) and
Expand All @@ -909,20 +922,32 @@ impl RecordingStream {
/// [SDK Micro Batching]: https://www.rerun.io/docs/reference/sdk-micro-batching
/// [component bundle]: [`AsComponents`]
#[inline]
pub fn log_timeless(
pub fn log_static(
&self,
ent_path: impl Into<EntityPath>,
arch: &impl AsComponents,
) -> RecordingStreamResult<()> {
self.log_with_timeless(ent_path, true, arch)
self.log_with_static(ent_path, true, arch)
}

#[deprecated(since = "0.16.0", note = "use `log_static` instead")]
#[doc(hidden)]
#[inline]
pub fn log_with_timeless(
&self,
ent_path: impl Into<EntityPath>,
static_: bool,
arch: &impl AsComponents,
) -> RecordingStreamResult<()> {
self.log_with_static(ent_path, static_, arch)
}

/// Logs the contents of a [component bundle] into Rerun.
///
/// If `timeless` is set to `true`, all timestamp data associated with this message will be
/// If `static_` is set to `true`, all timestamp data associated with this message will be
/// dropped right before sending it to Rerun.
/// Timeless data is present on all timelines and behaves as if it was recorded infinitely far
/// into the past.
/// Static data has no time associated with it, exists on all timelines, and unconditionally shadows
/// any temporal data of the same type.
///
/// Otherwise, the data will be timestamped automatically based on the [`RecordingStream`]'s
/// internal clock.
Expand All @@ -940,17 +965,17 @@ impl RecordingStream {
/// [SDK Micro Batching]: https://www.rerun.io/docs/reference/sdk-micro-batching
/// [component bundle]: [`AsComponents`]
#[inline]
pub fn log_with_timeless(
pub fn log_with_static(
&self,
ent_path: impl Into<EntityPath>,
timeless: bool,
static_: bool,
arch: &impl AsComponents,
) -> RecordingStreamResult<()> {
let row_id = RowId::new(); // Create row-id as early as possible. It has a timestamp and is used to estimate e2e latency.
self.log_component_batches_impl(
row_id,
ent_path,
timeless,
static_,
arch.as_component_batches()
.iter()
.map(|any_comp_batch| any_comp_batch.as_ref()),
Expand All @@ -959,10 +984,10 @@ impl RecordingStream {

/// Logs a set of [`ComponentBatch`]es into Rerun.
///
/// If `timeless` is set to `false`, all timestamp data associated with this message will be
/// If `static_` is set to `true`, all timestamp data associated with this message will be
/// dropped right before sending it to Rerun.
/// Timeless data is present on all timelines and behaves as if it was recorded infinitely far
/// into the past.
/// Static data has no time associated with it, exists on all timelines, and unconditionally shadows
/// any temporal data of the same type.
///
/// Otherwise, the data will be timestamped automatically based on the [`RecordingStream`]'s
/// internal clock.
Expand All @@ -983,18 +1008,18 @@ impl RecordingStream {
pub fn log_component_batches<'a>(
&self,
ent_path: impl Into<EntityPath>,
timeless: bool,
static_: bool,
comp_batches: impl IntoIterator<Item = &'a dyn ComponentBatch>,
) -> RecordingStreamResult<()> {
let row_id = RowId::new(); // Create row-id as early as possible. It has a timestamp and is used to estimate e2e latency.
self.log_component_batches_impl(row_id, ent_path, timeless, comp_batches)
self.log_component_batches_impl(row_id, ent_path, static_, comp_batches)
}

fn log_component_batches_impl<'a>(
&self,
row_id: RowId,
ent_path: impl Into<EntityPath>,
timeless: bool,
static_: bool,
comp_batches: impl IntoIterator<Item = &'a dyn ComponentBatch>,
) -> RecordingStreamResult<()> {
if !self.is_enabled() {
Expand Down Expand Up @@ -1071,13 +1096,13 @@ impl RecordingStream {
};

if let Some(splatted) = splatted {
self.record_row(splatted, !timeless);
self.record_row(splatted, !static_);
}

// Always the primary component last so range-based queries will include the other data.
// Since the primary component can't be splatted it must be in here, see(#1215).
if let Some(instanced) = instanced {
self.record_row(instanced, !timeless);
self.record_row(instanced, !static_);
}

Ok(())
Expand All @@ -1096,9 +1121,9 @@ impl RecordingStream {
&self,
filepath: impl AsRef<std::path::Path>,
entity_path_prefix: Option<EntityPath>,
timeless: bool,
static_: bool,
) -> RecordingStreamResult<()> {
self.log_file(filepath, None, entity_path_prefix, timeless)
self.log_file(filepath, None, entity_path_prefix, static_)
}

/// Logs the given `contents` using all [`re_data_source::DataLoader`]s available.
Expand All @@ -1115,9 +1140,9 @@ impl RecordingStream {
filepath: impl AsRef<std::path::Path>,
contents: std::borrow::Cow<'_, [u8]>,
entity_path_prefix: Option<EntityPath>,
timeless: bool,
static_: bool,
) -> RecordingStreamResult<()> {
self.log_file(filepath, Some(contents), entity_path_prefix, timeless)
self.log_file(filepath, Some(contents), entity_path_prefix, static_)
}

#[cfg(feature = "data_loaders")]
Expand All @@ -1126,7 +1151,7 @@ impl RecordingStream {
filepath: impl AsRef<std::path::Path>,
contents: Option<std::borrow::Cow<'_, [u8]>>,
entity_path_prefix: Option<EntityPath>,
timeless: bool,
static_: bool,
) -> RecordingStreamResult<()> {
let Some(store_info) = self.store_info().clone() else {
re_log::warn!("Ignored call to log_file() because RecordingStream has not been properly initialized");
Expand All @@ -1147,7 +1172,7 @@ impl RecordingStream {
store_id: store_info.store_id,
opened_store_id: None,
entity_path_prefix,
timepoint: (!timeless).then(|| {
timepoint: (!static_).then(|| {
self.with(|inner| {
// Get the current time on all timelines, for the current recording, on the current
// thread…
Expand Down Expand Up @@ -1383,9 +1408,6 @@ impl RecordingStream {
#[inline]
pub fn record_row(&self, mut row: DataRow, inject_time: bool) {
let f = move |inner: &RecordingStreamInner| {
// TODO(#2074): Adding a timeline to something timeless would suddenly make it not
// timeless… so for now it cannot even have a tick :/
//
// NOTE: We're incrementing the current tick still.
let tick = inner
.tick
Expand Down
2 changes: 1 addition & 1 deletion crates/re_types/src/archetypes/annotation_context.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/re_types/src/archetypes/asset3d.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/re_types/src/archetypes/segmentation_image.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions crates/re_types/src/archetypes/series_line.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions crates/re_types/src/archetypes/series_point.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/re_types/src/archetypes/view_coordinates.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/snippets/all/annotation-context/example.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Annotation context with two classes, using two labeled classes, of which ones defines a color.
MsgSender::new("masks") // Applies to all entities below "masks".
.with_timeless(true)
.with_static(true)
.with_component(&[AnnotationContext {
class_map: [
ClassDescription {
Expand Down Expand Up @@ -28,7 +28,7 @@ MsgSender::new("masks") // Applies to all entities below "masks".

// Annotation context with simple keypoints & keypoint connections.
MsgSender::new("detections") // Applies to all entities below "detections".
.with_timeless(true)
.with_static(true)
.with_component(&[AnnotationContext {
class_map: std::iter::once((
ClassId(0),
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/all/annotation_context_connections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Log an annotation context to assign a label and color to each class
// Create a class description with labels and color for each keypoint ID as well as some
// connections between keypoints.
rec.log_timeless(
rec.log_static(
"/",
&rerun::AnnotationContext::new([rerun::ClassDescription {
info: 0.into(),
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/all/annotation_context_rects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
rerun::RecordingStreamBuilder::new("rerun_example_annotation_context_rects").spawn()?;

// Log an annotation context to assign a label and color to each class
rec.log_timeless(
rec.log_static(
"/",
&rerun::AnnotationContext::new([
(1, "red", rerun::Rgba32::from_rgb(255, 0, 0)),
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/all/annotation_context_segmentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.spawn()?;

// create an annotation context to describe the classes
rec.log_timeless(
rec.log_static(
"segmentation",
&rerun::AnnotationContext::new([
(1, "red", rerun::Rgba32::from_rgb(255, 0, 0)),
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/all/asset3d_out_of_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn main() -> anyhow::Result<()> {

let rec = rerun::RecordingStreamBuilder::new("rerun_example_asset3d_out_of_tree").spawn()?;

rec.log_timeless("world", &rerun::ViewCoordinates::RIGHT_HAND_Z_UP)?; // Set an up-axis
rec.log_static("world", &rerun::ViewCoordinates::RIGHT_HAND_Z_UP)?; // Set an up-axis

rec.set_time_sequence("frame", 0);
rec.log("world/asset", &rerun::Asset3D::from_file(path)?)?;
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/all/asset3d_simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn main() -> anyhow::Result<()> {

let rec = rerun::RecordingStreamBuilder::new("rerun_example_asset3d").spawn()?;

rec.log_timeless("world", &rerun::ViewCoordinates::RIGHT_HAND_Z_UP)?; // Set an up-axis
rec.log_static("world", &rerun::ViewCoordinates::RIGHT_HAND_Z_UP)?; // Set an up-axis
rec.log("world/asset", &rerun::Asset3D::from_file(path)?)?;

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/all/log-file/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

let rec = rerun::RecordingStreamBuilder::new("rerun_example_log_file").spawn()?;

rec.log_file_from_path(&args[1], None /* prefix */, true /* timeless */)?;
rec.log_file_from_path(&args[1], None /* prefix */, true /* static */)?;
Loading
Loading