Skip to content

Commit

Permalink
addressing PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Jun 14, 2023
1 parent 5c418d8 commit af2482b
Show file tree
Hide file tree
Showing 19 changed files with 96 additions and 96 deletions.
4 changes: 2 additions & 2 deletions crates/re_types/definitions/arrow/attributes.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ namespace arrow;
/// matter that only impacts (de)serialization.
///
/// Only applies to unions.
attribute "arrow.attr.sparse_union";
attribute "attr.arrow.sparse_union";

/// Marks a single-field object as transparent, affecting its Arrow datatype.
///
/// This does _not_ affect the generated object structure in and of itself, it is a pure Arrow
/// matter that only impacts (de)serialization.
///
/// This is generally most useful for getting rid of extraneous `struct` layers.
attribute "arrow.attr.transparent";
attribute "attr.arrow.transparent";
6 changes: 3 additions & 3 deletions crates/re_types/definitions/python/attributes.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ namespace python.attributes;
/// Marks a field as transparent, meaning its type will be replaced by the underlying type.
///
/// Only applies to fields whose type is an object with a single-field.
attribute "python.attr.transparent";
attribute "attr.python.transparent";

/// Defines the type aliases for a component, e.g. the types that make up `ComponentLike`.
///
/// Only applies to structs/unions that are components.
attribute "python.attr.aliases";
attribute "attr.python.aliases";

/// Defines the array type aliases for a component, e.g. the types that make up `ComponentArrayLike`.
///
/// Only applies to structs/unions that are components.
attribute "python.attr.array_aliases";
attribute "attr.python.array_aliases";
20 changes: 10 additions & 10 deletions crates/re_types/definitions/rerun/archetypes/points2d.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,44 @@ namespace rerun.archetypes;

// TODO(#2371): archetype IDL definitions must always be tables
// TODO(#2372): archetype IDL definitions must refer to objects of kind component
// TODO(#2373): `rerun.attr.component_required` implies `required`
// TODO(#2373): `attr.rerun.component_required` implies `required`

