Skip to content

Commit

Permalink
Merge branch 'main' into jan/grpc-log-sink
Browse files Browse the repository at this point in the history
  • Loading branch information
jprochazk authored Jan 19, 2025
2 parents e4ef1af + 18ce378 commit 1bd445a
Show file tree
Hide file tree
Showing 71 changed files with 1,928 additions and 2,387 deletions.
4 changes: 2 additions & 2 deletions crates/store/re_data_loader/src/loader_archetype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use re_log_types::{EntityPath, TimeInt, TimePoint};
use re_types::archetypes::{AssetVideo, VideoFrameReference};
use re_types::components::VideoTimestamp;
use re_types::Archetype;
use re_types::{components::MediaType, ComponentBatch};
use re_types::ComponentBatch;

use arrow2::Either;

Expand Down Expand Up @@ -162,7 +162,7 @@ fn load_image(
let mut arch = re_types::archetypes::EncodedImage::from_file_contents(contents);

if let Ok(format) = image::ImageFormat::from_path(filepath) {
arch.media_type = Some(MediaType::from(format.to_mime_type()));
arch = arch.with_media_type(format.to_mime_type());
}

Chunk::builder(entity_path)
Expand Down
21 changes: 17 additions & 4 deletions crates/store/re_entity_db/tests/clear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use re_log_types::{
example_components::{MyColor, MyIndex, MyPoint},
EntityPath, StoreId, TimeInt, TimePoint, Timeline,
};
use re_types::ComponentBatch;
use re_types_core::{archetypes::Clear, components::ClearIsRecursive, AsComponents};

// ---
Expand Down Expand Up @@ -137,7 +138,10 @@ fn clears() -> anyhow::Result<()> {
let (_, _, got_clear) =
query_latest_component::<ClearIsRecursive>(&db, &entity_path_parent, &query)
.unwrap();
similar_asserts::assert_eq!(clear.is_recursive, got_clear);
similar_asserts::assert_eq!(
clear.is_recursive.map(|batch| batch.array),
got_clear.serialized().map(|batch| batch.array)
);

// child1
assert!(query_latest_component::<MyPoint>(&db, &entity_path_child1, &query).is_some());
Expand Down Expand Up @@ -171,7 +175,10 @@ fn clears() -> anyhow::Result<()> {
let (_, _, got_clear) =
query_latest_component::<ClearIsRecursive>(&db, &entity_path_parent, &query)
.unwrap();
similar_asserts::assert_eq!(clear.is_recursive, got_clear);
similar_asserts::assert_eq!(
clear.is_recursive.map(|batch| batch.array),
got_clear.serialized().map(|batch| batch.array)
);

// child1
assert!(query_latest_component::<MyPoint>(&db, &entity_path_child1, &query).is_none());
Expand Down Expand Up @@ -356,7 +363,10 @@ fn clears_respect_index_order() -> anyhow::Result<()> {
// the `Clear` component itself doesn't get cleared!
let (_, _, got_clear) =
query_latest_component::<ClearIsRecursive>(&db, &entity_path, &query).unwrap();
similar_asserts::assert_eq!(clear.is_recursive, got_clear);
similar_asserts::assert_eq!(
clear.is_recursive.map(|batch| batch.array),
got_clear.serialized().map(|batch| batch.array)
);
}

let clear = Clear::recursive();
Expand All @@ -378,7 +388,10 @@ fn clears_respect_index_order() -> anyhow::Result<()> {
// the `Clear` component itself doesn't get cleared!
let (_, _, got_clear) =
query_latest_component::<ClearIsRecursive>(&db, &entity_path, &query).unwrap();
similar_asserts::assert_eq!(clear.is_recursive, got_clear);
similar_asserts::assert_eq!(
clear.is_recursive.map(|batch| batch.array),
got_clear.serialized().map(|batch| batch.array)
);
}

Ok(())
Expand Down
53 changes: 51 additions & 2 deletions crates/store/re_log_types/src/example_components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,66 @@ use std::sync::Arc;

use re_arrow_util::ArrowArrayDowncastRef as _;
use re_byte_size::SizeBytes;
use re_types_core::{Component, ComponentDescriptor, DeserializationError, Loggable};
use re_types_core::{
Component, ComponentDescriptor, DeserializationError, Loggable, SerializedComponentBatch,
};

// ----------------------------------------------------------------------------

#[derive(Debug)]
pub struct MyPoints;
pub struct MyPoints {
pub points: Option<SerializedComponentBatch>,
pub colors: Option<SerializedComponentBatch>,
pub labels: Option<SerializedComponentBatch>,
}

impl MyPoints {
pub const NUM_COMPONENTS: usize = 5;
}

impl MyPoints {
pub fn descriptor_points() -> ComponentDescriptor {
ComponentDescriptor {
archetype_name: Some("example.MyPoints".into()),
archetype_field_name: Some("points".into()),
component_name: MyPoint::name(),
}
}

pub fn descriptor_colors() -> ComponentDescriptor {
ComponentDescriptor {
archetype_name: Some("example.MyPoints".into()),
archetype_field_name: Some("colors".into()),
component_name: MyColor::name(),
}
}

pub fn descriptor_labels() -> ComponentDescriptor {
ComponentDescriptor {
archetype_name: Some("example.MyPoints".into()),
archetype_field_name: Some("labels".into()),
component_name: MyLabel::name(),
}
}

pub fn clear_fields() -> Self {
Self {
points: Some(SerializedComponentBatch::new(
MyPoint::arrow_empty(),
Self::descriptor_points(),
)),
colors: Some(SerializedComponentBatch::new(
MyColor::arrow_empty(),
Self::descriptor_colors(),
)),
labels: Some(SerializedComponentBatch::new(
MyLabel::arrow_empty(),
Self::descriptor_labels(),
)),
}
}
}

impl re_types_core::Archetype for MyPoints {
type Indicator = re_types_core::GenericIndicatorComponent<Self>;

Expand Down
45 changes: 45 additions & 0 deletions crates/store/re_log_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,51 @@ pub fn strip_arrow_extension_types_from_batch(batch: &mut ArrowRecordBatch) {
}
}

// ----------------------------------------------------------------------------

/// Runtime asserts that an archetype has the given components.
///
/// In particular, this is useful to statically check that an archetype
/// has a specific component.
///
/// ```
/// # #[macro_use] extern crate re_log_types;
/// # use re_log_types::example_components::*;
/// debug_assert_archetype_has_components!(MyPoints, colors: MyColor);
/// ```
///
/// This will panic because the type is wrong:
///
/// ```should_panic
/// # #[macro_use] extern crate re_log_types;
/// # use re_log_types::example_components::*;
/// debug_assert_archetype_has_components!(MyPoints, colors: MyPoint);
/// ```
///
/// This will fail to compile because the field is missing:
///
/// ```compile_fail
/// # #[macro_use] extern crate re_log_types;
/// # use re_log_types::example_components::*;
/// debug_assert_archetype_has_components!(MyPoints, colours: MyColor);
/// ```
///
#[macro_export]
macro_rules! debug_assert_archetype_has_components {
($arch:ty, $($field:ident: $field_typ:ty),+ $(,)?) => {
#[cfg(debug_assertions)]
{
use re_log_types::external::re_types_core::{Component as _};
let archetype = <$arch>::clear_fields();
$(
assert_eq!(archetype.$field.map(|batch| batch.descriptor.component_name), Some(<$field_typ>::name()));
)+
}
};
}

// ----------------------------------------------------------------------------

#[cfg(test)]
mod tests {
use super::*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace rerun.archetypes;
/// \example archetypes/annotation_context_segmentation title="Segmentation" image="https://static.rerun.io/annotation_context_segmentation/6c9e88fc9d44a08031cadd444c2e58a985cc1208/1200w.png""
/// \example archetypes/annotation_context_connections !api title="Connections" image="https://static.rerun.io/annotation_context_connections/4a8422bc154699c5334f574ff01b55c5cd1748e3/1200w.png"
table AnnotationContext (
// TODO(#7245): "attr.rust.archetype_eager",
"attr.rust.derive": "Eq, PartialEq",
"attr.docs.view_types": "Spatial2DView, Spatial3DView"
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace rerun.archetypes;
///
/// \example archetypes/arrows2d_simple title="Simple batch of 2D arrows" image="https://static.rerun.io/arrow2d_simple/59f044ccc03f7bc66ee802288f75706618b29a6e/1200w.png"
table Arrows2D (
"attr.rust.archetype_eager",
"attr.rust.derive": "PartialEq",
"attr.rust.new_pub_crate",
"attr.cpp.no_field_ctors",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace rerun.archetypes;
///
/// \example archetypes/arrows3d_simple title="Simple batch of 3D arrows" image="https://static.rerun.io/arrow3d_simple/55e2f794a520bbf7527d7b828b0264732146c5d0/1200w.png"
table Arrows3D (
"attr.rust.archetype_eager",
"attr.rust.derive": "PartialEq",
"attr.rust.new_pub_crate",
"attr.cpp.no_field_ctors",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace rerun.archetypes;
///
/// \example archetypes/asset3d_simple title="Simple 3D asset" image="https://static.rerun.io/asset3d_simple/af238578188d3fd0de3e330212120e2842a8ddb2/1200w.png"
table Asset3D (
// TODO(#7245): "attr.rust.archetype_eager",
"attr.rust.derive": "PartialEq, Eq",
"attr.docs.category": "Spatial 3D",
"attr.docs.view_types": "Spatial3DView, Spatial2DView: if logged above active projection"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace rerun.archetypes;
/// \example archetypes/video_auto_frames title="Video with automatically determined frames" image="https://static.rerun.io/video_manual_frames/320a44e1e06b8b3a3161ecbbeae3e04d1ccb9589/1200w.png"
/// \example archetypes/video_manual_frames title="Demonstrates manual use of video frame references" image="https://static.rerun.io/video_manual_frames/9f41c00f84a98cc3f26875fba7c1d2fa2bad7151/1200w.png"
table AssetVideo (
// TODO(#7245): "attr.rust.archetype_eager",
"attr.docs.category": "Video",
"attr.docs.view_types": "Spatial2DView, Spatial3DView: if logged under a projection"
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace rerun.archetypes;
///
/// \example archetypes/bar_chart title="Simple bar chart" image="https://static.rerun.io/barchart_simple/cf6014b18265edfcaa562c06526c0716b296b193/1200w.png"
table BarChart (
"attr.rust.archetype_eager",
"attr.rust.derive": "PartialEq",
"attr.docs.category": "Plotting",
"attr.docs.view_types": "BarChartView"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace rerun.archetypes;
///
/// \example archetypes/boxes2d_simple title="Simple 2D boxes" image="https://static.rerun.io/box2d_simple/ac4424f3cf747382867649610cbd749c45b2020b/1200w.png"
table Boxes2D (
// TODO(#7245): "attr.rust.archetype_eager",
"attr.rust.derive": "PartialEq",
"attr.rust.new_pub_crate",
"attr.cpp.no_field_ctors",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace rerun.archetypes;
/// \example archetypes/boxes3d_simple !api title="Simple 3D boxes" image="https://static.rerun.io/box3d_simple/d6a3f38d2e3360fbacac52bb43e44762635be9c8/1200w.png"
/// \example archetypes/boxes3d_batch title="Batch of 3D boxes" image="https://static.rerun.io/box3d_batch/5aac5b5d29c9f2ecd572c93f6970fcec17f4984b/1200w.png"
table Boxes3D (
// TODO(#7245): "attr.rust.archetype_eager",
"attr.rust.derive": "PartialEq",
"attr.rust.new_pub_crate",
"attr.cpp.no_field_ctors",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace rerun.archetypes;
// TODO(#1361): This archetype should eventually generalize to cylinders without caps, truncated
// cones, and tapered capsules -- all common shapes based on expanding a line segment circularly.
table Capsules3D (
"attr.rust.archetype_eager",
"attr.rust.derive": "PartialEq",
"attr.rust.new_pub_crate",
"attr.cpp.no_field_ctors",
Expand Down
3 changes: 2 additions & 1 deletion crates/store/re_types/definitions/rerun/archetypes/clear.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ namespace rerun.archetypes;
/// \example archetypes/clear_simple title="Flat" image="https://static.rerun.io/clear_simple/2f5df95fcc53e9f0552f65670aef7f94830c5c1a/1200w.png"
/// \example archetypes/clear_recursive !api "Recursive"
table Clear (
"attr.rust.derive": "PartialEq, Eq",
"attr.rust.archetype_eager",
"attr.rust.derive": "PartialEq",
"attr.rust.override_crate": "re_types_core",
"attr.docs.view_types": "Spatial2DView, Spatial3DView, TimeSeriesView"
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace rerun.archetypes;
/// \example archetypes/depth_image_simple !api title="Simple example" image="https://static.rerun.io/depth_image_simple/77a6fa4f938a742bdc7c5350f668c4f31eed4d01/1200w.png"
/// \example archetypes/depth_image_3d title="Depth to 3D example" image="https://static.rerun.io/depth_image_3d/924e9d4d6a39d63d4fdece82582855fdaa62d15e/1200w.png"
table DepthImage (
"attr.rust.archetype_eager",
"attr.rust.derive": "PartialEq",
"attr.cpp.no_field_ctors",
"attr.docs.category": "Image & tensor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace rerun.archetypes;
///
/// \example archetypes/ellipsoids3d_simple title="Covariance ellipsoid" image="https://static.rerun.io/elliopsoid3d_simple/bd5d46e61b80ae44792b52ee07d750a7137002ea/1200w.png"
table Ellipsoids3D (
"attr.rust.archetype_eager",
"attr.rust.derive": "PartialEq",
"attr.rust.new_pub_crate",
"attr.cpp.no_field_ctors",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace rerun.archetypes;
///
/// \example archetypes/encoded_image
table EncodedImage (
"attr.rust.archetype_eager",
"attr.cpp.no_field_ctors",
"attr.docs.category": "Image & tensor",
"attr.docs.view_types": "Spatial2DView, Spatial3DView: if logged under a projection",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace rerun.archetypes;
///
/// \example archetypes/geo_line_strings_simple title="Log a geospatial line string" image="https://static.rerun.io/geo_line_strings_simple/5669983eb10906ace303755b5b5039cad75b917f/1200w.png"
table GeoLineStrings (
"attr.rust.archetype_eager",
"attr.rust.derive": "PartialEq",
"attr.rust.new_pub_crate",
"attr.docs.category": "Geospatial",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace rerun.archetypes;
///
/// \example archetypes/geo_points_simple title="Log a geospatial point" image="https://static.rerun.io/geopoint_simple/b86ce83e5871837587bd33a0ad639358b96e9010/1200w.png"
table GeoPoints (
"attr.rust.archetype_eager",
"attr.rust.derive": "PartialEq",
"attr.rust.new_pub_crate",
"attr.docs.category": "Geospatial",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ namespace rerun.archetypes;
/// \example archetypes/graph_undirected !api title="Simple undirected graph" image="https://static.rerun.io/graph_undirected/15f46bec77452a8c6220558e4403b99cac188e2e/1200w.png"
/// \example archetypes/graph_directed title="Simple directed graph" image="https://static.rerun.io/graph_directed/ca29a37b65e1e0b6482251dce401982a0bc568fa/1200w.png"
table GraphEdges (
"attr.rust.archetype_eager",
"attr.docs.category": "Graph",
"attr.docs.view_types": "GraphView",
"attr.rust.derive": "PartialEq, Eq"
"attr.rust.derive": "PartialEq"
) {
// --- Required ---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace rerun.archetypes;
/// \example archetypes/graph_undirected !api title="Simple undirected graph" image="https://static.rerun.io/graph_undirected/15f46bec77452a8c6220558e4403b99cac188e2e/1200w.png"
/// \example archetypes/graph_directed title="Simple directed graph" image="https://static.rerun.io/graph_directed/ca29a37b65e1e0b6482251dce401982a0bc568fa/1200w.png"
table GraphNodes (
"attr.rust.archetype_eager",
"attr.docs.category": "Graph",
"attr.docs.view_types": "GraphView",
"attr.rust.derive": "PartialEq"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace rerun.archetypes;
/// \example archetypes/image_formats title="Logging images with various formats" image="https://static.rerun.io/image_formats/7b8a162fcfd266f303980439beea997dc8544c24/full.png"
/// \example archetypes/image_send_columns !api title="Image from file, PIL & OpenCV" image="https://static.rerun.io/image_advanced/81fc8a255488615510790ee41be314e054978d51/full.png"
table Image (
// TODO(#7245): "attr.rust.archetype_eager",
"attr.rust.derive": "PartialEq",
"attr.cpp.no_field_ctors",
"attr.docs.category": "Image & tensor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace rerun.archetypes;
/// \example archetypes/instance_poses3d_combined title="Regular & instance transforms in tandem" image="https://static.rerun.io/leaf_transform3d/41674f0082d6de489f8a1cd1583f60f6b5820ddf/1200w.png"
/// \example archetypes/mesh3d_instancing !api title="3D mesh with instancing" image="https://static.rerun.io/mesh3d_leaf_transforms3d/c2d0ee033129da53168f5705625a9b033f3a3d61/1200w.png"
table InstancePoses3D (
"attr.rust.archetype_eager",
"attr.docs.category": "Spatial 3D",
"attr.docs.view_types": "Spatial3DView, Spatial2DView: if logged above active projection",
"attr.rust.derive": " PartialEq"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace rerun.archetypes;
/// \example archetypes/mesh3d_partial_updates !api title="3D mesh with partial updates" image="https://static.rerun.io/mesh3d_partial_updates/7de33d26220585691a403098c953cd46f94c3262/1200w.png"
/// \example archetypes/mesh3d_instancing title="3D mesh with instancing" image="https://static.rerun.io/mesh3d_leaf_transforms3d/c2d0ee033129da53168f5705625a9b033f3a3d61/1200w.png"
table Mesh3D (
// TODO(#7245): "attr.rust.archetype_eager",
"attr.rust.derive": "PartialEq",
"attr.docs.category": "Spatial 3D",
"attr.docs.view_types": "Spatial3DView, Spatial2DView: if logged above active projection"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace rerun.archetypes;
/// \example archetypes/pinhole_simple title="Simple pinhole camera" image="https://static.rerun.io/pinhole_simple/9af9441a94bcd9fd54e1fea44fb0c59ff381a7f2/1200w.png"
/// \example archetypes/pinhole_perspective title="Perspective pinhole camera" image="https://static.rerun.io/pinhole_perspective/317e2de6d212b238dcdad5b67037e9e2a2afafa0/1200w.png"
table Pinhole (
// TODO(#7245): "attr.rust.archetype_eager"
"attr.rust.derive": "PartialEq",
"attr.docs.category": "Spatial 3D",
"attr.docs.view_types": "Spatial2DView, Spatial2DView"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace rerun.archetypes;
/// \example archetypes/points2d_random title="Randomly distributed 2D points with varying color and radius" image="https://static.rerun.io/point2d_random/8e8ac75373677bd72bd3f56a15e44fcab309a168/1200w.png"
/// \example archetypes/points2d_ui_radius title="Log points with radii given in UI points" image="https://static.rerun.io/point2d_ui_radius/ce804fc77300d89c348b4ab5960395171497b7ac/1200w.png"
table Points2D (
"attr.rust.archetype_eager",
"attr.rust.derive": "PartialEq",
"attr.docs.category": "Spatial 2D",
"attr.docs.view_types": "Spatial2DView, Spatial3DView: if logged under a projection"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace rerun.archetypes;
/// \example archetypes/scalar_multiple_plots !api title="Multiple time series plots" image="https://static.rerun.io/scalar_multiple/15845c2a348f875248fbd694e03eabd922741c4c/1200w.png"
/// \example archetypes/scalar_send_columns !api title="Multiple scalars in a single `send_columns` call" image="https://static.rerun.io/scalar_send_columns/b4bf172256f521f4851dfec5c2c6e3143f5d6923/1200w.png"
table Scalar (
"attr.rust.archetype_eager",
"attr.rust.derive": "PartialEq",
"attr.docs.category": "Plotting",
"attr.docs.view_types": "TimeSeriesView"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace rerun.archetypes;
///
/// \example archetypes/segmentation_image_simple title="Simple segmentation image" image="https://static.rerun.io/segmentation_image_simple/f8aac62abcf4c59c5d62f9ebc2d86fd0285c1736/1200w.png"
table SegmentationImage (
"attr.rust.archetype_eager",
"attr.rust.derive": "PartialEq",
"attr.cpp.no_field_ctors",
"attr.docs.category": "Image & tensor",
Expand Down
Loading

0 comments on commit 1bd445a

Please sign in to comment.