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

Python codegen: big cleaning and paving the way towards transforms #2603

Merged
merged 19 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions crates/re_types/definitions/rerun/components/color.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ namespace rerun.components;
/// \py If there is an alpha, we assume it is in linear space, and separate (NOT pre-multiplied).
struct Color (
"attr.arrow.transparent",
"attr.python.aliases": "int, npt.NDArray[np.uint8], npt.NDArray[np.uint32], npt.NDArray[np.float32], npt.NDArray[np.float64]",
"attr.python.array_aliases": "Sequence[int], npt.NDArray[np.uint8], npt.NDArray[np.uint32], npt.NDArray[np.float32], npt.NDArray[np.float64]",
"attr.python.aliases": "int, Sequence[int], npt.NDArray[np.uint8 | np.float32 | np.float64]",
"attr.python.array_aliases": "Sequence[Sequence[int]], npt.NDArray[np.uint8 | np.uint32 | np.float32 | np.float64]",
"attr.rerun.legacy_fqname": "rerun.colorrgba",
"attr.rust.derive": "Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, bytemuck::Pod, bytemuck::Zeroable",
"attr.rust.repr": "transparent",
Expand Down
1 change: 1 addition & 0 deletions crates/re_types/definitions/rerun/components/label.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace rerun.components;
table Label (
"attr.arrow.transparent",
"attr.python.aliases": "str",
"attr.python.array_aliases": "Sequence[str]",
"attr.rerun.legacy_fqname": "rerun.label",
"attr.rust.derive": "Debug, Clone, PartialEq, Eq, PartialOrd, Ord",
"attr.rust.repr": "transparent",
Expand Down
23 changes: 2 additions & 21 deletions crates/re_types/definitions/rerun/components/point2d.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,13 @@ namespace rerun.components;
// ---

/// A point in 2D space.
// TODO(cmc): bring back attr.rust.tuple_struct
struct Point2D (
"attr.python.aliases": "npt.NDArray[np.float32], Sequence[float], Tuple[float, float]",
"attr.python.array_aliases": "npt.NDArray[np.float32], Sequence[float]",
"attr.rerun.legacy_fqname": "rerun.point2d",
"attr.rust.derive": "Debug, Default, Clone, Copy, PartialEq, PartialOrd",
order: 100
) {
x: float (order: 100);
y: float (order: 200);
xy: rerun.datatypes.Point2D (order: 100);
}

// ---

// TODO(cmc): use the following definition instead once we've finalized the switch to HOPE.

// /// A point in 2D space.
// struct Point2D (
// "attr.arrow.transparent",
// "attr.python.aliases": "npt.NDArray[np.float32], Sequence[float], Tuple[float, float]",
// "attr.python.array_aliases": "npt.NDArray[np.float32], Sequence[float]",
// "attr.rust.tuple_struct",
// "attr.rust.derive": "Debug, Default, Clone, Copy, PartialEq, PartialOrd",
// order: 100
// ) {
// position: rerun.datatypes.Vec2D (
// "attr.python.transparent",
// order: 100
// );
// }
2 changes: 2 additions & 0 deletions crates/re_types/definitions/rerun/datatypes.fbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include "./datatypes/point2d.fbs";
include "./datatypes/vec2d.fbs";


abey79 marked this conversation as resolved.
Show resolved Hide resolved
namespace rerun.datatypes;
19 changes: 19 additions & 0 deletions crates/re_types/definitions/rerun/datatypes/point2d.fbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
include "arrow/attributes.fbs";
include "python/attributes.fbs";
include "fbs/attributes.fbs";
include "rust/attributes.fbs";

namespace rerun.datatypes;

// ---

/// A point in 2D space.
struct Point2D (
"attr.python.aliases": "Sequence[float]",
"attr.python.array_aliases": "npt.NDArray[np.float32], Sequence[npt.NDArray[np.float32]], Sequence[tuple[float, float]], Sequence[float]",
"attr.rust.derive": "Debug, Default, Clone, Copy, PartialEq, PartialOrd",
order: 100
) {
x: float (order: 100);
y: float (order: 200);
}
3 changes: 3 additions & 0 deletions crates/re_types/definitions/rerun/datatypes/vec2d.fbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include "arrow/attributes.fbs";
include "python/attributes.fbs";
include "fbs/attributes.fbs";
include "rust/attributes.fbs";

Expand All @@ -9,6 +10,8 @@ namespace rerun.datatypes;
/// A vector in 2D space.
struct Vec2D (
"attr.arrow.transparent",
"attr.python.aliases": "tuple[float, float]",
"attr.python.array_aliases": "npt.NDArray[np.float32], Sequence[tuple[float, float]], Sequence[float]",
"attr.rust.derive": "Debug, Default, Clone, Copy, PartialEq, PartialOrd",
"attr.rust.tuple_struct",
order: 100
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,30 @@ table AffixFuzzer1 (
fuzz1004: rerun.testing.components.AffixFuzzer4 ("attr.rerun.component_required", required, order: 1004);
fuzz1005: rerun.testing.components.AffixFuzzer5 ("attr.rerun.component_required", required, order: 1005);
fuzz1006: rerun.testing.components.AffixFuzzer6 ("attr.rerun.component_required", required, order: 1006);
fuzz1007: rerun.testing.components.AffixFuzzer7 ("attr.rerun.component_required", required, order: 1007);
// fuzz1007: rerun.testing.components.AffixFuzzer7 ("attr.rerun.component_required", required, order: 1007);

fuzz1101: [rerun.testing.components.AffixFuzzer1] ("attr.rerun.component_required", required, order: 1101);
fuzz1102: [rerun.testing.components.AffixFuzzer2] ("attr.rerun.component_required", required, order: 1102);
fuzz1103: [rerun.testing.components.AffixFuzzer3] ("attr.rerun.component_required", required, order: 1103);
fuzz1104: [rerun.testing.components.AffixFuzzer4] ("attr.rerun.component_required", required, order: 1104);
fuzz1105: [rerun.testing.components.AffixFuzzer5] ("attr.rerun.component_required", required, order: 1105);
fuzz1106: [rerun.testing.components.AffixFuzzer6] ("attr.rerun.component_required", required, order: 1106);
fuzz1107: [rerun.testing.components.AffixFuzzer7] ("attr.rerun.component_required", required, order: 1107);
// fuzz1107: [rerun.testing.components.AffixFuzzer7] ("attr.rerun.component_required", required, order: 1107);

fuzz2001: rerun.testing.components.AffixFuzzer1 ("attr.rerun.component_optional", order: 2001);
fuzz2002: rerun.testing.components.AffixFuzzer2 ("attr.rerun.component_optional", order: 2002);
fuzz2003: rerun.testing.components.AffixFuzzer3 ("attr.rerun.component_optional", order: 2003);
fuzz2004: rerun.testing.components.AffixFuzzer4 ("attr.rerun.component_optional", order: 2004);
fuzz2005: rerun.testing.components.AffixFuzzer5 ("attr.rerun.component_optional", order: 2005);
fuzz2006: rerun.testing.components.AffixFuzzer6 ("attr.rerun.component_optional", order: 2006);
fuzz2007: rerun.testing.components.AffixFuzzer7 ("attr.rerun.component_optional", order: 2007);
// fuzz2007: rerun.testing.components.AffixFuzzer7 ("attr.rerun.component_optional", order: 2007);

fuzz2101: [rerun.testing.components.AffixFuzzer1] ("attr.rerun.component_optional", order: 2101);
fuzz2102: [rerun.testing.components.AffixFuzzer2] ("attr.rerun.component_optional", order: 2102);
fuzz2103: [rerun.testing.components.AffixFuzzer3] ("attr.rerun.component_optional", order: 2103);
fuzz2104: [rerun.testing.components.AffixFuzzer4] ("attr.rerun.component_optional", order: 2104);
fuzz2105: [rerun.testing.components.AffixFuzzer5] ("attr.rerun.component_optional", order: 2105);
fuzz2106: [rerun.testing.components.AffixFuzzer6] ("attr.rerun.component_optional", order: 2106);
fuzz2107: [rerun.testing.components.AffixFuzzer7] ("attr.rerun.component_optional", order: 2107);
// fuzz2107: [rerun.testing.components.AffixFuzzer7] ("attr.rerun.component_optional", order: 2107);
}

28 changes: 14 additions & 14 deletions crates/re_types/definitions/rerun/testing/components/fuzzy.fbs
abey79 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ table AffixFuzzer6 (
single_optional: rerun.testing.datatypes.AffixFuzzer1;
}

table AffixFuzzer7 (
"attr.rust.derive": "Debug, Clone, PartialEq",
order: 700
) {
many_optional: [rerun.testing.datatypes.AffixFuzzer1] (order: 100);
single_float_optional: float (order: 101);
single_string_required: string (order: 102, required);
single_string_optional: string (order: 103);
many_floats_optional: [float] (order: 104);
many_strings_required: [string] (order: 105, required);
many_strings_optional: [string] (order: 106);
// TODO(cmc): the ugly bug we need to take care of at some point
// many_transparent_optionals: rerun.testing.datatypes.AffixFuzzer2 (order: 107);
}
// table AffixFuzzer7 (
abey79 marked this conversation as resolved.
Show resolved Hide resolved
// "attr.rust.derive": "Debug, Clone, PartialEq",
// order: 700
// ) {
// many_optional: [rerun.testing.datatypes.AffixFuzzer1] (order: 100);
// single_float_optional: float (order: 101);
// single_string_required: string (order: 102, required);
// single_string_optional: string (order: 103);
// many_floats_optional: [float] (order: 104);
// many_strings_required: [string] (order: 105, required);
// many_strings_optional: [string] (order: 106);
// // TODO(cmc): the ugly bug we need to take care of at some point
// // many_transparent_optionals: rerun.testing.datatypes.AffixFuzzer2 (order: 107);
// }
41 changes: 0 additions & 41 deletions crates/re_types/tests/fuzzy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,40 +66,6 @@ fn roundtrip() {
// // many_strings_optional: None,
// }),
// };
let fuzzy7_1 = re_types::components::AffixFuzzer7 {
many_optional: None,
single_float_optional: None,
single_string_required: "b".into(),
single_string_optional: None,
many_floats_optional: Some(vec![1.0, 10.0]),
many_strings_required: vec!["1".into(), "10".into()],
many_strings_optional: None,
// TODO(cmc): this one is bugged.
// many_transparent_optionals: vec![],
};
let fuzzy7_2 = re_types::components::AffixFuzzer7 {
many_optional: Some(vec![re_types::datatypes::AffixFuzzer1 {
single_float_optional: None,
single_string_required: "d".into(),
single_string_optional: None,
many_floats_optional: Some(vec![4.0, 40.0, 400.0]),
many_strings_required: vec!["7".into(), "8".into()],
many_strings_optional: None,
}]),
single_float_optional: Some(1.0),
single_string_required: "a".into(),
single_string_optional: Some("a".into()),
many_floats_optional: Some(vec![2.0, 20.0, 200.0]),
many_strings_required: vec!["20".into(), "200".into(), "2000".into()],
many_strings_optional: Some(vec![
"30".into(),
"300".into(),
"3000".into(),
"30000".into(),
]),
// TODO(cmc): this one is bugged.
// many_transparent_optionals: vec![],
};

let arch = AffixFuzzer1::new(
fuzzy1.clone(),
Expand All @@ -108,19 +74,16 @@ fn roundtrip() {
fuzzy4.clone(),
fuzzy5.clone(),
fuzzy6.clone(),
fuzzy7_1.clone(),
[fuzzy1.clone(), fuzzy1.clone(), fuzzy1.clone()],
[fuzzy2.clone(), fuzzy2.clone(), fuzzy2.clone()],
[fuzzy3.clone(), fuzzy3.clone(), fuzzy3.clone()],
[fuzzy4.clone(), fuzzy4.clone(), fuzzy4.clone()],
[fuzzy5.clone(), fuzzy5.clone(), fuzzy5.clone()],
[fuzzy6.clone(), fuzzy6.clone(), fuzzy6.clone()],
[fuzzy7_1.clone(), fuzzy7_2.clone()],
)
.with_fuzz2001(fuzzy1.clone())
.with_fuzz2003(fuzzy3.clone())
.with_fuzz2005(fuzzy5.clone())
.with_fuzz2007(fuzzy7_2.clone())
.with_fuzz2102([fuzzy2.clone(), fuzzy2.clone(), fuzzy2.clone()])
.with_fuzz2104([fuzzy4.clone(), fuzzy4.clone(), fuzzy4.clone()])
.with_fuzz2106([fuzzy6.clone(), fuzzy6.clone(), fuzzy6.clone()]);
Expand All @@ -133,31 +96,27 @@ fn roundtrip() {
("fuzz1004", vec!["rerun.testing.components.AffixFuzzer4", "rerun.testing.datatypes.AffixFuzzer1"]),
("fuzz1005", vec!["rerun.testing.components.AffixFuzzer5", "rerun.testing.datatypes.AffixFuzzer1"]),
("fuzz1006", vec!["rerun.testing.components.AffixFuzzer6", "rerun.testing.datatypes.AffixFuzzer1"]),
("fuzz1007", vec!["rerun.testing.components.AffixFuzzer7", "rerun.testing.datatypes.AffixFuzzer1"]),

("fuzz1101", vec!["rerun.testing.components.AffixFuzzer1", "rerun.testing.datatypes.AffixFuzzer1"]),
("fuzz1102", vec!["rerun.testing.components.AffixFuzzer2", "rerun.testing.datatypes.AffixFuzzer1"]),
("fuzz1103", vec!["rerun.testing.components.AffixFuzzer3", "rerun.testing.datatypes.AffixFuzzer1"]),
("fuzz1104", vec!["rerun.testing.components.AffixFuzzer4", "rerun.testing.datatypes.AffixFuzzer1"]),
("fuzz1105", vec!["rerun.testing.components.AffixFuzzer5", "rerun.testing.datatypes.AffixFuzzer1"]),
("fuzz1106", vec!["rerun.testing.components.AffixFuzzer6", "rerun.testing.datatypes.AffixFuzzer1"]),
("fuzz1107", vec!["rerun.testing.components.AffixFuzzer7", "rerun.testing.datatypes.AffixFuzzer1"]),

("fuzz2001", vec!["rerun.testing.components.AffixFuzzer1", "rerun.testing.datatypes.AffixFuzzer1"]),
("fuzz2002", vec!["rerun.testing.components.AffixFuzzer2", "rerun.testing.datatypes.AffixFuzzer1"]),
("fuzz2003", vec!["rerun.testing.components.AffixFuzzer3", "rerun.testing.datatypes.AffixFuzzer1"]),
("fuzz2004", vec!["rerun.testing.components.AffixFuzzer4", "rerun.testing.datatypes.AffixFuzzer1"]),
("fuzz2005", vec!["rerun.testing.components.AffixFuzzer5", "rerun.testing.datatypes.AffixFuzzer1"]),
("fuzz2006", vec!["rerun.testing.components.AffixFuzzer6", "rerun.testing.datatypes.AffixFuzzer1"]),
("fuzz2007", vec!["rerun.testing.components.AffixFuzzer7", "rerun.testing.datatypes.AffixFuzzer1"]),

("fuzz2101", vec!["rerun.testing.components.AffixFuzzer1", "rerun.testing.datatypes.AffixFuzzer1"]),
("fuzz2102", vec!["rerun.testing.components.AffixFuzzer2", "rerun.testing.datatypes.AffixFuzzer1"]),
("fuzz2103", vec!["rerun.testing.components.AffixFuzzer3", "rerun.testing.datatypes.AffixFuzzer1"]),
("fuzz2104", vec!["rerun.testing.components.AffixFuzzer4", "rerun.testing.datatypes.AffixFuzzer1"]),
("fuzz2105", vec!["rerun.testing.components.AffixFuzzer5", "rerun.testing.datatypes.AffixFuzzer1"]),
("fuzz2106", vec!["rerun.testing.components.AffixFuzzer6", "rerun.testing.datatypes.AffixFuzzer1"]),
("fuzz2107", vec!["rerun.testing.components.AffixFuzzer7", "rerun.testing.datatypes.AffixFuzzer1"]),
]
.into();

Expand Down
Loading