/// A 2D point cloud with positions and optional colors, radii, labels, etc.
table Points2D (
"rust.attr.derive": "Debug, Clone, PartialEq",
"attr.rust.derive": "Debug, Clone, PartialEq",
order: 100
) {
// --- Required ---

/// All the actual 2D points that make up the point cloud.
points: [rerun.components.Point2D] ("rerun.attr.component_required", required, order: 1000);
points: [rerun.components.Point2D] ("attr.rerun.component_required", required, order: 1000);

// --- Recommended ---

/// Optional radii for the points, effectively turning them into circles.
radii: [rerun.components.Radius] ("rerun.attr.component_recommended", order: 2000);
radii: [rerun.components.Radius] ("attr.rerun.component_recommended", order: 2000);

/// Optional colors for the points.
///
/// \python The colors are interpreted as RGB or RGBA in sRGB gamma-space,
/// \python As either 0-1 floats or 0-255 integers, with separate alpha.
colors: [rerun.components.Color] ("rerun.attr.component_recommended", order: 2100);
colors: [rerun.components.Color] ("attr.rerun.component_recommended", order: 2100);

// --- Optional ---

/// Optional text labels for the points.
labels: [rerun.components.Label] ("rerun.attr.component_optional", order: 3000);
labels: [rerun.components.Label] ("attr.rerun.component_optional", order: 3000);

/// 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.
draw_order: rerun.components.DrawOrder ("rerun.attr.component_optional", order: 3100);
draw_order: rerun.components.DrawOrder ("attr.rerun.component_optional", order: 3100);

/// Optional class Ids for the points.
///
/// The class ID provides colors and labels if not specified explicitly.
class_ids: [rerun.components.ClassId] ("rerun.attr.component_optional", order: 3200);
class_ids: [rerun.components.ClassId] ("attr.rerun.component_optional", order: 3200);

/// Optional keypoint IDs for the points, identifying them within a class.
///
Expand All @@ -56,8 +56,8 @@ table Points2D (
/// with `class_id`).
/// E.g. the classification might be 'Person' and the keypoints refer to joints on a
/// detected skeleton.
keypoint_ids: [rerun.components.KeypointId] ("rerun.attr.component_optional", order: 3300);
keypoint_ids: [rerun.components.KeypointId] ("attr.rerun.component_optional", order: 3300);

/// Unique identifiers for each individual point in the batch.
instance_keys: [rerun.components.InstanceKey] ("rerun.attr.component_optional", order: 3400);
instance_keys: [rerun.components.InstanceKey] ("attr.rerun.component_optional", order: 3400);
}
8 changes: 4 additions & 4 deletions crates/re_types/definitions/rerun/attributes.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ namespace rerun.attributes;
/// backend-specific ways.
///
/// Only applies to the fields of an archetype.
attribute "rerun.attr.component_required";
attribute "attr.rerun.component_required";

/// Marks a component as recommended, which is likely to impact the generated code in
/// backend-specific ways.
///
/// Only applies to the fields of an archetype.
attribute "rerun.attr.component_recommended";
attribute "attr.rerun.component_recommended";

/// Marks a component as optional, which is likely to impact the generated code in
/// ways.
/// backend-specific ways.
///
/// Only applies to the fields of an archetype.
attribute "rerun.attr.component_optional";
attribute "attr.rerun.component_optional";
10 changes: 5 additions & 5 deletions crates/re_types/definitions/rerun/components/class_id.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ namespace rerun.components;
///
/// \rs Used to look up a `crate::components::ClassDescription` within the `crate::components::AnnotationContext`.
struct ClassId (
"arrow.attr.transparent",
"python.attr.aliases": "float",
"python.attr.array_aliases": "npt.NDArray[np.uint8], npt.NDArray[np.uint16], npt.NDArray[np.uint32]",
"rust.attr.derive": "Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash",
"rust.attr.tuple_struct",
"attr.arrow.transparent",
"attr.python.aliases": "float",
"attr.python.array_aliases": "npt.NDArray[np.uint8], npt.NDArray[np.uint16], npt.NDArray[np.uint32]",
"attr.rust.derive": "Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash",
"attr.rust.tuple_struct",
order: 100
) {
id: ushort;
Expand Down
12 changes: 6 additions & 6 deletions crates/re_types/definitions/rerun/components/color.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ namespace rerun.components;

/// An RGBA color tuple with unmultiplied/separate alpha, in sRGB gamma space with linear alpha.
struct Color (
"arrow.attr.transparent",
"python.attr.aliases": "Sequence[int], Sequence[float], npt.NDArray[np.uint8], npt.NDArray[np.float32], npt.NDArray[np.float64]",
"python.attr.array_aliases": "Sequence[int], Sequence[float], npt.NDArray[np.uint8], npt.NDArray[np.float32], npt.NDArray[np.float64]",
"rust.attr.derive": "Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, bytemuck::Pod, bytemuck::Zeroable",
"rust.attr.repr": "transparent",
"rust.attr.tuple_struct",
"attr.arrow.transparent",
"attr.python.aliases": "Sequence[int], Sequence[float], npt.NDArray[np.uint8], npt.NDArray[np.float32], npt.NDArray[np.float64]",
"attr.python.array_aliases": "Sequence[int], Sequence[float], npt.NDArray[np.uint8], npt.NDArray[np.float32], npt.NDArray[np.float64]",
"attr.rust.derive": "Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, bytemuck::Pod, bytemuck::Zeroable",
"attr.rust.repr": "transparent",
"attr.rust.tuple_struct",
order: 100
) {
rgba: uint;
Expand Down
12 changes: 6 additions & 6 deletions crates/re_types/definitions/rerun/components/draw_order.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ namespace rerun.components;
///
/// Draw order for entities with the same draw order is generally undefined.
struct DrawOrder (
"arrow.attr.transparent",
"python.attr.aliases": "float",
"python.attr.array_aliases": "npt.NDArray[np.float32]",
"rust.attr.derive": "Debug, Clone, Copy, PartialEq, PartialOrd",
"rust.attr.repr": "transparent",
"rust.attr.tuple_struct",
"attr.arrow.transparent",
"attr.python.aliases": "float",
"attr.python.array_aliases": "npt.NDArray[np.float32]",
"attr.rust.derive": "Debug, Clone, Copy, PartialEq, PartialOrd",
"attr.rust.repr": "transparent",
"attr.rust.tuple_struct",
order: 100
) {
value: float;
Expand Down
10 changes: 5 additions & 5 deletions crates/re_types/definitions/rerun/components/instance_key.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ namespace rerun.components;

/// A unique numeric identifier for each individual instance within a batch.
struct InstanceKey (
"arrow.attr.transparent",
"python.attr.aliases": "int",
"python.attr.array_aliases": "npt.NDArray[np.uint64]",
"rust.attr.tuple_struct",
"rust.attr.derive": "Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord",
"attr.arrow.transparent",
"attr.python.aliases": "int",
"attr.python.array_aliases": "npt.NDArray[np.uint64]",
"attr.rust.tuple_struct",
"attr.rust.derive": "Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord",
order: 100
) {
value: uint64;
Expand Down
10 changes: 5 additions & 5 deletions crates/re_types/definitions/rerun/components/keypoint_id.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ namespace rerun.components;
/// \rs
/// \rs Used to look up an `crate::components::AnnotationInfo` for a Keypoint within the `crate::components::AnnotationContext`.
struct KeypointId (
"arrow.attr.transparent",
"python.attr.aliases": "float",
"python.attr.array_aliases": "npt.NDArray[np.uint8], npt.NDArray[np.uint16], npt.NDArray[np.uint32]",
"rust.attr.derive": "Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash",
"rust.attr.tuple_struct",
"attr.arrow.transparent",
"attr.python.aliases": "float",
"attr.python.array_aliases": "npt.NDArray[np.uint8], npt.NDArray[np.uint16], npt.NDArray[np.uint32]",
"attr.rust.derive": "Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash",
"attr.rust.tuple_struct",
order: 200
) {
id: ushort;
Expand Down
10 changes: 5 additions & 5 deletions crates/re_types/definitions/rerun/components/label.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ namespace rerun.components;

/// A String label component.
table Label (
"arrow.attr.transparent",
"python.attr.aliases": "str",
"rust.attr.derive": "Debug, Clone, PartialEq, Eq, PartialOrd, Ord",
"rust.attr.repr": "transparent",
"rust.attr.tuple_struct",
"attr.arrow.transparent",
"attr.python.aliases": "str",
"attr.rust.derive": "Debug, Clone, PartialEq, Eq, PartialOrd, Ord",
"attr.rust.repr": "transparent",
"attr.rust.tuple_struct",
order: 100
) {
value: string (required, order: 100);
Expand Down
12 changes: 6 additions & 6 deletions crates/re_types/definitions/rerun/components/point2d.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ namespace rerun.components;

/// A point in 2D space.
struct Point2D (
"arrow.attr.transparent",
"python.attr.aliases": "npt.NDArray[np.float32], Sequence[float], Tuple[float, float]",
"python.attr.array_aliases": "npt.NDArray[np.float32], Sequence[float]",
"rust.attr.tuple_struct",
"rust.attr.derive": "Debug, Default, Clone, Copy, PartialEq, PartialOrd",
"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 (
"python.attr.transparent",
"attr.python.transparent",
order: 100
);
}
10 changes: 5 additions & 5 deletions crates/re_types/definitions/rerun/components/radius.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ namespace rerun.components;

/// A Radius component.
struct Radius (
"arrow.attr.transparent",
"python.attr.aliases": "float",
"python.attr.array_aliases": "npt.NDArray[np.float32]",
"rust.attr.tuple_struct",
"rust.attr.derive": "Debug, Clone, Copy, PartialEq, PartialOrd",
"attr.arrow.transparent",
"attr.python.aliases": "float",
"attr.python.array_aliases": "npt.NDArray[np.float32]",
"attr.rust.tuple_struct",
"attr.rust.derive": "Debug, Clone, Copy, PartialEq, PartialOrd",
order: 100
) {
value: float;
Expand Down
6 changes: 3 additions & 3 deletions crates/re_types/definitions/rerun/datatypes/vec2d.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ namespace rerun.datatypes;

/// A vector in 2D space.
struct Vec2D (
"arrow.attr.transparent",
"rust.attr.derive": "Debug, Default, Clone, Copy, PartialEq, PartialOrd",
"rust.attr.tuple_struct",
"attr.arrow.transparent",
"attr.rust.derive": "Debug, Default, Clone, Copy, PartialEq, PartialOrd",
"attr.rust.tuple_struct",
order: 100
) {
xy: [float: 2];
Expand Down
8 changes: 4 additions & 4 deletions crates/re_types/definitions/rust/attributes.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ namespace rust.attributes;
/// Apply to a struct or table object to generate a tuple struct.
///
/// The type definition of the target object must have exactly a single field.
attribute "rust.attr.tuple_struct";
attribute "attr.rust.tuple_struct";

/// Apply to any object to generate a #derive clause.
///
/// The value of the attribute will be trimmed out but otherwise left as-is.
/// E.g. "rust.attr.derive": "Debug, Clone, Copy"`.
attribute "rust.attr.derive";
/// E.g. "attr.rust.derive": "Debug, Clone, Copy"`.
attribute "attr.rust.derive";

/// Apply to any object to generate a #repr clause with the specified value.
attribute "rust.attr.repr";
attribute "attr.rust.repr";
2 changes: 1 addition & 1 deletion crates/re_types/source_hash.txt
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.
dae77f291d1698807cd865265cbb77731bd1aedf07c0968a6b0ac67c18f94590
95c13226f31d47e4639e155fc80ee6830579c50e38ee1d997b4bda4d23ba03b6
6 changes: 3 additions & 3 deletions crates/re_types_builder/src/arrow_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use anyhow::Context as _;
use arrow2::datatypes::{DataType, Field, UnionMode};
use std::collections::{BTreeMap, HashMap};

use crate::{ElementType, Object, Type, ARROW_ATTR_SPARSE_UNION, ARROW_ATTR_TRANSPARENT};
use crate::{ElementType, Object, Type, ATTR_ARROW_SPARSE_UNION, ATTR_ARROW_TRANSPARENT};

// --- Registry ---

Expand Down Expand Up @@ -50,7 +50,7 @@ impl ArrowRegistry {

fn arrow_datatype_from_object(&self, obj: &Object) -> LazyDatatype {
let is_struct = obj.is_struct();
let is_transparent = obj.try_get_attr::<String>(ARROW_ATTR_TRANSPARENT).is_some();
let is_transparent = obj.try_get_attr::<String>(ATTR_ARROW_TRANSPARENT).is_some();
let num_fields = obj.fields.len();

assert!(
Expand Down Expand Up @@ -79,7 +79,7 @@ impl ArrowRegistry {
)
} else {
let is_sparse = obj
.try_get_attr::<String>(ARROW_ATTR_SPARSE_UNION)
.try_get_attr::<String>(ATTR_ARROW_SPARSE_UNION)
.is_some();
LazyDatatype::Extension(
obj.fqname.clone(),
Expand Down
8 changes: 4 additions & 4 deletions crates/re_types_builder/src/codegen/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::{
use crate::{
codegen::{StringExt as _, AUTOGEN_WARNING},
ArrowRegistry, CodeGenerator, Docs, ElementType, Object, ObjectField, ObjectKind, Objects,
Type, PYTHON_ATTR_ALIASES, PYTHON_ATTR_ARRAY_ALIASES, PYTHON_ATTR_TRANSPARENT,
Type, ATTR_PYTHON_ALIASES, ATTR_PYTHON_ARRAY_ALIASES, ATTR_PYTHON_TRANSPARENT,
};

// ---
Expand Down Expand Up @@ -544,9 +544,9 @@ fn quote_str_method_from_obj(objects: &Objects, obj: &Object) -> String {
fn quote_aliases_from_object(obj: &Object) -> String {
assert!(obj.kind != ObjectKind::Archetype);

let aliases = obj.try_get_attr::<String>(PYTHON_ATTR_ALIASES);
let aliases = obj.try_get_attr::<String>(ATTR_PYTHON_ALIASES);
let array_aliases = obj
.try_get_attr::<String>(PYTHON_ATTR_ARRAY_ALIASES)
.try_get_attr::<String>(ATTR_PYTHON_ARRAY_ALIASES)
.unwrap_or_default();

let name = &obj.name;
Expand Down Expand Up @@ -682,7 +682,7 @@ fn quote_field_type_from_field(
// agnostic) in a python specific quoting function... a static helper at the very least
// would be nice.
let is_transparent = field
.try_get_attr::<String>(PYTHON_ATTR_TRANSPARENT)
.try_get_attr::<String>(ATTR_PYTHON_TRANSPARENT)
.is_some();
if is_transparent {
let target = objects.get(fqname);
Expand Down
Loading

0 comments on commit af2482b

Please sign in to comment.