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

Use arrow1 Fields in Archetype::from_arrow #8595

Merged
merged 9 commits into from
Jan 7, 2025
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
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/project.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Project
about: Define a
about: A large but finite project involving many sub-tasks
title: 'Project: <project title>'
labels: project
assignees: ''
Expand Down
22 changes: 3 additions & 19 deletions crates/store/re_types/tests/types/annotation_context.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
use std::collections::HashMap;

use re_types::{
archetypes::AnnotationContext,
components,
datatypes::{ClassDescription, KeypointPair, Rgba32},
Archetype as _, AsComponents as _,
};

use crate::util;

#[test]
fn roundtrip() {
let expected = components::AnnotationContext::from([
Expand All @@ -22,27 +18,15 @@ fn roundtrip() {

let arch = AnnotationContext::new(expected);

let expected_extensions: HashMap<_, _> =
[("context", vec!["rerun.components.AnnotationContext"])].into();

eprintln!("arch = {arch:#?}");
let serialized = arch.to_arrow2().unwrap();
let serialized = arch.to_arrow().unwrap();
for (field, array) in &serialized {
// NOTE: Keep those around please, very useful when debugging.
// eprintln!("field = {field:#?}");
// eprintln!("array = {array:#?}");
eprintln!("{} = {array:#?}", field.name);

// TODO(cmc): Re-enable extensions and these assertions once `arrow2-convert`
// has been fully replaced.
if false {
util::assert_extensions(
&**array,
expected_extensions[field.name.as_str()].as_slice(),
);
}
eprintln!("{} = {array:#?}", field.name());
}

let deserialized = AnnotationContext::from_arrow2(serialized).unwrap();
let deserialized = AnnotationContext::from_arrow(serialized).unwrap();
similar_asserts::assert_eq!(arch, deserialized);
}
29 changes: 3 additions & 26 deletions crates/store/re_types/tests/types/arrows3d.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
use std::collections::HashMap;

use re_types::{
archetypes::Arrows3D,
components::{ClassId, Color, Position3D, Radius, Vector3D},
datatypes::Vec3D,
Archetype as _, AsComponents as _,
};

use crate::util;

#[test]
fn roundtrip() {
let expected = Arrows3D {
Expand Down Expand Up @@ -48,34 +44,15 @@ fn roundtrip() {
.with_show_labels(true);
similar_asserts::assert_eq!(expected, arch);

let expected_extensions: HashMap<_, _> = [
("arrows", vec!["rerun.components.Arrow3D"]),
("radii", vec!["rerun.components.Radius"]),
("colors", vec!["rerun.components.Color"]),
("labels", vec!["rerun.components.Text"]),
("class_ids", vec!["rerun.components.ClassId"]),
("show_labels", vec!["rerun.components.ShowLabels"]),
]
.into();

eprintln!("arch = {arch:#?}");
let serialized = arch.to_arrow2().unwrap();
let serialized = arch.to_arrow().unwrap();
for (field, array) in &serialized {
// NOTE: Keep those around please, very useful when debugging.
// eprintln!("field = {field:#?}");
// eprintln!("array = {array:#?}");
eprintln!("{} = {array:#?}", field.name);

// TODO(cmc): Re-enable extensions and these assertions once `arrow2-convert`
// has been fully replaced.
if false {
util::assert_extensions(
&**array,
expected_extensions[field.name.as_str()].as_slice(),
);
}
eprintln!("{} = {array:#?}", field.name());
}

let deserialized = Arrows3D::from_arrow2(serialized).unwrap();
let deserialized = Arrows3D::from_arrow(serialized).unwrap();
similar_asserts::assert_eq!(expected, deserialized);
}
17 changes: 3 additions & 14 deletions crates/store/re_types/tests/types/asset3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,15 @@ fn roundtrip() {
.with_albedo_factor(0xEE112233);
similar_asserts::assert_eq!(expected, arch);

// let expected_extensions: HashMap<_, _> = [
// ]
// .into();

eprintln!("arch = {arch:#?}");
let serialized = arch.to_arrow2().unwrap();
let serialized = arch.to_arrow().unwrap();
for (field, array) in &serialized {
// NOTE: Keep those around please, very useful when debugging.
// eprintln!("field = {field:#?}");
// eprintln!("array = {array:#?}");
eprintln!("{} = {array:#?}", field.name);

// TODO(cmc): Re-enable extensions and these assertions once `arrow2-convert`
// has been fully replaced.
// util::assert_extensions(
// &**array,
// expected_extensions[field.name.as_str()].as_slice(),
// );
eprintln!("{} = {array:#?}", field.name());
}

let deserialized = Asset3D::from_arrow2(serialized).unwrap();
let deserialized = Asset3D::from_arrow(serialized).unwrap();
similar_asserts::assert_eq!(expected, deserialized);
}
31 changes: 3 additions & 28 deletions crates/store/re_types/tests/types/box2d.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
use std::collections::HashMap;

use re_types::{archetypes::Boxes2D, components, Archetype as _, AsComponents as _};

use crate::util;

#[test]
fn roundtrip() {
let expected = Boxes2D {
Expand Down Expand Up @@ -45,37 +41,16 @@ fn roundtrip() {
.with_show_labels(true);
similar_asserts::assert_eq!(expected, arch);

let expected_extensions: HashMap<_, _> = [
("half_sizes", vec!["rerun.components.HalfSize2D"]),
("centers", vec!["rerun.components.Position2D"]),
("colors", vec!["rerun.components.Color"]),
("radii", vec!["rerun.components.Radius"]),
("labels", vec!["rerun.components.Label"]),
("draw_order", vec!["rerun.components.DrawOrder"]),
("class_ids", vec!["rerun.components.ClassId"]),
("show_labels", vec!["rerun.components.ShowLabels"]),
]
.into();

eprintln!("arch = {arch:#?}");
let serialized = arch.to_arrow2().unwrap();
let serialized = arch.to_arrow().unwrap();
for (field, array) in &serialized {
// NOTE: Keep those around please, very useful when debugging.
// eprintln!("field = {field:#?}");
// eprintln!("array = {array:#?}");
eprintln!("{} = {array:#?}", field.name);

// TODO(cmc): Re-enable extensions and these assertions once `arrow2-convert`
// has been fully replaced.
if false {
util::assert_extensions(
&**array,
expected_extensions[field.name.as_str()].as_slice(),
);
}
eprintln!("{} = {array:#?}", field.name());
}

let deserialized = Boxes2D::from_arrow2(serialized).unwrap();
let deserialized = Boxes2D::from_arrow(serialized).unwrap();
similar_asserts::assert_eq!(expected, deserialized);
}

Expand Down
32 changes: 3 additions & 29 deletions crates/store/re_types/tests/types/box3d.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
use std::collections::HashMap;

use re_types::{archetypes::Boxes3D, components, datatypes, Archetype as _, AsComponents as _};

use crate::util;

#[test]
fn roundtrip() {
let expected = Boxes3D {
Expand Down Expand Up @@ -58,38 +54,16 @@ fn roundtrip() {
.with_show_labels(false);
similar_asserts::assert_eq!(expected, arch);

let expected_extensions: HashMap<_, _> = [
("half_sizes", vec!["rerun.components.HalfSize2D"]),
("centers", vec!["rerun.components.Position2D"]),
("colors", vec!["rerun.components.Color"]),
("radii", vec!["rerun.components.Radius"]),
("fill_mode", vec!["rerun.components.FillMode"]),
("labels", vec!["rerun.components.Label"]),
("draw_order", vec!["rerun.components.DrawOrder"]),
("class_ids", vec!["rerun.components.ClassId"]),
("show_labels", vec!["rerun.components.ShowLabels"]),
]
.into();

eprintln!("arch = {arch:#?}");
let serialized = arch.to_arrow2().unwrap();
let serialized = arch.to_arrow().unwrap();
for (field, array) in &serialized {
// NOTE: Keep those around please, very useful when debugging.
// eprintln!("field = {field:#?}");
// eprintln!("array = {array:#?}");
eprintln!("{} = {array:#?}", field.name);

// TODO(cmc): Re-enable extensions and these assertions once `arrow2-convert`
// has been fully replaced.
if false {
util::assert_extensions(
&**array,
expected_extensions[field.name.as_str()].as_slice(),
);
}
eprintln!("{} = {array:#?}", field.name());
}

let deserialized = Boxes3D::from_arrow2(serialized).unwrap();
let deserialized = Boxes3D::from_arrow(serialized).unwrap();
similar_asserts::assert_eq!(expected, deserialized);
}

Expand Down
24 changes: 3 additions & 21 deletions crates/store/re_types/tests/types/clear.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
use std::collections::HashMap;

use re_types::{archetypes::Clear, Archetype as _, AsComponents as _};

use crate::util;

#[test]
fn roundtrip() {
let all_expected = [
Expand All @@ -20,33 +16,19 @@ fn roundtrip() {
Clear::flat(), //
];

let expected_extensions: HashMap<_, _> = [
("recursive", vec!["rerun.components.Clear"]), //
]
.into();

for (expected, arch) in all_expected.into_iter().zip(all_arch) {
similar_asserts::assert_eq!(expected, arch);

eprintln!("arch = {arch:#?}");
let serialized = arch.to_arrow2().unwrap();
let serialized = arch.to_arrow().unwrap();
for (field, array) in &serialized {
// NOTE: Keep those around please, very useful when debugging.
// eprintln!("field = {field:#?}");
// eprintln!("array = {array:#?}");
eprintln!("{} = {array:#?}", field.name);

// TODO(cmc): Re-enable extensions and these assertions once `arrow2-convert`
// has been fully replaced.
if false {
util::assert_extensions(
&**array,
expected_extensions[field.name.as_str()].as_slice(),
);
}
eprintln!("{} = {array:#?}", field.name());
}

let deserialized = Clear::from_arrow2(serialized).unwrap();
let deserialized = Clear::from_arrow(serialized).unwrap();
similar_asserts::assert_eq!(expected, deserialized);
}
}
21 changes: 3 additions & 18 deletions crates/store/re_types/tests/types/depth_image.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
use std::collections::HashMap;

use re_types::{
archetypes::DepthImage,
components::DepthMeter,
datatypes::{ChannelDatatype, ImageFormat},
Archetype as _, AsComponents as _,
};

use crate::util;

#[test]
fn depth_image_roundtrip() {
let format_expected = ImageFormat {
Expand All @@ -33,30 +29,19 @@ fn depth_image_roundtrip() {
DepthImage::try_from(ndarray::array![[1u8, 2, 3], [4, 5, 6]])
.unwrap()
.with_meter(1000.0)
.to_arrow2()
.to_arrow()
.unwrap(),
];

let expected_extensions: HashMap<_, _> = [("data", vec!["rerun.components.Blob"])].into();

for (expected, serialized) in all_expected.into_iter().zip(all_arch_serialized) {
for (field, array) in &serialized {
// NOTE: Keep those around please, very useful when debugging.
// eprintln!("field = {field:#?}");
// eprintln!("array = {array:#?}");
eprintln!("{} = {array:#?}", field.name);

// TODO(cmc): Re-enable extensions and these assertions once `arrow2-convert`
// has been fully replaced.
if false {
util::assert_extensions(
&**array,
expected_extensions[field.name.as_str()].as_slice(),
);
}
eprintln!("{} = {array:#?}", field.name());
}

let deserialized = DepthImage::from_arrow2(serialized).unwrap();
let deserialized = DepthImage::from_arrow(serialized).unwrap();
similar_asserts::assert_eq!(expected, deserialized);
}
}
Expand Down
Loading
Loading