-
Notifications
You must be signed in to change notification settings - Fork 373
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
Codegen/IDL 6: auto-generated Rust code for Points2D
#2375
Merged
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
6e8ef61
more build tools
teh-cmc c500549
self-review
teh-cmc 65e2d7f
addressing PR comments
teh-cmc 4317ce0
introduce re_types_builder
teh-cmc 98766b9
generate reflection code
teh-cmc c34db31
unindent 0.1 everywhere
teh-cmc 2f6f977
self-review
teh-cmc c3e7e33
adhering to py38+ style guide
teh-cmc 0a31cd1
vscode flatbuffer things. Fix comment typo
Wumpf aa1fac3
turn the inner from_similar into _from_similar to appease linters
teh-cmc 3c34cd1
generate __all__ everywhere to make python tools behave
teh-cmc e0af655
make sure __all__ manifests are lexically sorted
teh-cmc 6c26baf
adressing PR comments
teh-cmc 47509c7
introduce re_types
teh-cmc cf3ae5e
self-review
teh-cmc 83a4a3e
python shall output to rerun_py/rerun_sdk/rerun2
teh-cmc efcb3d7
addressing PR comments
teh-cmc 31bd4ba
Rerun attributes' definitions
teh-cmc 3212e30
Rerun datatypes' definitions
teh-cmc 5a11dfc
Rerun components' definitions
teh-cmc c96edd0
Rerun archetypes' definitions
teh-cmc 62c78ef
fixing typo in re_types_builder doc
teh-cmc 9399435
self-review
teh-cmc 58de8da
fix DrawOrder missing PartialEq & PartialOrd
teh-cmc b359ec4
addressing PR comments
teh-cmc 791f0e9
fixing typo in re_types_builder doc
teh-cmc 3048f38
autogenerated python code
teh-cmc 6346424
freshly autogenerated python code for new py38+ style guide
teh-cmc d638e84
python shall go into rerun_py/rerun_sdk/rerun2
teh-cmc 9a29070
setting up pyproject and runtime redirections apropriately
teh-cmc 09f723b
regen after rebase
teh-cmc 32c386b
regen post rebase
teh-cmc 9f7a593
addressing PR comments
teh-cmc a4fd5ac
force regen this so the PR train makes sense
teh-cmc d42c8e5
fixed wrong indent in python codegen
teh-cmc fe9413f
left a dbg didnt i
teh-cmc 6901e0f
autogenerated rust code
teh-cmc fb43b9c
{Datatype,Component,Archetype}Name
teh-cmc 2c8eac0
regen post rebase
teh-cmc cf5322c
regen hash post rebase
teh-cmc 72b6c47
broke git
teh-cmc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
include "./archetypes/points2d.fbs"; | ||
|
||
namespace rerun.archetypes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# This is a sha256 hash for all direct and indirect dependencies of this crate's build script. | ||
# It can be safely removed at anytime to force the build script to run again. | ||
# Check out build.rs to see how it's computed. | ||
95c13226f31d47e4639e155fc80ee6830579c50e38ee1d997b4bda4d23ba03b6 | ||
2d611d0d686a6314da94b1797472e7690413465d16a611aae3560a847668d53d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
// NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT. | ||
|
||
mod points2d; | ||
|
||
pub use self::points2d::Points2D; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
// NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT. | ||
|
||
/// A 2D point cloud with positions and optional colors, radii, labels, etc. | ||
#[derive(Debug, Clone, PartialEq)] | ||
pub struct Points2D { | ||
/// All the actual 2D points that make up the point cloud. | ||
pub points: Vec<crate::components::Point2D>, | ||
|
||
/// Optional radii for the points, effectively turning them into circles. | ||
pub radii: Option<Vec<crate::components::Radius>>, | ||
|
||
/// Optional colors for the points. | ||
pub colors: Option<Vec<crate::components::Color>>, | ||
|
||
/// Optional text labels for the points. | ||
pub labels: Option<Vec<crate::components::Label>>, | ||
|
||
/// An optional floating point value that specifies the 2D drawing order. | ||
/// Objects with higher values are drawn on top of those with lower values. | ||
/// | ||
/// The default for 2D points is 30.0. | ||
pub draw_order: Option<crate::components::DrawOrder>, | ||
|
||
/// Optional class Ids for the points. | ||
/// | ||
/// The class ID provides colors and labels if not specified explicitly. | ||
pub class_ids: Option<Vec<crate::components::ClassId>>, | ||
|
||
/// Optional keypoint IDs for the points, identifying them within a class. | ||
/// | ||
/// If keypoint IDs are passed in but no class IDs were specified, the class ID will | ||
/// default to 0. | ||
/// This is useful to identify points within a single classification (which is identified | ||
/// with `class_id`). | ||
/// E.g. the classification might be 'Person' and the keypoints refer to joints on a | ||
/// detected skeleton. | ||
pub keypoint_ids: Option<Vec<crate::components::KeypointId>>, | ||
|
||
/// Unique identifiers for each individual point in the batch. | ||
pub instance_keys: Option<Vec<crate::components::InstanceKey>>, | ||
} | ||
|
||
impl Points2D { | ||
pub const REQUIRED_COMPONENTS: [crate::ComponentName; 1] = | ||
[crate::ComponentName::Borrowed("rerun.components.Point2D")]; | ||
|
||
pub const RECOMMENDED_COMPONENTS: [crate::ComponentName; 2] = [ | ||
crate::ComponentName::Borrowed("rerun.components.Radius"), | ||
crate::ComponentName::Borrowed("rerun.components.Color"), | ||
]; | ||
|
||
pub const OPTIONAL_COMPONENTS: [crate::ComponentName; 5] = [ | ||
crate::ComponentName::Borrowed("rerun.components.Label"), | ||
crate::ComponentName::Borrowed("rerun.components.DrawOrder"), | ||
crate::ComponentName::Borrowed("rerun.components.ClassId"), | ||
crate::ComponentName::Borrowed("rerun.components.KeypointId"), | ||
crate::ComponentName::Borrowed("rerun.components.InstanceKey"), | ||
]; | ||
|
||
pub const ALL_COMPONENTS: [crate::ComponentName; 8] = [ | ||
crate::ComponentName::Borrowed("rerun.components.Point2D"), | ||
crate::ComponentName::Borrowed("rerun.components.Radius"), | ||
crate::ComponentName::Borrowed("rerun.components.Color"), | ||
crate::ComponentName::Borrowed("rerun.components.Label"), | ||
crate::ComponentName::Borrowed("rerun.components.DrawOrder"), | ||
crate::ComponentName::Borrowed("rerun.components.ClassId"), | ||
crate::ComponentName::Borrowed("rerun.components.KeypointId"), | ||
crate::ComponentName::Borrowed("rerun.components.InstanceKey"), | ||
]; | ||
} | ||
|
||
impl crate::Archetype for Points2D { | ||
fn name() -> crate::ArchetypeName { | ||
crate::ArchetypeName::Borrowed("rerun.archetypes.Points2D") | ||
} | ||
|
||
fn required_components() -> Vec<crate::ComponentName> { | ||
Self::REQUIRED_COMPONENTS.to_vec() | ||
} | ||
|
||
fn recommended_components() -> Vec<crate::ComponentName> { | ||
Self::RECOMMENDED_COMPONENTS.to_vec() | ||
} | ||
|
||
fn optional_components() -> Vec<crate::ComponentName> { | ||
Self::OPTIONAL_COMPONENTS.to_vec() | ||
} | ||
|
||
#[allow(clippy::unimplemented)] | ||
fn to_arrow_datatypes() -> Vec<arrow2::datatypes::DataType> { | ||
// TODO(#2368): dump the arrow registry into the generated code | ||
unimplemented!("query the registry for all fqnames"); // NOLINT | ||
} | ||
} | ||
|
||
impl Points2D { | ||
pub fn new(points: impl IntoIterator<Item = impl Into<crate::components::Point2D>>) -> Self { | ||
Self { | ||
points: points.into_iter().map(Into::into).collect(), | ||
radii: None, | ||
colors: None, | ||
labels: None, | ||
draw_order: None, | ||
class_ids: None, | ||
keypoint_ids: None, | ||
instance_keys: None, | ||
} | ||
} | ||
|
||
pub fn with_radii( | ||
mut self, | ||
radii: impl IntoIterator<Item = impl Into<crate::components::Radius>>, | ||
) -> Self { | ||
self.radii = Some(radii.into_iter().map(Into::into).collect()); | ||
self | ||
} | ||
|
||
pub fn with_colors( | ||
mut self, | ||
colors: impl IntoIterator<Item = impl Into<crate::components::Color>>, | ||
) -> Self { | ||
self.colors = Some(colors.into_iter().map(Into::into).collect()); | ||
self | ||
} | ||
|
||
pub fn with_labels( | ||
mut self, | ||
labels: impl IntoIterator<Item = impl Into<crate::components::Label>>, | ||
) -> Self { | ||
self.labels = Some(labels.into_iter().map(Into::into).collect()); | ||
self | ||
} | ||
|
||
pub fn with_draw_order(mut self, draw_order: impl Into<crate::components::DrawOrder>) -> Self { | ||
self.draw_order = Some(draw_order.into()); | ||
self | ||
} | ||
|
||
pub fn with_class_ids( | ||
mut self, | ||
class_ids: impl IntoIterator<Item = impl Into<crate::components::ClassId>>, | ||
) -> Self { | ||
self.class_ids = Some(class_ids.into_iter().map(Into::into).collect()); | ||
self | ||
} | ||
|
||
pub fn with_keypoint_ids( | ||
mut self, | ||
keypoint_ids: impl IntoIterator<Item = impl Into<crate::components::KeypointId>>, | ||
) -> Self { | ||
self.keypoint_ids = Some(keypoint_ids.into_iter().map(Into::into).collect()); | ||
self | ||
} | ||
|
||
pub fn with_instance_keys( | ||
mut self, | ||
instance_keys: impl IntoIterator<Item = impl Into<crate::components::InstanceKey>>, | ||
) -> Self { | ||
self.instance_keys = Some(instance_keys.into_iter().map(Into::into).collect()); | ||
self | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT. | ||
|
||
/// A 16-bit ID representing a type of semantic class. | ||
/// | ||
/// Used to look up a `crate::components::ClassDescription` within the `crate::components::AnnotationContext`. | ||
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
pub struct ClassId(pub u16); | ||
|
||
impl crate::Component for ClassId { | ||
fn name() -> crate::ComponentName { | ||
crate::ComponentName::Borrowed("rerun.components.ClassId") | ||
} | ||
|
||
#[allow(clippy::wildcard_imports)] | ||
fn to_arrow_datatype() -> arrow2::datatypes::DataType { | ||
use ::arrow2::datatypes::*; | ||
DataType::UInt16 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT. | ||
|
||
/// An RGBA color tuple with unmultiplied/separate alpha, in sRGB gamma space with linear alpha. | ||
#[derive( | ||
Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, bytemuck::Pod, bytemuck::Zeroable, | ||
)] | ||
#[repr(transparent)] | ||
pub struct Color(pub u32); | ||
|
||
impl crate::Component for Color { | ||
fn name() -> crate::ComponentName { | ||
crate::ComponentName::Borrowed("rerun.components.Color") | ||
} | ||
|
||
#[allow(clippy::wildcard_imports)] | ||
fn to_arrow_datatype() -> arrow2::datatypes::DataType { | ||
use ::arrow2::datatypes::*; | ||
DataType::UInt32 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT. | ||
|
||
/// Draw order used for the display order of 2D elements. | ||
/// | ||
/// Higher values are drawn on top of lower values. | ||
/// An entity can have only a single draw order component. | ||
/// Within an entity draw order is governed by the order of the components. | ||
/// | ||
/// Draw order for entities with the same draw order is generally undefined. | ||
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)] | ||
#[repr(transparent)] | ||
pub struct DrawOrder(pub f32); | ||
|
||
impl crate::Component for DrawOrder { | ||
fn name() -> crate::ComponentName { | ||
crate::ComponentName::Borrowed("rerun.components.DrawOrder") | ||
} | ||
|
||
#[allow(clippy::wildcard_imports)] | ||
fn to_arrow_datatype() -> arrow2::datatypes::DataType { | ||
use ::arrow2::datatypes::*; | ||
DataType::Float32 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT. | ||
|
||
/// A unique numeric identifier for each individual instance within a batch. | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] | ||
pub struct InstanceKey(pub u64); | ||
|
||
impl crate::Component for InstanceKey { | ||
fn name() -> crate::ComponentName { | ||
crate::ComponentName::Borrowed("rerun.components.InstanceKey") | ||
} | ||
|
||
#[allow(clippy::wildcard_imports)] | ||
fn to_arrow_datatype() -> arrow2::datatypes::DataType { | ||
use ::arrow2::datatypes::*; | ||
DataType::UInt64 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT. | ||
|
||
/// A 16-bit ID representing a type of semantic keypoint within a class. | ||
/// | ||
/// `KeypointId`s are only meaningful within the context of a `crate::components::ClassDescription`. | ||
/// | ||
/// Used to look up an `crate::components::AnnotationInfo` for a Keypoint within the `crate::components::AnnotationContext`. | ||
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
pub struct KeypointId(pub u16); | ||
|
||
impl crate::Component for KeypointId { | ||
fn name() -> crate::ComponentName { | ||
crate::ComponentName::Borrowed("rerun.components.KeypointId") | ||
} | ||
|
||
#[allow(clippy::wildcard_imports)] | ||
fn to_arrow_datatype() -> arrow2::datatypes::DataType { | ||
use ::arrow2::datatypes::*; | ||
DataType::UInt16 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT. | ||
|
||
/// A String label component. | ||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] | ||
#[repr(transparent)] | ||
pub struct Label(pub String); | ||
|
||
impl crate::Component for Label { | ||
fn name() -> crate::ComponentName { | ||
crate::ComponentName::Borrowed("rerun.components.Label") | ||
} | ||
|
||
#[allow(clippy::wildcard_imports)] | ||
fn to_arrow_datatype() -> arrow2::datatypes::DataType { | ||
use ::arrow2::datatypes::*; | ||
DataType::Utf8 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,19 @@ | ||
// NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT. | ||
|
||
mod class_id; | ||
mod color; | ||
mod draw_order; | ||
mod instance_key; | ||
mod keypoint_id; | ||
mod label; | ||
mod point2d; | ||
mod radius; | ||
|
||
pub use self::class_id::ClassId; | ||
pub use self::color::Color; | ||
pub use self::draw_order::DrawOrder; | ||
pub use self::instance_key::InstanceKey; | ||
pub use self::keypoint_id::KeypointId; | ||
pub use self::label::Label; | ||
pub use self::point2d::Point2D; | ||
pub use self::radius::Radius; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT. | ||
|
||
/// A point in 2D space. | ||
#[derive(Debug, Default, Clone, Copy, PartialEq, PartialOrd)] | ||
pub struct Point2D(pub crate::datatypes::Vec2D); | ||
|
||
impl crate::Component for Point2D { | ||
fn name() -> crate::ComponentName { | ||
crate::ComponentName::Borrowed("rerun.components.Point2D") | ||
} | ||
|
||
#[allow(clippy::wildcard_imports)] | ||
fn to_arrow_datatype() -> arrow2::datatypes::DataType { | ||
use ::arrow2::datatypes::*; | ||
DataType::FixedSizeList( | ||
Box::new(Field { | ||
name: "item".to_owned(), | ||
data_type: DataType::Float32, | ||
is_nullable: false, | ||
metadata: [].into(), | ||
}), | ||
2, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT. | ||
|
||
/// A Radius component. | ||
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)] | ||
pub struct Radius(pub f32); | ||
|
||
impl crate::Component for Radius { | ||
fn name() -> crate::ComponentName { | ||
crate::ComponentName::Borrowed("rerun.components.Radius") | ||
} | ||
|
||
#[allow(clippy::wildcard_imports)] | ||
fn to_arrow_datatype() -> arrow2::datatypes::DataType { | ||
use ::arrow2::datatypes::*; | ||
DataType::Float32 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
// NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT. | ||
|
||
mod vec2d; | ||
|
||
pub use self::vec2d::Vec2D; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: doc link missing. Another thing where I'm wondering if codegen could help us a lil bit to do the right thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's missing on purpose because I havent ported these objects to HOPE yet! and i didn't want to link back to legacy objects until we actually start backporting.