From 01c672a21e4cb2dbaa0d0e157ac26430818a99e3 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Sat, 1 Jul 2023 10:43:08 +0200 Subject: [PATCH 01/14] Implement `log_any` - update python.rs - fix bug in label_ext - added `splat()` helper in InstanceKeyArray - added base class for Archetypes and Components - super basic test --- crates/re_types_builder/src/codegen/python.rs | 69 +++++++++--- rerun_py/rerun_sdk/rerun/__init__.py | 1 + .../rerun/_rerun2/archetypes/_base.py | 8 ++ .../rerun/_rerun2/components/_base.py | 9 ++ .../_rerun2/components/instance_key_ext.py | 14 ++- .../rerun/_rerun2/components/label_ext.py | 4 +- rerun_py/rerun_sdk/rerun/_rerun2/log_any.py | 103 ++++++++++++++++++ rerun_py/tests/unit/test_log.py | 10 ++ 8 files changed, 202 insertions(+), 16 deletions(-) create mode 100644 rerun_py/rerun_sdk/rerun/_rerun2/archetypes/_base.py create mode 100644 rerun_py/rerun_sdk/rerun/_rerun2/components/_base.py create mode 100644 rerun_py/rerun_sdk/rerun/_rerun2/log_any.py create mode 100644 rerun_py/tests/unit/test_log.py diff --git a/crates/re_types_builder/src/codegen/python.rs b/crates/re_types_builder/src/codegen/python.rs index 144570f4d58a..87803dea5db8 100644 --- a/crates/re_types_builder/src/codegen/python.rs +++ b/crates/re_types_builder/src/codegen/python.rs @@ -41,6 +41,7 @@ impl CodeGenerator for PythonCodeGenerator { datatypes_path, arrow_registry, objs, + ObjectKind::Datatype, &objs.ordered_objects(ObjectKind::Datatype.into()), ) .0, @@ -55,6 +56,7 @@ impl CodeGenerator for PythonCodeGenerator { components_path, arrow_registry, objs, + ObjectKind::Component, &objs.ordered_objects(ObjectKind::Component.into()), ) .0, @@ -68,6 +70,7 @@ impl CodeGenerator for PythonCodeGenerator { archetypes_path, arrow_registry, objs, + ObjectKind::Archetype, &objs.ordered_objects(ObjectKind::Archetype.into()), ); filepaths.extend(paths); @@ -117,6 +120,7 @@ fn quote_objects( out_path: impl AsRef, arrow_registry: &ArrowRegistry, all_objects: &Objects, + kind: ObjectKind, objs: &[&Object], ) -> (Vec, Vec) { let out_path = out_path.as_ref(); @@ -176,6 +180,11 @@ fn quote_objects( code.push_text(&format!("# {AUTOGEN_WARNING}"), 2, 0); let manifest = quote_manifest(names); + let base_include = match kind { + ObjectKind::Archetype => "from ._base import Archetype", + ObjectKind::Component => "from ._base import Component", + _ => "", + }; code.push_unindented_text( format!( " @@ -185,9 +194,11 @@ fn quote_objects( import numpy.typing as npt import pyarrow as pa - from dataclasses import dataclass + from dataclasses import dataclass, field from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union + {base_include} + __all__ = [{manifest}] ", @@ -220,14 +231,21 @@ fn quote_objects( let manifest = quote_manifest(mods.iter().flat_map(|(_, names)| names.iter())); + let (base_manifest, base_include) = match kind { + ObjectKind::Archetype => ("\"Archetype\", ", "from ._base import Archetype\n"), + ObjectKind::Component => ("\"Component\", ", "from ._base import Component\n"), + _ => ("", ""), + }; + code.push_text(&format!("# {AUTOGEN_WARNING}"), 2, 0); code.push_unindented_text( format!( " from __future__ import annotations - __all__ = [{manifest}] + __all__ = [{base_manifest}{manifest}] + {base_include} ", ), 0, @@ -275,6 +293,11 @@ impl QuotedObject { let mut code = String::new(); + let superclass = match *kind { + ObjectKind::Archetype => "(Archetype)", + ObjectKind::Component => "(Component)", + _ => "", + }; code.push_unindented_text( format!( r#" @@ -282,7 +305,7 @@ impl QuotedObject { ## --- {name} --- ## @dataclass - class {name}: + class {name}{superclass}: "# ), 0, @@ -317,10 +340,20 @@ impl QuotedObject { } else { typ }; - let typ = if *is_nullable { - format!("{typ} | None = None") + let typ = if *kind == ObjectKind::Archetype { + if !*is_nullable { + format!("{typ} = field(metadata={{'component': 'primary'}})") + } else { + format!( + "{typ} | None = field(default=None, metadata={{'component': 'secondary'}})" + ) + } } else { - typ + if !*is_nullable { + typ + } else { + format!("{typ} | None = None") + } }; code.push_text(format!("{name}: {typ}"), 1, 4); @@ -457,13 +490,13 @@ fn quote_str_repr_from_obj(obj: &Object) -> String { s = f"rr.{type(self).__name__}(\n" from dataclasses import fields - for field in fields(self): - data = getattr(self, field.name) - datatype = getattr(data, "type", None) - if datatype: - name = datatype.extension_name - typ = datatype.storage_type - s += f" {name}<{typ}>(\n {data.to_pylist()}\n )\n" + for fld in fields(self): + if "component" in fld.metadata: + comp: components.Component = getattr(self, fld.name) + if datatype := getattr(comp, "type"): + name = comp.extension_name + typ = datatype.storage_type + s += f" {name}<{typ}>(\n {comp.to_pylist()}\n )\n" s += ")" @@ -754,6 +787,12 @@ fn quote_arrow_support_from_obj(arrow_registry: &ArrowRegistry, obj: &Object) -> .try_get_attr::(ATTR_RERUN_LEGACY_FQNAME) .unwrap_or_else(|| fqname.clone()); + let superclass = if kind == &ObjectKind::Component { + "Component, " + } else { + "" + }; + unindent::unindent(&format!( r#" @@ -784,7 +823,9 @@ fn quote_arrow_support_from_obj(arrow_registry: &ArrowRegistry, obj: &Object) -> # TODO(cmc): bring back registration to pyarrow once legacy types are gone # pa.register_extension_type({arrow}()) - class {many}(pa.ExtensionArray, {many}Ext): # type: ignore[misc] + class {many}({superclass}{many}Ext): # type: ignore[misc] + _extension_name = "{legacy_fqname}" + @staticmethod def from_similar(data: {many_aliases} | None) -> pa.Array: if data is None: diff --git a/rerun_py/rerun_sdk/rerun/__init__.py b/rerun_py/rerun_sdk/rerun/__init__.py index b318cfea0c7b..1f06926ece0b 100644 --- a/rerun_py/rerun_sdk/rerun/__init__.py +++ b/rerun_py/rerun_sdk/rerun/__init__.py @@ -60,6 +60,7 @@ _ENABLE_NEXT_GEN_API = True if _ENABLE_NEXT_GEN_API: from ._rerun2.archetypes import * + from ._rerun2.log_any import log_any def _init_recording_stream() -> None: diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/_base.py b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/_base.py new file mode 100644 index 000000000000..2998990e9c7d --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/_base.py @@ -0,0 +1,8 @@ +from __future__ import annotations + +from dataclasses import dataclass + + +@dataclass +class Archetype: + pass diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/_base.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/_base.py new file mode 100644 index 000000000000..7c8f5a9a6a56 --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/_base.py @@ -0,0 +1,9 @@ +from __future__ import annotations + +import pyarrow as pa + + +class Component(pa.ExtensionArray): # type: ignore[misc] + @property + def extension_name(self) -> str: + return getattr(self, "_extension_name", "") diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key_ext.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key_ext.py index 79a98ffedef3..55fdf14f9981 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key_ext.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key_ext.py @@ -2,11 +2,16 @@ __all__ = ["InstanceKeyArrayExt"] -from typing import Any, Sequence +from typing import TYPE_CHECKING, Any, Sequence import numpy as np import pyarrow as pa +if TYPE_CHECKING: + from .instance_key import InstanceKeyArray + +_MAX_U64 = 2**64 - 1 + class InstanceKeyArrayExt: @staticmethod @@ -19,3 +24,10 @@ def _from_similar( array = np.asarray(data, dtype=np.uint64).flatten() return arrow().wrap_array(pa.array(array, type=arrow().storage_type)) + + @staticmethod + def splat() -> InstanceKeyArray: + from .instance_key import InstanceKeyType + + storage = pa.array([_MAX_U64], type=InstanceKeyType().storage_type) + return storage # type: ignore[no-any-return] diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/label_ext.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/label_ext.py index 5baecff2fed7..1a74aef9bb08 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/label_ext.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/label_ext.py @@ -12,7 +12,9 @@ class LabelArrayExt: def _from_similar( data: Any | None, *, mono: type, mono_aliases: Any, many: type, many_aliases: Any, arrow: type ) -> pa.Array: - if isinstance(data, Sequence): + if isinstance(data, str): + array = [data] + elif isinstance(data, Sequence): array = [str(datum) for datum in data] else: array = [str(data)] diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/log_any.py b/rerun_py/rerun_sdk/rerun/_rerun2/log_any.py new file mode 100644 index 000000000000..5177908e8850 --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/_rerun2/log_any.py @@ -0,0 +1,103 @@ +from __future__ import annotations + +from dataclasses import fields +from typing import Any + +import numpy as np +import numpy.typing as npt +import pyarrow as pa + +from .. import RecordingStream, bindings +from ..log import error_utils +from .archetypes import Archetype +from .components import Component, InstanceKeyArray + +__all__ = ["log_any"] + + +EXT_PREFIX = "ext." + +ext_component_types: dict[str, Any] = {} + + +# adapted from rerun.log._add_extension_components +def _add_extension_components( + instanced: dict[str, Component], + splats: dict[str, Component], + ext: dict[str, Any], + identifiers: npt.NDArray[np.uint64] | None, +) -> None: + global ext_component_types + + for name, value in ext.items(): + # Don't log empty components + if value is None: + continue + + # Add the ext prefix, unless it's already there + if not name.startswith(EXT_PREFIX): + name = EXT_PREFIX + name + + np_type, pa_type = ext_component_types.get(name, (None, None)) + + try: + if np_type is not None: + np_value = np.atleast_1d(np.array(value, copy=False, dtype=np_type)) + pa_value = pa.array(np_value, type=pa_type) + else: + np_value = np.atleast_1d(np.array(value, copy=False)) + pa_value = pa.array(np_value) + ext_component_types[name] = (np_value.dtype, pa_value.type) + except Exception as ex: + error_utils._send_warning( + "Error converting extension data to arrow for component {}. Dropping.\n{}: {}".format( + name, type(ex).__name__, ex + ), + 1, + ) + continue + + is_splat = (len(np_value) == 1) and (len(identifiers or []) != 1) + + if is_splat: + splats[name] = pa_value # noqa + else: + instanced[name] = pa_value # noqa + + +def log_any( + entity_path: str, + entity: Archetype, + ext: dict[str, Any] | None = None, + timeless: bool = False, + recording: RecordingStream | None = None, +) -> None: + from .. import strict_mode + + if strict_mode(): + if not isinstance(entity, Archetype): + raise TypeError(f"Expected Archetype, got {type(entity)}") + + # 0 = instanced, 1 = splat + instanced: dict[str, Component] = {} + splats: dict[str, Component] = {} + + for fld in fields(entity): + if "component" in fld.metadata: + comp: Component = getattr(entity, fld.name) + if fld.metadata["component"] == "primary": + instanced[comp.extension_name] = comp.storage + elif len(comp) == 1: + splats[comp.extension_name] = comp.storage + elif len(comp) > 1: + instanced[comp.extension_name] = comp.storage + + if ext: + _add_extension_components(instanced, splats, ext, None) + + if splats: + splats["rerun.instance_key"] = InstanceKeyArray.splat() + bindings.log_arrow_msg(entity_path, components=splats, timeless=timeless, recording=recording) + + # Always the primary component last so range-based queries will include the other data. See(#1215) + bindings.log_arrow_msg(entity_path, components=instanced, timeless=timeless, recording=recording) diff --git a/rerun_py/tests/unit/test_log.py b/rerun_py/tests/unit/test_log.py new file mode 100644 index 000000000000..b41b833df6ef --- /dev/null +++ b/rerun_py/tests/unit/test_log.py @@ -0,0 +1,10 @@ +from __future__ import annotations + +import rerun as rr + + +def test_log_point2d_basic() -> None: + """Basic test: logging a point shouldn't raise an exception...""" + points = rr.Points2D([(0, 0), (2, 2), (2, 2.5), (2.5, 2), (3, 4)], radii=0.5) + rr.init("test_log") + rr.log_any("points", points) From 8081ab9cf8bcf643876c3a9c61cc2079c0245a0f Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Sat, 1 Jul 2023 10:45:24 +0200 Subject: [PATCH 02/14] Codegen --- crates/re_types/source_hash.txt | 2 +- .../rerun/_rerun2/archetypes/__init__.py | 3 +- .../rerun/_rerun2/archetypes/fuzzy.py | 76 ++++++++++--------- .../rerun/_rerun2/archetypes/points2d.py | 36 ++++----- .../rerun/_rerun2/components/__init__.py | 2 + .../rerun/_rerun2/components/class_id.py | 8 +- .../rerun/_rerun2/components/color.py | 8 +- .../rerun/_rerun2/components/draw_order.py | 8 +- .../rerun/_rerun2/components/fuzzy.py | 44 +++++++---- .../rerun/_rerun2/components/instance_key.py | 8 +- .../rerun/_rerun2/components/keypoint_id.py | 8 +- .../rerun/_rerun2/components/label.py | 8 +- .../rerun/_rerun2/components/point2d.py | 8 +- .../rerun/_rerun2/components/radius.py | 8 +- .../rerun/_rerun2/datatypes/__init__.py | 1 + .../rerun/_rerun2/datatypes/fuzzy.py | 8 +- .../rerun/_rerun2/datatypes/vec2d.py | 4 +- 17 files changed, 151 insertions(+), 89 deletions(-) diff --git a/crates/re_types/source_hash.txt b/crates/re_types/source_hash.txt index 983c45fa1012..bd4ba9f3f5cf 100644 --- a/crates/re_types/source_hash.txt +++ b/crates/re_types/source_hash.txt @@ -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. -128cd542f3f9e6cf3b2a44aeb022cd5f3ad819b00ce5371eeb311300f3e9a7f1 \ No newline at end of file +3e32fbbf9bde3b1e48f6f8d89265d254f51d4b54c969dda46e361ec725f02171 \ No newline at end of file diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/__init__.py b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/__init__.py index b63e459e6d55..adba56934c13 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/__init__.py @@ -2,7 +2,8 @@ from __future__ import annotations -__all__ = ["AffixFuzzer1", "Points2D"] +__all__ = ["Archetype", "AffixFuzzer1", "Points2D"] +from ._base import Archetype from .fuzzy import AffixFuzzer1 from .points2d import Points2D diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py index fcff0b4adb97..bbb01722a1c5 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py @@ -2,7 +2,9 @@ from __future__ import annotations -from dataclasses import dataclass +from dataclasses import dataclass, field + +from ._base import Archetype __all__ = ["AffixFuzzer1"] @@ -12,48 +14,48 @@ @dataclass -class AffixFuzzer1: - fuzz1001: components.AffixFuzzer1Array - fuzz1002: components.AffixFuzzer2Array - fuzz1003: components.AffixFuzzer3Array - fuzz1004: components.AffixFuzzer4Array - fuzz1005: components.AffixFuzzer5Array - fuzz1006: components.AffixFuzzer6Array - fuzz1007: components.AffixFuzzer7Array - fuzz1101: components.AffixFuzzer1Array - fuzz1102: components.AffixFuzzer2Array - fuzz1103: components.AffixFuzzer3Array - fuzz1104: components.AffixFuzzer4Array - fuzz1105: components.AffixFuzzer5Array - fuzz1106: components.AffixFuzzer6Array - fuzz1107: components.AffixFuzzer7Array - fuzz2001: components.AffixFuzzer1Array | None = None - fuzz2002: components.AffixFuzzer2Array | None = None - fuzz2003: components.AffixFuzzer3Array | None = None - fuzz2004: components.AffixFuzzer4Array | None = None - fuzz2005: components.AffixFuzzer5Array | None = None - fuzz2006: components.AffixFuzzer6Array | None = None - fuzz2007: components.AffixFuzzer7Array | None = None - fuzz2101: components.AffixFuzzer1Array | None = None - fuzz2102: components.AffixFuzzer2Array | None = None - fuzz2103: components.AffixFuzzer3Array | None = None - fuzz2104: components.AffixFuzzer4Array | None = None - fuzz2105: components.AffixFuzzer5Array | None = None - fuzz2106: components.AffixFuzzer6Array | None = None - fuzz2107: components.AffixFuzzer7Array | None = None +class AffixFuzzer1(Archetype): + fuzz1001: components.AffixFuzzer1Array = field(metadata={"component": "primary"}) + fuzz1002: components.AffixFuzzer2Array = field(metadata={"component": "primary"}) + fuzz1003: components.AffixFuzzer3Array = field(metadata={"component": "primary"}) + fuzz1004: components.AffixFuzzer4Array = field(metadata={"component": "primary"}) + fuzz1005: components.AffixFuzzer5Array = field(metadata={"component": "primary"}) + fuzz1006: components.AffixFuzzer6Array = field(metadata={"component": "primary"}) + fuzz1007: components.AffixFuzzer7Array = field(metadata={"component": "primary"}) + fuzz1101: components.AffixFuzzer1Array = field(metadata={"component": "primary"}) + fuzz1102: components.AffixFuzzer2Array = field(metadata={"component": "primary"}) + fuzz1103: components.AffixFuzzer3Array = field(metadata={"component": "primary"}) + fuzz1104: components.AffixFuzzer4Array = field(metadata={"component": "primary"}) + fuzz1105: components.AffixFuzzer5Array = field(metadata={"component": "primary"}) + fuzz1106: components.AffixFuzzer6Array = field(metadata={"component": "primary"}) + fuzz1107: components.AffixFuzzer7Array = field(metadata={"component": "primary"}) + fuzz2001: components.AffixFuzzer1Array | None = field(default=None, metadata={"component": "secondary"}) + fuzz2002: components.AffixFuzzer2Array | None = field(default=None, metadata={"component": "secondary"}) + fuzz2003: components.AffixFuzzer3Array | None = field(default=None, metadata={"component": "secondary"}) + fuzz2004: components.AffixFuzzer4Array | None = field(default=None, metadata={"component": "secondary"}) + fuzz2005: components.AffixFuzzer5Array | None = field(default=None, metadata={"component": "secondary"}) + fuzz2006: components.AffixFuzzer6Array | None = field(default=None, metadata={"component": "secondary"}) + fuzz2007: components.AffixFuzzer7Array | None = field(default=None, metadata={"component": "secondary"}) + fuzz2101: components.AffixFuzzer1Array | None = field(default=None, metadata={"component": "secondary"}) + fuzz2102: components.AffixFuzzer2Array | None = field(default=None, metadata={"component": "secondary"}) + fuzz2103: components.AffixFuzzer3Array | None = field(default=None, metadata={"component": "secondary"}) + fuzz2104: components.AffixFuzzer4Array | None = field(default=None, metadata={"component": "secondary"}) + fuzz2105: components.AffixFuzzer5Array | None = field(default=None, metadata={"component": "secondary"}) + fuzz2106: components.AffixFuzzer6Array | None = field(default=None, metadata={"component": "secondary"}) + fuzz2107: components.AffixFuzzer7Array | None = field(default=None, metadata={"component": "secondary"}) def __str__(self) -> str: s = f"rr.{type(self).__name__}(\n" from dataclasses import fields - for field in fields(self): - data = getattr(self, field.name) - datatype = getattr(data, "type", None) - if datatype: - name = datatype.extension_name - typ = datatype.storage_type - s += f" {name}<{typ}>(\n {data.to_pylist()}\n )\n" + for fld in fields(self): + if "component" in fld.metadata: + comp: components.Component = getattr(self, fld.name) + if datatype := getattr(comp, "type"): + name = comp.extension_name + typ = datatype.storage_type + s += f" {name}<{typ}>(\n {comp.to_pylist()}\n )\n" s += ")" diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py index 6fd3d30c8795..a53b0632ebae 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py @@ -2,7 +2,9 @@ from __future__ import annotations -from dataclasses import dataclass +from dataclasses import dataclass, field + +from ._base import Archetype __all__ = ["Points2D"] @@ -12,20 +14,20 @@ @dataclass -class Points2D: +class Points2D(Archetype): """A 2D point cloud with positions and optional colors, radii, labels, etc.""" - points: components.Point2DArray + points: components.Point2DArray = field(metadata={"component": "primary"}) """ All the actual 2D points that make up the point cloud. """ - radii: components.RadiusArray | None = None + radii: components.RadiusArray | None = field(default=None, metadata={"component": "secondary"}) """ Optional radii for the points, effectively turning them into circles. """ - colors: components.ColorArray | None = None + colors: components.ColorArray | None = field(default=None, metadata={"component": "secondary"}) """ Optional colors for the points. @@ -33,12 +35,12 @@ class Points2D: As either 0-1 floats or 0-255 integers, with separate alpha. """ - labels: components.LabelArray | None = None + labels: components.LabelArray | None = field(default=None, metadata={"component": "secondary"}) """ Optional text labels for the points. """ - draw_order: components.DrawOrderArray | None = None + draw_order: components.DrawOrderArray | None = field(default=None, metadata={"component": "secondary"}) """ An optional floating point value that specifies the 2D drawing order. Objects with higher values are drawn on top of those with lower values. @@ -46,14 +48,14 @@ class Points2D: The default for 2D points is 30.0. """ - class_ids: components.ClassIdArray | None = None + class_ids: components.ClassIdArray | None = field(default=None, metadata={"component": "secondary"}) """ Optional class Ids for the points. The class ID provides colors and labels if not specified explicitly. """ - keypoint_ids: components.KeypointIdArray | None = None + keypoint_ids: components.KeypointIdArray | None = field(default=None, metadata={"component": "secondary"}) """ Optional keypoint IDs for the points, identifying them within a class. @@ -65,7 +67,7 @@ class Points2D: detected skeleton. """ - instance_keys: components.InstanceKeyArray | None = None + instance_keys: components.InstanceKeyArray | None = field(default=None, metadata={"component": "secondary"}) """ Unique identifiers for each individual point in the batch. """ @@ -75,13 +77,13 @@ def __str__(self) -> str: from dataclasses import fields - for field in fields(self): - data = getattr(self, field.name) - datatype = getattr(data, "type", None) - if datatype: - name = datatype.extension_name - typ = datatype.storage_type - s += f" {name}<{typ}>(\n {data.to_pylist()}\n )\n" + for fld in fields(self): + if "component" in fld.metadata: + comp: components.Component = getattr(self, fld.name) + if datatype := getattr(comp, "type"): + name = comp.extension_name + typ = datatype.storage_type + s += f" {name}<{typ}>(\n {comp.to_pylist()}\n )\n" s += ")" diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py index 39cab6189458..03e810d8ccf7 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py @@ -3,6 +3,7 @@ from __future__ import annotations __all__ = [ + "Component", "AffixFuzzer1", "AffixFuzzer1Array", "AffixFuzzer1ArrayLike", @@ -80,6 +81,7 @@ "RadiusType", ] +from ._base import Component from .class_id import ClassId, ClassIdArray, ClassIdArrayLike, ClassIdLike, ClassIdType from .color import Color, ColorArray, ColorArrayLike, ColorLike, ColorType from .draw_order import DrawOrder, DrawOrderArray, DrawOrderArrayLike, DrawOrderLike, DrawOrderType diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py index 0cd3d86043c4..384741ade57e 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py @@ -9,6 +9,8 @@ import numpy.typing as npt import pyarrow as pa +from ._base import Component + __all__ = ["ClassId", "ClassIdArray", "ClassIdArrayLike", "ClassIdLike", "ClassIdType"] @@ -16,7 +18,7 @@ @dataclass -class ClassId: +class ClassId(Component): """A 16-bit ID representing a type of semantic class.""" id: int @@ -65,7 +67,9 @@ def __arrow_ext_class__(self: type[pa.ExtensionType]) -> type[pa.ExtensionArray] # pa.register_extension_type(ClassIdType()) -class ClassIdArray(pa.ExtensionArray, ClassIdArrayExt): # type: ignore[misc] +class ClassIdArray(Component, ClassIdArrayExt): # type: ignore[misc] + _extension_name = "rerun.class_id" + @staticmethod def from_similar(data: ClassIdArrayLike | None) -> pa.Array: if data is None: diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py index 327bf8bee058..29eb7d5d2077 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py @@ -9,6 +9,8 @@ import numpy.typing as npt import pyarrow as pa +from ._base import Component + __all__ = ["Color", "ColorArray", "ColorArrayLike", "ColorLike", "ColorType"] @@ -16,7 +18,7 @@ @dataclass -class Color: +class Color(Component): """ An RGBA color tuple with unmultiplied/separate alpha, in sRGB gamma space with linear alpha. @@ -74,7 +76,9 @@ def __arrow_ext_class__(self: type[pa.ExtensionType]) -> type[pa.ExtensionArray] # pa.register_extension_type(ColorType()) -class ColorArray(pa.ExtensionArray, ColorArrayExt): # type: ignore[misc] +class ColorArray(Component, ColorArrayExt): # type: ignore[misc] + _extension_name = "rerun.colorrgba" + @staticmethod def from_similar(data: ColorArrayLike | None) -> pa.Array: if data is None: diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py index b015c66feb4f..11734e5f5011 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py @@ -9,6 +9,8 @@ import numpy.typing as npt import pyarrow as pa +from ._base import Component + __all__ = ["DrawOrder", "DrawOrderArray", "DrawOrderArrayLike", "DrawOrderLike", "DrawOrderType"] @@ -16,7 +18,7 @@ @dataclass -class DrawOrder: +class DrawOrder(Component): """ Draw order used for the display order of 2D elements. @@ -66,7 +68,9 @@ def __arrow_ext_class__(self: type[pa.ExtensionType]) -> type[pa.ExtensionArray] # pa.register_extension_type(DrawOrderType()) -class DrawOrderArray(pa.ExtensionArray, DrawOrderArrayExt): # type: ignore[misc] +class DrawOrderArray(Component, DrawOrderArrayExt): # type: ignore[misc] + _extension_name = "rerun.draw_order" + @staticmethod def from_similar(data: DrawOrderArrayLike | None) -> pa.Array: if data is None: diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py index 905feacc6a6e..f2866f1e64d3 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py @@ -8,6 +8,8 @@ import numpy.typing as npt import pyarrow as pa +from ._base import Component + __all__ = [ "AffixFuzzer1", "AffixFuzzer1Array", @@ -52,7 +54,7 @@ @dataclass -class AffixFuzzer1: +class AffixFuzzer1(Component): single_required: datatypes.AffixFuzzer1 @@ -104,7 +106,9 @@ def __arrow_ext_class__(self: type[pa.ExtensionType]) -> type[pa.ExtensionArray] # pa.register_extension_type(AffixFuzzer1Type()) -class AffixFuzzer1Array(pa.ExtensionArray, AffixFuzzer1ArrayExt): # type: ignore[misc] +class AffixFuzzer1Array(Component, AffixFuzzer1ArrayExt): # type: ignore[misc] + _extension_name = "rerun.testing.components.AffixFuzzer1" + @staticmethod def from_similar(data: AffixFuzzer1ArrayLike | None) -> pa.Array: if data is None: @@ -124,7 +128,7 @@ def from_similar(data: AffixFuzzer1ArrayLike | None) -> pa.Array: @dataclass -class AffixFuzzer2: +class AffixFuzzer2(Component): single_required: datatypes.AffixFuzzer1 @@ -176,7 +180,9 @@ def __arrow_ext_class__(self: type[pa.ExtensionType]) -> type[pa.ExtensionArray] # pa.register_extension_type(AffixFuzzer2Type()) -class AffixFuzzer2Array(pa.ExtensionArray, AffixFuzzer2ArrayExt): # type: ignore[misc] +class AffixFuzzer2Array(Component, AffixFuzzer2ArrayExt): # type: ignore[misc] + _extension_name = "rerun.testing.components.AffixFuzzer2" + @staticmethod def from_similar(data: AffixFuzzer2ArrayLike | None) -> pa.Array: if data is None: @@ -196,7 +202,7 @@ def from_similar(data: AffixFuzzer2ArrayLike | None) -> pa.Array: @dataclass -class AffixFuzzer3: +class AffixFuzzer3(Component): single_required: datatypes.AffixFuzzer1 @@ -263,7 +269,9 @@ def __arrow_ext_class__(self: type[pa.ExtensionType]) -> type[pa.ExtensionArray] # pa.register_extension_type(AffixFuzzer3Type()) -class AffixFuzzer3Array(pa.ExtensionArray, AffixFuzzer3ArrayExt): # type: ignore[misc] +class AffixFuzzer3Array(Component, AffixFuzzer3ArrayExt): # type: ignore[misc] + _extension_name = "rerun.testing.components.AffixFuzzer3" + @staticmethod def from_similar(data: AffixFuzzer3ArrayLike | None) -> pa.Array: if data is None: @@ -283,7 +291,7 @@ def from_similar(data: AffixFuzzer3ArrayLike | None) -> pa.Array: @dataclass -class AffixFuzzer4: +class AffixFuzzer4(Component): single_optional: datatypes.AffixFuzzer1 | None = None @@ -335,7 +343,9 @@ def __arrow_ext_class__(self: type[pa.ExtensionType]) -> type[pa.ExtensionArray] # pa.register_extension_type(AffixFuzzer4Type()) -class AffixFuzzer4Array(pa.ExtensionArray, AffixFuzzer4ArrayExt): # type: ignore[misc] +class AffixFuzzer4Array(Component, AffixFuzzer4ArrayExt): # type: ignore[misc] + _extension_name = "rerun.testing.components.AffixFuzzer4" + @staticmethod def from_similar(data: AffixFuzzer4ArrayLike | None) -> pa.Array: if data is None: @@ -355,7 +365,7 @@ def from_similar(data: AffixFuzzer4ArrayLike | None) -> pa.Array: @dataclass -class AffixFuzzer5: +class AffixFuzzer5(Component): single_optional: datatypes.AffixFuzzer1 | None = None @@ -407,7 +417,9 @@ def __arrow_ext_class__(self: type[pa.ExtensionType]) -> type[pa.ExtensionArray] # pa.register_extension_type(AffixFuzzer5Type()) -class AffixFuzzer5Array(pa.ExtensionArray, AffixFuzzer5ArrayExt): # type: ignore[misc] +class AffixFuzzer5Array(Component, AffixFuzzer5ArrayExt): # type: ignore[misc] + _extension_name = "rerun.testing.components.AffixFuzzer5" + @staticmethod def from_similar(data: AffixFuzzer5ArrayLike | None) -> pa.Array: if data is None: @@ -427,7 +439,7 @@ def from_similar(data: AffixFuzzer5ArrayLike | None) -> pa.Array: @dataclass -class AffixFuzzer6: +class AffixFuzzer6(Component): single_optional: datatypes.AffixFuzzer1 | None = None @@ -494,7 +506,9 @@ def __arrow_ext_class__(self: type[pa.ExtensionType]) -> type[pa.ExtensionArray] # pa.register_extension_type(AffixFuzzer6Type()) -class AffixFuzzer6Array(pa.ExtensionArray, AffixFuzzer6ArrayExt): # type: ignore[misc] +class AffixFuzzer6Array(Component, AffixFuzzer6ArrayExt): # type: ignore[misc] + _extension_name = "rerun.testing.components.AffixFuzzer6" + @staticmethod def from_similar(data: AffixFuzzer6ArrayLike | None) -> pa.Array: if data is None: @@ -514,7 +528,7 @@ def from_similar(data: AffixFuzzer6ArrayLike | None) -> pa.Array: @dataclass -class AffixFuzzer7: +class AffixFuzzer7(Component): single_string_required: str many_strings_required: npt.ArrayLike many_optional: list[datatypes.AffixFuzzer1] | None = None @@ -609,7 +623,9 @@ def __arrow_ext_class__(self: type[pa.ExtensionType]) -> type[pa.ExtensionArray] # pa.register_extension_type(AffixFuzzer7Type()) -class AffixFuzzer7Array(pa.ExtensionArray, AffixFuzzer7ArrayExt): # type: ignore[misc] +class AffixFuzzer7Array(Component, AffixFuzzer7ArrayExt): # type: ignore[misc] + _extension_name = "rerun.testing.components.AffixFuzzer7" + @staticmethod def from_similar(data: AffixFuzzer7ArrayLike | None) -> pa.Array: if data is None: diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py index 01b825e7beb5..e6fe20fcf324 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py @@ -9,6 +9,8 @@ import numpy.typing as npt import pyarrow as pa +from ._base import Component + __all__ = ["InstanceKey", "InstanceKeyArray", "InstanceKeyArrayLike", "InstanceKeyLike", "InstanceKeyType"] @@ -16,7 +18,7 @@ @dataclass -class InstanceKey: +class InstanceKey(Component): """A unique numeric identifier for each individual instance within a batch.""" value: int @@ -58,7 +60,9 @@ def __arrow_ext_class__(self: type[pa.ExtensionType]) -> type[pa.ExtensionArray] # pa.register_extension_type(InstanceKeyType()) -class InstanceKeyArray(pa.ExtensionArray, InstanceKeyArrayExt): # type: ignore[misc] +class InstanceKeyArray(Component, InstanceKeyArrayExt): # type: ignore[misc] + _extension_name = "rerun.instance_key" + @staticmethod def from_similar(data: InstanceKeyArrayLike | None) -> pa.Array: if data is None: diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py index 38f9b3ddbac1..f3c4f20a7c41 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py @@ -9,6 +9,8 @@ import numpy.typing as npt import pyarrow as pa +from ._base import Component + __all__ = ["KeypointId", "KeypointIdArray", "KeypointIdArrayLike", "KeypointIdLike", "KeypointIdType"] @@ -16,7 +18,7 @@ @dataclass -class KeypointId: +class KeypointId(Component): """ A 16-bit ID representing a type of semantic keypoint within a class. @@ -67,7 +69,9 @@ def __arrow_ext_class__(self: type[pa.ExtensionType]) -> type[pa.ExtensionArray] # pa.register_extension_type(KeypointIdType()) -class KeypointIdArray(pa.ExtensionArray, KeypointIdArrayExt): # type: ignore[misc] +class KeypointIdArray(Component, KeypointIdArrayExt): # type: ignore[misc] + _extension_name = "rerun.keypoint_id" + @staticmethod def from_similar(data: KeypointIdArrayLike | None) -> pa.Array: if data is None: diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py index 5af6ea0c614b..8a7f399569e5 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py @@ -7,6 +7,8 @@ import pyarrow as pa +from ._base import Component + __all__ = ["Label", "LabelArray", "LabelArrayLike", "LabelLike", "LabelType"] @@ -14,7 +16,7 @@ @dataclass -class Label: +class Label(Component): """A String label component.""" value: str @@ -59,7 +61,9 @@ def __arrow_ext_class__(self: type[pa.ExtensionType]) -> type[pa.ExtensionArray] # pa.register_extension_type(LabelType()) -class LabelArray(pa.ExtensionArray, LabelArrayExt): # type: ignore[misc] +class LabelArray(Component, LabelArrayExt): # type: ignore[misc] + _extension_name = "rerun.label" + @staticmethod def from_similar(data: LabelArrayLike | None) -> pa.Array: if data is None: diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py index a7d5aaac503e..0134ea0af801 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py @@ -9,6 +9,8 @@ import numpy.typing as npt import pyarrow as pa +from ._base import Component + __all__ = ["Point2D", "Point2DArray", "Point2DArrayLike", "Point2DLike", "Point2DType"] @@ -16,7 +18,7 @@ @dataclass -class Point2D: +class Point2D(Component): """A point in 2D space.""" x: float @@ -60,7 +62,9 @@ def __arrow_ext_class__(self: type[pa.ExtensionType]) -> type[pa.ExtensionArray] # pa.register_extension_type(Point2DType()) -class Point2DArray(pa.ExtensionArray, Point2DArrayExt): # type: ignore[misc] +class Point2DArray(Component, Point2DArrayExt): # type: ignore[misc] + _extension_name = "rerun.point2d" + @staticmethod def from_similar(data: Point2DArrayLike | None) -> pa.Array: if data is None: diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py index ec81b9eeffe9..2329419dc64d 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py @@ -9,6 +9,8 @@ import numpy.typing as npt import pyarrow as pa +from ._base import Component + __all__ = ["Radius", "RadiusArray", "RadiusArrayLike", "RadiusLike", "RadiusType"] @@ -16,7 +18,7 @@ @dataclass -class Radius: +class Radius(Component): """A Radius component.""" value: float @@ -58,7 +60,9 @@ def __arrow_ext_class__(self: type[pa.ExtensionType]) -> type[pa.ExtensionArray] # pa.register_extension_type(RadiusType()) -class RadiusArray(pa.ExtensionArray, RadiusArrayExt): # type: ignore[misc] +class RadiusArray(Component, RadiusArrayExt): # type: ignore[misc] + _extension_name = "rerun.radius" + @staticmethod def from_similar(data: RadiusArrayLike | None) -> pa.Array: if data is None: diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/__init__.py b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/__init__.py index 9519be379256..cec81dfa19cf 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/__init__.py @@ -20,6 +20,7 @@ "Vec2DType", ] + from .fuzzy import ( AffixFuzzer1, AffixFuzzer1Array, diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py index 76d2ee4da208..f095027ea27e 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py @@ -84,7 +84,9 @@ def __arrow_ext_class__(self: type[pa.ExtensionType]) -> type[pa.ExtensionArray] # pa.register_extension_type(AffixFuzzer1Type()) -class AffixFuzzer1Array(pa.ExtensionArray, AffixFuzzer1ArrayExt): # type: ignore[misc] +class AffixFuzzer1Array(AffixFuzzer1ArrayExt): # type: ignore[misc] + _extension_name = "rerun.testing.datatypes.AffixFuzzer1" + @staticmethod def from_similar(data: AffixFuzzer1ArrayLike | None) -> pa.Array: if data is None: @@ -146,7 +148,9 @@ def __arrow_ext_class__(self: type[pa.ExtensionType]) -> type[pa.ExtensionArray] # pa.register_extension_type(AffixFuzzer2Type()) -class AffixFuzzer2Array(pa.ExtensionArray, AffixFuzzer2ArrayExt): # type: ignore[misc] +class AffixFuzzer2Array(AffixFuzzer2ArrayExt): # type: ignore[misc] + _extension_name = "rerun.testing.datatypes.AffixFuzzer2" + @staticmethod def from_similar(data: AffixFuzzer2ArrayLike | None) -> pa.Array: if data is None: diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/vec2d.py b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/vec2d.py index 2efcf56fbcf2..14aa1d0a2a1c 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/vec2d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/vec2d.py @@ -60,7 +60,9 @@ def __arrow_ext_class__(self: type[pa.ExtensionType]) -> type[pa.ExtensionArray] # pa.register_extension_type(Vec2DType()) -class Vec2DArray(pa.ExtensionArray, Vec2DArrayExt): # type: ignore[misc] +class Vec2DArray(Vec2DArrayExt): # type: ignore[misc] + _extension_name = "rerun.datatypes.Vec2D" + @staticmethod def from_similar(data: Vec2DArrayLike | None) -> pa.Array: if data is None: From 869456a18ca0c968438127e17bd682a173442733 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Sat, 1 Jul 2023 10:46:01 +0200 Subject: [PATCH 03/14] Updated api_demo to use `rr.log_any()` --- examples/python/api_demo/main.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/examples/python/api_demo/main.py b/examples/python/api_demo/main.py index 6fa22c021ef2..ba272e783e24 100755 --- a/examples/python/api_demo/main.py +++ b/examples/python/api_demo/main.py @@ -33,18 +33,20 @@ def run_segmentation() -> None: rr.log_segmentation_image("seg_demo/img", segmentation_img) # Log a bunch of classified 2D points - rr.log_point("seg_demo/single_point", np.array([64, 64]), class_id=13) - rr.log_point("seg_demo/single_point_labeled", np.array([90, 50]), class_id=13, label="labeled point") - rr.log_points("seg_demo/several_points0", np.array([[20, 50], [100, 70], [60, 30]]), class_ids=42) - rr.log_points( + # Note: this uses the new, WIP object-oriented API + rr.log_any("seg_demo/single_point", rr.Points2D(np.array([64, 64]), class_ids=13)) + rr.log_any("seg_demo/single_point_labeled", rr.Points2D(np.array([90, 50]), class_ids=13, labels="labeled point")) + rr.log_any("seg_demo/several_points0", rr.Points2D(np.array([[20, 50], [100, 70], [60, 30]]), class_ids=42)) + rr.log_any( "seg_demo/several_points1", - np.array([[40, 50], [120, 70], [80, 30]]), - class_ids=np.array([13, 42, 99], dtype=np.uint8), + rr.Points2D(np.array([[40, 50], [120, 70], [80, 30]]), class_ids=np.array([13, 42, 99], dtype=np.uint8)), ) - rr.log_points( + rr.log_any( "seg_demo/many points", - np.array([[100 + (int(i / 5)) * 2, 100 + (i % 5) * 2] for i in range(25)]), - class_ids=np.array([42], dtype=np.uint8), + rr.Points2D( + np.array([[100 + (int(i / 5)) * 2, 100 + (i % 5) * 2] for i in range(25)]), + class_ids=np.array([42], dtype=np.uint8), + ), ) rr.log_text_entry("logs/seg_demo_log", "default colored rects, default colored points, a single point has a label") From 57912e8feecf0a87f834ea5b6d609a0533d07724 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Sat, 1 Jul 2023 10:52:37 +0200 Subject: [PATCH 04/14] Fix rs lint --- crates/re_types_builder/src/codegen/python.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/crates/re_types_builder/src/codegen/python.rs b/crates/re_types_builder/src/codegen/python.rs index 87803dea5db8..46a5744732ff 100644 --- a/crates/re_types_builder/src/codegen/python.rs +++ b/crates/re_types_builder/src/codegen/python.rs @@ -183,7 +183,7 @@ fn quote_objects( let base_include = match kind { ObjectKind::Archetype => "from ._base import Archetype", ObjectKind::Component => "from ._base import Component", - _ => "", + ObjectKind::Datatype => "", }; code.push_unindented_text( format!( @@ -234,7 +234,7 @@ fn quote_objects( let (base_manifest, base_include) = match kind { ObjectKind::Archetype => ("\"Archetype\", ", "from ._base import Archetype\n"), ObjectKind::Component => ("\"Component\", ", "from ._base import Component\n"), - _ => ("", ""), + ObjectKind::Datatype => ("", ""), }; code.push_text(&format!("# {AUTOGEN_WARNING}"), 2, 0); @@ -296,7 +296,7 @@ impl QuotedObject { let superclass = match *kind { ObjectKind::Archetype => "(Archetype)", ObjectKind::Component => "(Component)", - _ => "", + ObjectKind::Datatype => "", }; code.push_unindented_text( format!( @@ -348,12 +348,10 @@ impl QuotedObject { "{typ} | None = field(default=None, metadata={{'component': 'secondary'}})" ) } + } else if !*is_nullable { + typ } else { - if !*is_nullable { - typ - } else { - format!("{typ} | None = None") - } + format!("{typ} | None = None") }; code.push_text(format!("{name}: {typ}"), 1, 4); From e11aca7fc13bce59e44d6df899801eef75eee53d Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Sat, 1 Jul 2023 10:52:47 +0200 Subject: [PATCH 05/14] Codegen --- crates/re_types/source_hash.txt | 2 +- rerun_py/rerun_sdk/rerun/_rerun2/__init__.py | 2 +- .../rerun/_rerun2/archetypes/__init__.py | 3 +- .../rerun/_rerun2/archetypes/fuzzy.py | 5 +++ .../rerun/_rerun2/archetypes/points2d.py | 9 +++++- .../rerun/_rerun2/components/__init__.py | 31 ++++++++++--------- .../rerun/_rerun2/components/class_id.py | 10 +++--- .../rerun/_rerun2/components/color.py | 6 ++-- .../rerun/_rerun2/components/draw_order.py | 6 ++-- .../rerun/_rerun2/components/fuzzy.py | 7 +++-- .../rerun/_rerun2/components/instance_key.py | 10 +++--- .../rerun/_rerun2/components/keypoint_id.py | 6 ++-- .../rerun/_rerun2/components/label.py | 12 ++++--- .../rerun/_rerun2/components/point2d.py | 10 +++--- .../rerun/_rerun2/components/radius.py | 10 +++--- .../rerun/_rerun2/datatypes/__init__.py | 6 ++-- .../rerun/_rerun2/datatypes/fuzzy.py | 7 +++-- .../rerun/_rerun2/datatypes/vec2d.py | 11 ++++--- 18 files changed, 92 insertions(+), 61 deletions(-) diff --git a/crates/re_types/source_hash.txt b/crates/re_types/source_hash.txt index bd4ba9f3f5cf..6d956047bb8f 100644 --- a/crates/re_types/source_hash.txt +++ b/crates/re_types/source_hash.txt @@ -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. -3e32fbbf9bde3b1e48f6f8d89265d254f51d4b54c969dda46e361ec725f02171 \ No newline at end of file +219cf96d5e2976a679fd188430b4d6b9ffc8914d354e413f6d4023a499896f47 \ No newline at end of file diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/__init__.py b/rerun_py/rerun_sdk/rerun/_rerun2/__init__.py index 436e54dd125e..73c8a2dc7112 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/__init__.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/__init__.py @@ -4,4 +4,4 @@ __all__ = ["AffixFuzzer1", "Points2D"] -from .archetypes import AffixFuzzer1, Points2D +from .archetypes import Points2D, AffixFuzzer1 diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/__init__.py b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/__init__.py index adba56934c13..0d0d54ad8fe4 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/__init__.py @@ -5,5 +5,6 @@ __all__ = ["Archetype", "AffixFuzzer1", "Points2D"] from ._base import Archetype -from .fuzzy import AffixFuzzer1 + from .points2d import Points2D +from .fuzzy import AffixFuzzer1 diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py index bbb01722a1c5..f05bee19589c 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py @@ -2,7 +2,12 @@ from __future__ import annotations +import numpy as np +import numpy.typing as npt +import pyarrow as pa + from dataclasses import dataclass, field +from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union from ._base import Archetype diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py index a53b0632ebae..9373274468f0 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py @@ -2,7 +2,12 @@ from __future__ import annotations +import numpy as np +import numpy.typing as npt +import pyarrow as pa + from dataclasses import dataclass, field +from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union from ._base import Archetype @@ -15,7 +20,9 @@ @dataclass class Points2D(Archetype): - """A 2D point cloud with positions and optional colors, radii, labels, etc.""" + """ + A 2D point cloud with positions and optional colors, radii, labels, etc. + """ points: components.Point2DArray = field(metadata={"component": "primary"}) """ diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py index 03e810d8ccf7..26883135d0f4 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py @@ -82,48 +82,49 @@ ] from ._base import Component -from .class_id import ClassId, ClassIdArray, ClassIdArrayLike, ClassIdLike, ClassIdType -from .color import Color, ColorArray, ColorArrayLike, ColorLike, ColorType -from .draw_order import DrawOrder, DrawOrderArray, DrawOrderArrayLike, DrawOrderLike, DrawOrderType + +from .point2d import Point2D, Point2DLike, Point2DArray, Point2DArrayLike, Point2DType +from .draw_order import DrawOrder, DrawOrderLike, DrawOrderArray, DrawOrderArrayLike, DrawOrderType +from .keypoint_id import KeypointId, KeypointIdLike, KeypointIdArray, KeypointIdArrayLike, KeypointIdType +from .color import Color, ColorLike, ColorArray, ColorArrayLike, ColorType from .fuzzy import ( AffixFuzzer1, + AffixFuzzer1Like, AffixFuzzer1Array, AffixFuzzer1ArrayLike, - AffixFuzzer1Like, AffixFuzzer1Type, AffixFuzzer2, + AffixFuzzer2Like, AffixFuzzer2Array, AffixFuzzer2ArrayLike, - AffixFuzzer2Like, AffixFuzzer2Type, AffixFuzzer3, + AffixFuzzer3Like, AffixFuzzer3Array, AffixFuzzer3ArrayLike, - AffixFuzzer3Like, AffixFuzzer3Type, AffixFuzzer4, + AffixFuzzer4Like, AffixFuzzer4Array, AffixFuzzer4ArrayLike, - AffixFuzzer4Like, AffixFuzzer4Type, AffixFuzzer5, + AffixFuzzer5Like, AffixFuzzer5Array, AffixFuzzer5ArrayLike, - AffixFuzzer5Like, AffixFuzzer5Type, AffixFuzzer6, + AffixFuzzer6Like, AffixFuzzer6Array, AffixFuzzer6ArrayLike, - AffixFuzzer6Like, AffixFuzzer6Type, AffixFuzzer7, + AffixFuzzer7Like, AffixFuzzer7Array, AffixFuzzer7ArrayLike, - AffixFuzzer7Like, AffixFuzzer7Type, ) -from .instance_key import InstanceKey, InstanceKeyArray, InstanceKeyArrayLike, InstanceKeyLike, InstanceKeyType -from .keypoint_id import KeypointId, KeypointIdArray, KeypointIdArrayLike, KeypointIdLike, KeypointIdType -from .label import Label, LabelArray, LabelArrayLike, LabelLike, LabelType -from .point2d import Point2D, Point2DArray, Point2DArrayLike, Point2DLike, Point2DType -from .radius import Radius, RadiusArray, RadiusArrayLike, RadiusLike, RadiusType +from .label import Label, LabelLike, LabelArray, LabelArrayLike, LabelType +from .instance_key import InstanceKey, InstanceKeyLike, InstanceKeyArray, InstanceKeyArrayLike, InstanceKeyType +from .radius import Radius, RadiusLike, RadiusArray, RadiusArrayLike, RadiusType +from .class_id import ClassId, ClassIdLike, ClassIdArray, ClassIdArrayLike, ClassIdType diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py index 384741ade57e..aedf0044799a 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py @@ -2,13 +2,13 @@ from __future__ import annotations -from dataclasses import dataclass -from typing import Any, Sequence, Union - import numpy as np import numpy.typing as npt import pyarrow as pa +from dataclasses import dataclass, field +from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union + from ._base import Component __all__ = ["ClassId", "ClassIdArray", "ClassIdArrayLike", "ClassIdLike", "ClassIdType"] @@ -19,7 +19,9 @@ @dataclass class ClassId(Component): - """A 16-bit ID representing a type of semantic class.""" + """ + A 16-bit ID representing a type of semantic class. + """ id: int diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py index 29eb7d5d2077..88cbcbe15b7c 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py @@ -2,13 +2,13 @@ from __future__ import annotations -from dataclasses import dataclass -from typing import Any, Sequence, Union - import numpy as np import numpy.typing as npt import pyarrow as pa +from dataclasses import dataclass, field +from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union + from ._base import Component __all__ = ["Color", "ColorArray", "ColorArrayLike", "ColorLike", "ColorType"] diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py index 11734e5f5011..d7aec23353e8 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py @@ -2,13 +2,13 @@ from __future__ import annotations -from dataclasses import dataclass -from typing import Any, Sequence, Union - import numpy as np import numpy.typing as npt import pyarrow as pa +from dataclasses import dataclass, field +from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union + from ._base import Component __all__ = ["DrawOrder", "DrawOrderArray", "DrawOrderArrayLike", "DrawOrderLike", "DrawOrderType"] diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py index f2866f1e64d3..1f14457fa98e 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py @@ -2,12 +2,13 @@ from __future__ import annotations -from dataclasses import dataclass -from typing import Any, Sequence, Union - +import numpy as np import numpy.typing as npt import pyarrow as pa +from dataclasses import dataclass, field +from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union + from ._base import Component __all__ = [ diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py index e6fe20fcf324..3baf940806ef 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py @@ -2,13 +2,13 @@ from __future__ import annotations -from dataclasses import dataclass -from typing import Any, Sequence, Union - import numpy as np import numpy.typing as npt import pyarrow as pa +from dataclasses import dataclass, field +from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union + from ._base import Component __all__ = ["InstanceKey", "InstanceKeyArray", "InstanceKeyArrayLike", "InstanceKeyLike", "InstanceKeyType"] @@ -19,7 +19,9 @@ @dataclass class InstanceKey(Component): - """A unique numeric identifier for each individual instance within a batch.""" + """ + A unique numeric identifier for each individual instance within a batch. + """ value: int diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py index f3c4f20a7c41..8b0f1d55f9d1 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py @@ -2,13 +2,13 @@ from __future__ import annotations -from dataclasses import dataclass -from typing import Any, Sequence, Union - import numpy as np import numpy.typing as npt import pyarrow as pa +from dataclasses import dataclass, field +from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union + from ._base import Component __all__ = ["KeypointId", "KeypointIdArray", "KeypointIdArrayLike", "KeypointIdLike", "KeypointIdType"] diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py index 8a7f399569e5..12e418fee51c 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py @@ -2,11 +2,13 @@ from __future__ import annotations -from dataclasses import dataclass -from typing import Any, Sequence, Union - +import numpy as np +import numpy.typing as npt import pyarrow as pa +from dataclasses import dataclass, field +from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union + from ._base import Component __all__ = ["Label", "LabelArray", "LabelArrayLike", "LabelLike", "LabelType"] @@ -17,7 +19,9 @@ @dataclass class Label(Component): - """A String label component.""" + """ + A String label component. + """ value: str diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py index 0134ea0af801..e9afd243ff1b 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py @@ -2,13 +2,13 @@ from __future__ import annotations -from dataclasses import dataclass -from typing import Any, Sequence, Tuple, Union - import numpy as np import numpy.typing as npt import pyarrow as pa +from dataclasses import dataclass, field +from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union + from ._base import Component __all__ = ["Point2D", "Point2DArray", "Point2DArrayLike", "Point2DLike", "Point2DType"] @@ -19,7 +19,9 @@ @dataclass class Point2D(Component): - """A point in 2D space.""" + """ + A point in 2D space. + """ x: float y: float diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py index 2329419dc64d..242e01532a8c 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py @@ -2,13 +2,13 @@ from __future__ import annotations -from dataclasses import dataclass -from typing import Any, Sequence, Union - import numpy as np import numpy.typing as npt import pyarrow as pa +from dataclasses import dataclass, field +from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union + from ._base import Component __all__ = ["Radius", "RadiusArray", "RadiusArrayLike", "RadiusLike", "RadiusType"] @@ -19,7 +19,9 @@ @dataclass class Radius(Component): - """A Radius component.""" + """ + A Radius component. + """ value: float diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/__init__.py b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/__init__.py index cec81dfa19cf..17886a025fd0 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/__init__.py @@ -21,16 +21,16 @@ ] +from .vec2d import Vec2D, Vec2DLike, Vec2DArray, Vec2DArrayLike, Vec2DType from .fuzzy import ( AffixFuzzer1, + AffixFuzzer1Like, AffixFuzzer1Array, AffixFuzzer1ArrayLike, - AffixFuzzer1Like, AffixFuzzer1Type, AffixFuzzer2, + AffixFuzzer2Like, AffixFuzzer2Array, AffixFuzzer2ArrayLike, - AffixFuzzer2Like, AffixFuzzer2Type, ) -from .vec2d import Vec2D, Vec2DArray, Vec2DArrayLike, Vec2DLike, Vec2DType diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py index f095027ea27e..796c186ee1b3 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py @@ -2,13 +2,14 @@ from __future__ import annotations -from dataclasses import dataclass -from typing import Any, Sequence, Union - import numpy as np import numpy.typing as npt import pyarrow as pa +from dataclasses import dataclass, field +from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union + + __all__ = [ "AffixFuzzer1", "AffixFuzzer1Array", diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/vec2d.py b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/vec2d.py index 14aa1d0a2a1c..ba9e38373ecb 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/vec2d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/vec2d.py @@ -2,13 +2,14 @@ from __future__ import annotations -from dataclasses import dataclass -from typing import Any, Sequence, Union - import numpy as np import numpy.typing as npt import pyarrow as pa +from dataclasses import dataclass, field +from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union + + __all__ = ["Vec2D", "Vec2DArray", "Vec2DArrayLike", "Vec2DLike", "Vec2DType"] @@ -17,7 +18,9 @@ @dataclass class Vec2D: - """A vector in 2D space.""" + """ + A vector in 2D space. + """ xy: npt.ArrayLike From 331856729c3739d31c1891e7b51d99f89926eb02 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Sat, 1 Jul 2023 12:21:48 +0200 Subject: [PATCH 06/14] Codegen again --- rerun_py/rerun_sdk/rerun/_rerun2/__init__.py | 2 +- .../rerun/_rerun2/archetypes/__init__.py | 3 +- .../rerun/_rerun2/archetypes/fuzzy.py | 5 --- .../rerun/_rerun2/archetypes/points2d.py | 9 +----- .../rerun/_rerun2/components/__init__.py | 31 +++++++++---------- .../rerun/_rerun2/components/class_id.py | 10 +++--- .../rerun/_rerun2/components/color.py | 6 ++-- .../rerun/_rerun2/components/draw_order.py | 6 ++-- .../rerun/_rerun2/components/fuzzy.py | 7 ++--- .../rerun/_rerun2/components/instance_key.py | 10 +++--- .../rerun/_rerun2/components/keypoint_id.py | 6 ++-- .../rerun/_rerun2/components/label.py | 12 +++---- .../rerun/_rerun2/components/point2d.py | 10 +++--- .../rerun/_rerun2/components/radius.py | 10 +++--- .../rerun/_rerun2/datatypes/__init__.py | 6 ++-- .../rerun/_rerun2/datatypes/fuzzy.py | 7 ++--- .../rerun/_rerun2/datatypes/vec2d.py | 11 +++---- 17 files changed, 60 insertions(+), 91 deletions(-) diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/__init__.py b/rerun_py/rerun_sdk/rerun/_rerun2/__init__.py index 73c8a2dc7112..436e54dd125e 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/__init__.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/__init__.py @@ -4,4 +4,4 @@ __all__ = ["AffixFuzzer1", "Points2D"] -from .archetypes import Points2D, AffixFuzzer1 +from .archetypes import AffixFuzzer1, Points2D diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/__init__.py b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/__init__.py index 0d0d54ad8fe4..adba56934c13 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/__init__.py @@ -5,6 +5,5 @@ __all__ = ["Archetype", "AffixFuzzer1", "Points2D"] from ._base import Archetype - -from .points2d import Points2D from .fuzzy import AffixFuzzer1 +from .points2d import Points2D diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py index f05bee19589c..bbb01722a1c5 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py @@ -2,12 +2,7 @@ from __future__ import annotations -import numpy as np -import numpy.typing as npt -import pyarrow as pa - from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union from ._base import Archetype diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py index 9373274468f0..a53b0632ebae 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py @@ -2,12 +2,7 @@ from __future__ import annotations -import numpy as np -import numpy.typing as npt -import pyarrow as pa - from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union from ._base import Archetype @@ -20,9 +15,7 @@ @dataclass class Points2D(Archetype): - """ - A 2D point cloud with positions and optional colors, radii, labels, etc. - """ + """A 2D point cloud with positions and optional colors, radii, labels, etc.""" points: components.Point2DArray = field(metadata={"component": "primary"}) """ diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py index 26883135d0f4..03e810d8ccf7 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py @@ -82,49 +82,48 @@ ] from ._base import Component - -from .point2d import Point2D, Point2DLike, Point2DArray, Point2DArrayLike, Point2DType -from .draw_order import DrawOrder, DrawOrderLike, DrawOrderArray, DrawOrderArrayLike, DrawOrderType -from .keypoint_id import KeypointId, KeypointIdLike, KeypointIdArray, KeypointIdArrayLike, KeypointIdType -from .color import Color, ColorLike, ColorArray, ColorArrayLike, ColorType +from .class_id import ClassId, ClassIdArray, ClassIdArrayLike, ClassIdLike, ClassIdType +from .color import Color, ColorArray, ColorArrayLike, ColorLike, ColorType +from .draw_order import DrawOrder, DrawOrderArray, DrawOrderArrayLike, DrawOrderLike, DrawOrderType from .fuzzy import ( AffixFuzzer1, - AffixFuzzer1Like, AffixFuzzer1Array, AffixFuzzer1ArrayLike, + AffixFuzzer1Like, AffixFuzzer1Type, AffixFuzzer2, - AffixFuzzer2Like, AffixFuzzer2Array, AffixFuzzer2ArrayLike, + AffixFuzzer2Like, AffixFuzzer2Type, AffixFuzzer3, - AffixFuzzer3Like, AffixFuzzer3Array, AffixFuzzer3ArrayLike, + AffixFuzzer3Like, AffixFuzzer3Type, AffixFuzzer4, - AffixFuzzer4Like, AffixFuzzer4Array, AffixFuzzer4ArrayLike, + AffixFuzzer4Like, AffixFuzzer4Type, AffixFuzzer5, - AffixFuzzer5Like, AffixFuzzer5Array, AffixFuzzer5ArrayLike, + AffixFuzzer5Like, AffixFuzzer5Type, AffixFuzzer6, - AffixFuzzer6Like, AffixFuzzer6Array, AffixFuzzer6ArrayLike, + AffixFuzzer6Like, AffixFuzzer6Type, AffixFuzzer7, - AffixFuzzer7Like, AffixFuzzer7Array, AffixFuzzer7ArrayLike, + AffixFuzzer7Like, AffixFuzzer7Type, ) -from .label import Label, LabelLike, LabelArray, LabelArrayLike, LabelType -from .instance_key import InstanceKey, InstanceKeyLike, InstanceKeyArray, InstanceKeyArrayLike, InstanceKeyType -from .radius import Radius, RadiusLike, RadiusArray, RadiusArrayLike, RadiusType -from .class_id import ClassId, ClassIdLike, ClassIdArray, ClassIdArrayLike, ClassIdType +from .instance_key import InstanceKey, InstanceKeyArray, InstanceKeyArrayLike, InstanceKeyLike, InstanceKeyType +from .keypoint_id import KeypointId, KeypointIdArray, KeypointIdArrayLike, KeypointIdLike, KeypointIdType +from .label import Label, LabelArray, LabelArrayLike, LabelLike, LabelType +from .point2d import Point2D, Point2DArray, Point2DArrayLike, Point2DLike, Point2DType +from .radius import Radius, RadiusArray, RadiusArrayLike, RadiusLike, RadiusType diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py index aedf0044799a..384741ade57e 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py @@ -2,13 +2,13 @@ from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Sequence, Union + import numpy as np import numpy.typing as npt import pyarrow as pa -from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union - from ._base import Component __all__ = ["ClassId", "ClassIdArray", "ClassIdArrayLike", "ClassIdLike", "ClassIdType"] @@ -19,9 +19,7 @@ @dataclass class ClassId(Component): - """ - A 16-bit ID representing a type of semantic class. - """ + """A 16-bit ID representing a type of semantic class.""" id: int diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py index 88cbcbe15b7c..29eb7d5d2077 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py @@ -2,13 +2,13 @@ from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Sequence, Union + import numpy as np import numpy.typing as npt import pyarrow as pa -from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union - from ._base import Component __all__ = ["Color", "ColorArray", "ColorArrayLike", "ColorLike", "ColorType"] diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py index d7aec23353e8..11734e5f5011 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py @@ -2,13 +2,13 @@ from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Sequence, Union + import numpy as np import numpy.typing as npt import pyarrow as pa -from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union - from ._base import Component __all__ = ["DrawOrder", "DrawOrderArray", "DrawOrderArrayLike", "DrawOrderLike", "DrawOrderType"] diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py index 1f14457fa98e..f2866f1e64d3 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py @@ -2,13 +2,12 @@ from __future__ import annotations -import numpy as np +from dataclasses import dataclass +from typing import Any, Sequence, Union + import numpy.typing as npt import pyarrow as pa -from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union - from ._base import Component __all__ = [ diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py index 3baf940806ef..e6fe20fcf324 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py @@ -2,13 +2,13 @@ from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Sequence, Union + import numpy as np import numpy.typing as npt import pyarrow as pa -from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union - from ._base import Component __all__ = ["InstanceKey", "InstanceKeyArray", "InstanceKeyArrayLike", "InstanceKeyLike", "InstanceKeyType"] @@ -19,9 +19,7 @@ @dataclass class InstanceKey(Component): - """ - A unique numeric identifier for each individual instance within a batch. - """ + """A unique numeric identifier for each individual instance within a batch.""" value: int diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py index 8b0f1d55f9d1..f3c4f20a7c41 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py @@ -2,13 +2,13 @@ from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Sequence, Union + import numpy as np import numpy.typing as npt import pyarrow as pa -from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union - from ._base import Component __all__ = ["KeypointId", "KeypointIdArray", "KeypointIdArrayLike", "KeypointIdLike", "KeypointIdType"] diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py index 12e418fee51c..8a7f399569e5 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py @@ -2,12 +2,10 @@ from __future__ import annotations -import numpy as np -import numpy.typing as npt -import pyarrow as pa +from dataclasses import dataclass +from typing import Any, Sequence, Union -from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union +import pyarrow as pa from ._base import Component @@ -19,9 +17,7 @@ @dataclass class Label(Component): - """ - A String label component. - """ + """A String label component.""" value: str diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py index e9afd243ff1b..0134ea0af801 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py @@ -2,13 +2,13 @@ from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Sequence, Tuple, Union + import numpy as np import numpy.typing as npt import pyarrow as pa -from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union - from ._base import Component __all__ = ["Point2D", "Point2DArray", "Point2DArrayLike", "Point2DLike", "Point2DType"] @@ -19,9 +19,7 @@ @dataclass class Point2D(Component): - """ - A point in 2D space. - """ + """A point in 2D space.""" x: float y: float diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py index 242e01532a8c..2329419dc64d 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py @@ -2,13 +2,13 @@ from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Sequence, Union + import numpy as np import numpy.typing as npt import pyarrow as pa -from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union - from ._base import Component __all__ = ["Radius", "RadiusArray", "RadiusArrayLike", "RadiusLike", "RadiusType"] @@ -19,9 +19,7 @@ @dataclass class Radius(Component): - """ - A Radius component. - """ + """A Radius component.""" value: float diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/__init__.py b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/__init__.py index 17886a025fd0..cec81dfa19cf 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/__init__.py @@ -21,16 +21,16 @@ ] -from .vec2d import Vec2D, Vec2DLike, Vec2DArray, Vec2DArrayLike, Vec2DType from .fuzzy import ( AffixFuzzer1, - AffixFuzzer1Like, AffixFuzzer1Array, AffixFuzzer1ArrayLike, + AffixFuzzer1Like, AffixFuzzer1Type, AffixFuzzer2, - AffixFuzzer2Like, AffixFuzzer2Array, AffixFuzzer2ArrayLike, + AffixFuzzer2Like, AffixFuzzer2Type, ) +from .vec2d import Vec2D, Vec2DArray, Vec2DArrayLike, Vec2DLike, Vec2DType diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py index 796c186ee1b3..f095027ea27e 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py @@ -2,14 +2,13 @@ from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Sequence, Union + import numpy as np import numpy.typing as npt import pyarrow as pa -from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union - - __all__ = [ "AffixFuzzer1", "AffixFuzzer1Array", diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/vec2d.py b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/vec2d.py index ba9e38373ecb..14aa1d0a2a1c 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/vec2d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/vec2d.py @@ -2,14 +2,13 @@ from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Sequence, Union + import numpy as np import numpy.typing as npt import pyarrow as pa -from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union - - __all__ = ["Vec2D", "Vec2DArray", "Vec2DArrayLike", "Vec2DLike", "Vec2DType"] @@ -18,9 +17,7 @@ @dataclass class Vec2D: - """ - A vector in 2D space. - """ + """A vector in 2D space.""" xy: npt.ArrayLike From 3b58d94fdf5848629fcc65c8059eda4a51e014f4 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Sat, 1 Jul 2023 14:21:22 +0200 Subject: [PATCH 07/14] Native objects for components *are not* Component subclasses. --- crates/re_types_builder/src/codegen/python.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/re_types_builder/src/codegen/python.rs b/crates/re_types_builder/src/codegen/python.rs index 46a5744732ff..3c945ee5c52e 100644 --- a/crates/re_types_builder/src/codegen/python.rs +++ b/crates/re_types_builder/src/codegen/python.rs @@ -295,8 +295,7 @@ impl QuotedObject { let superclass = match *kind { ObjectKind::Archetype => "(Archetype)", - ObjectKind::Component => "(Component)", - ObjectKind::Datatype => "", + ObjectKind::Component | ObjectKind::Datatype => "", }; code.push_unindented_text( format!( From 4b5f2ed2b2114e5e89ab7201d9ca11455512a29e Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Sat, 1 Jul 2023 14:21:32 +0200 Subject: [PATCH 08/14] Codegen --- crates/re_types/source_hash.txt | 2 +- .../rerun_sdk/rerun/_rerun2/components/class_id.py | 2 +- .../rerun_sdk/rerun/_rerun2/components/color.py | 2 +- .../rerun/_rerun2/components/draw_order.py | 2 +- .../rerun_sdk/rerun/_rerun2/components/fuzzy.py | 14 +++++++------- .../rerun/_rerun2/components/instance_key.py | 2 +- .../rerun/_rerun2/components/keypoint_id.py | 2 +- .../rerun_sdk/rerun/_rerun2/components/label.py | 2 +- .../rerun_sdk/rerun/_rerun2/components/point2d.py | 2 +- .../rerun_sdk/rerun/_rerun2/components/radius.py | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/crates/re_types/source_hash.txt b/crates/re_types/source_hash.txt index 6d956047bb8f..017beb2a4153 100644 --- a/crates/re_types/source_hash.txt +++ b/crates/re_types/source_hash.txt @@ -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. -219cf96d5e2976a679fd188430b4d6b9ffc8914d354e413f6d4023a499896f47 \ No newline at end of file +e32e0f115b22080f35f06fb73b486eeb390c4c47deee6c04012621ab5fca0d09 \ No newline at end of file diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py index 384741ade57e..f9484667052d 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py @@ -18,7 +18,7 @@ @dataclass -class ClassId(Component): +class ClassId: """A 16-bit ID representing a type of semantic class.""" id: int diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py index 29eb7d5d2077..fa8915791474 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py @@ -18,7 +18,7 @@ @dataclass -class Color(Component): +class Color: """ An RGBA color tuple with unmultiplied/separate alpha, in sRGB gamma space with linear alpha. diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py index 11734e5f5011..3b74433ae08b 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py @@ -18,7 +18,7 @@ @dataclass -class DrawOrder(Component): +class DrawOrder: """ Draw order used for the display order of 2D elements. diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py index f2866f1e64d3..8f0c102d61ad 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py @@ -54,7 +54,7 @@ @dataclass -class AffixFuzzer1(Component): +class AffixFuzzer1: single_required: datatypes.AffixFuzzer1 @@ -128,7 +128,7 @@ def from_similar(data: AffixFuzzer1ArrayLike | None) -> pa.Array: @dataclass -class AffixFuzzer2(Component): +class AffixFuzzer2: single_required: datatypes.AffixFuzzer1 @@ -202,7 +202,7 @@ def from_similar(data: AffixFuzzer2ArrayLike | None) -> pa.Array: @dataclass -class AffixFuzzer3(Component): +class AffixFuzzer3: single_required: datatypes.AffixFuzzer1 @@ -291,7 +291,7 @@ def from_similar(data: AffixFuzzer3ArrayLike | None) -> pa.Array: @dataclass -class AffixFuzzer4(Component): +class AffixFuzzer4: single_optional: datatypes.AffixFuzzer1 | None = None @@ -365,7 +365,7 @@ def from_similar(data: AffixFuzzer4ArrayLike | None) -> pa.Array: @dataclass -class AffixFuzzer5(Component): +class AffixFuzzer5: single_optional: datatypes.AffixFuzzer1 | None = None @@ -439,7 +439,7 @@ def from_similar(data: AffixFuzzer5ArrayLike | None) -> pa.Array: @dataclass -class AffixFuzzer6(Component): +class AffixFuzzer6: single_optional: datatypes.AffixFuzzer1 | None = None @@ -528,7 +528,7 @@ def from_similar(data: AffixFuzzer6ArrayLike | None) -> pa.Array: @dataclass -class AffixFuzzer7(Component): +class AffixFuzzer7: single_string_required: str many_strings_required: npt.ArrayLike many_optional: list[datatypes.AffixFuzzer1] | None = None diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py index e6fe20fcf324..d50197f657b7 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py @@ -18,7 +18,7 @@ @dataclass -class InstanceKey(Component): +class InstanceKey: """A unique numeric identifier for each individual instance within a batch.""" value: int diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py index f3c4f20a7c41..1f9c6dabc4da 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py @@ -18,7 +18,7 @@ @dataclass -class KeypointId(Component): +class KeypointId: """ A 16-bit ID representing a type of semantic keypoint within a class. diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py index 8a7f399569e5..e5c8a44ca1c7 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py @@ -16,7 +16,7 @@ @dataclass -class Label(Component): +class Label: """A String label component.""" value: str diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py index 0134ea0af801..34e7d28ce673 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py @@ -18,7 +18,7 @@ @dataclass -class Point2D(Component): +class Point2D: """A point in 2D space.""" x: float diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py index 2329419dc64d..0e58fb790b1a 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py @@ -18,7 +18,7 @@ @dataclass -class Radius(Component): +class Radius: """A Radius component.""" value: float From 6e1e2b8dae8b65cedfebb838ae5479d280792ad6 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Mon, 3 Jul 2023 09:05:58 +0200 Subject: [PATCH 09/14] Fixed source_hash.txt --- crates/re_types/source_hash.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/re_types/source_hash.txt b/crates/re_types/source_hash.txt index 017beb2a4153..bfb98aa5f715 100644 --- a/crates/re_types/source_hash.txt +++ b/crates/re_types/source_hash.txt @@ -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. -e32e0f115b22080f35f06fb73b486eeb390c4c47deee6c04012621ab5fca0d09 \ No newline at end of file +b7927e46605c38a4659f7c90a026f6ce5903e84428414549725107993a4af38a \ No newline at end of file From 3da7eff6a8d4fae9ba2e5b54a7328cecf13ebd9e Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Mon, 3 Jul 2023 10:55:26 +0200 Subject: [PATCH 10/14] - moved base classes - conditional use of new api in api_demo - do not needlessly splat --- crates/re_types_builder/src/codegen/python.rs | 8 +-- examples/python/api_demo/main.py | 43 +++++++++++----- rerun_py/rerun_sdk/rerun/__init__.py | 5 +- .../{components/_base.py => _baseclasses.py} | 7 +++ .../rerun/_rerun2/archetypes/_base.py | 8 --- rerun_py/rerun_sdk/rerun/_rerun2/log_any.py | 49 ++++++++++++++----- 6 files changed, 81 insertions(+), 39 deletions(-) rename rerun_py/rerun_sdk/rerun/_rerun2/{components/_base.py => _baseclasses.py} (74%) delete mode 100644 rerun_py/rerun_sdk/rerun/_rerun2/archetypes/_base.py diff --git a/crates/re_types_builder/src/codegen/python.rs b/crates/re_types_builder/src/codegen/python.rs index 3c945ee5c52e..4cca28137f1f 100644 --- a/crates/re_types_builder/src/codegen/python.rs +++ b/crates/re_types_builder/src/codegen/python.rs @@ -181,8 +181,8 @@ fn quote_objects( let manifest = quote_manifest(names); let base_include = match kind { - ObjectKind::Archetype => "from ._base import Archetype", - ObjectKind::Component => "from ._base import Component", + ObjectKind::Archetype => "from .._baseclasses import Archetype", + ObjectKind::Component => "from .._baseclasses import Component", ObjectKind::Datatype => "", }; code.push_unindented_text( @@ -232,8 +232,8 @@ fn quote_objects( let manifest = quote_manifest(mods.iter().flat_map(|(_, names)| names.iter())); let (base_manifest, base_include) = match kind { - ObjectKind::Archetype => ("\"Archetype\", ", "from ._base import Archetype\n"), - ObjectKind::Component => ("\"Component\", ", "from ._base import Component\n"), + ObjectKind::Archetype => ("\"Archetype\", ", "from .._baseclasses import Archetype\n"), + ObjectKind::Component => ("\"Component\", ", "from .._baseclasses import Component\n"), ObjectKind::Datatype => ("", ""), }; diff --git a/examples/python/api_demo/main.py b/examples/python/api_demo/main.py index ba272e783e24..e4614345b160 100755 --- a/examples/python/api_demo/main.py +++ b/examples/python/api_demo/main.py @@ -33,21 +33,38 @@ def run_segmentation() -> None: rr.log_segmentation_image("seg_demo/img", segmentation_img) # Log a bunch of classified 2D points - # Note: this uses the new, WIP object-oriented API - rr.log_any("seg_demo/single_point", rr.Points2D(np.array([64, 64]), class_ids=13)) - rr.log_any("seg_demo/single_point_labeled", rr.Points2D(np.array([90, 50]), class_ids=13, labels="labeled point")) - rr.log_any("seg_demo/several_points0", rr.Points2D(np.array([[20, 50], [100, 70], [60, 30]]), class_ids=42)) - rr.log_any( - "seg_demo/several_points1", - rr.Points2D(np.array([[40, 50], [120, 70], [80, 30]]), class_ids=np.array([13, 42, 99], dtype=np.uint8)), - ) - rr.log_any( - "seg_demo/many points", - rr.Points2D( + if rr.ENABLE_NEXT_GEN_API: + # Note: this uses the new, WIP object-oriented API + rr.log_any("seg_demo/single_point", rr.Points2D(np.array([64, 64]), class_ids=13)) + rr.log_any( + "seg_demo/single_point_labeled", rr.Points2D(np.array([90, 50]), class_ids=13, labels="labeled point") + ) + rr.log_any("seg_demo/several_points0", rr.Points2D(np.array([[20, 50], [100, 70], [60, 30]]), class_ids=42)) + rr.log_any( + "seg_demo/several_points1", + rr.Points2D(np.array([[40, 50], [120, 70], [80, 30]]), class_ids=np.array([13, 42, 99], dtype=np.uint8)), + ) + rr.log_any( + "seg_demo/many points", + rr.Points2D( + np.array([[100 + (int(i / 5)) * 2, 100 + (i % 5) * 2] for i in range(25)]), + class_ids=np.array([42], dtype=np.uint8), + ), + ) + else: + rr.log_point("seg_demo/single_point", np.array([64, 64]), class_id=13) + rr.log_point("seg_demo/single_point_labeled", np.array([90, 50]), class_id=13, label="labeled point") + rr.log_points("seg_demo/several_points0", np.array([[20, 50], [100, 70], [60, 30]]), class_ids=42) + rr.log_points( + "seg_demo/several_points1", + np.array([[40, 50], [120, 70], [80, 30]]), + class_ids=np.array([13, 42, 99], dtype=np.uint8), + ) + rr.log_points( + "seg_demo/many points", np.array([[100 + (int(i / 5)) * 2, 100 + (i % 5) * 2] for i in range(25)]), class_ids=np.array([42], dtype=np.uint8), - ), - ) + ) rr.log_text_entry("logs/seg_demo_log", "default colored rects, default colored points, a single point has a label") diff --git a/rerun_py/rerun_sdk/rerun/__init__.py b/rerun_py/rerun_sdk/rerun/__init__.py index 1f06926ece0b..64184c10318c 100644 --- a/rerun_py/rerun_sdk/rerun/__init__.py +++ b/rerun_py/rerun_sdk/rerun/__init__.py @@ -56,9 +56,8 @@ from .time import reset_time, set_time_nanos, set_time_seconds, set_time_sequence # Next-gen API imports -# TODO(ab): remove this guard, here to make it easy to "hide" the next gen API if needed in the short term. -_ENABLE_NEXT_GEN_API = True -if _ENABLE_NEXT_GEN_API: +ENABLE_NEXT_GEN_API = True +if ENABLE_NEXT_GEN_API: from ._rerun2.archetypes import * from ._rerun2.log_any import log_any diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/_base.py b/rerun_py/rerun_sdk/rerun/_rerun2/_baseclasses.py similarity index 74% rename from rerun_py/rerun_sdk/rerun/_rerun2/components/_base.py rename to rerun_py/rerun_sdk/rerun/_rerun2/_baseclasses.py index 7c8f5a9a6a56..a42f49a61ad3 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/_base.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/_baseclasses.py @@ -1,8 +1,15 @@ from __future__ import annotations +from dataclasses import dataclass + import pyarrow as pa +@dataclass +class Archetype: + pass + + class Component(pa.ExtensionArray): # type: ignore[misc] @property def extension_name(self) -> str: diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/_base.py b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/_base.py deleted file mode 100644 index 2998990e9c7d..000000000000 --- a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/_base.py +++ /dev/null @@ -1,8 +0,0 @@ -from __future__ import annotations - -from dataclasses import dataclass - - -@dataclass -class Archetype: - pass diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/log_any.py b/rerun_py/rerun_sdk/rerun/_rerun2/log_any.py index 5177908e8850..74d4b00578ea 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/log_any.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/log_any.py @@ -1,7 +1,7 @@ from __future__ import annotations from dataclasses import fields -from typing import Any +from typing import Any, Iterable import numpy as np import numpy.typing as npt @@ -65,6 +65,13 @@ def _add_extension_components( instanced[name] = pa_value # noqa +def _extract_components(entity: Archetype) -> Iterable[tuple[Component, bool]]: + """Extract the components from an entity, yielding (component, is_primary) tuples.""" + for fld in fields(entity): + if "component" in fld.metadata: + yield getattr(entity, fld.name), fld.metadata["component"] == "primary" + + def log_any( entity_path: str, entity: Archetype, @@ -72,25 +79,45 @@ def log_any( timeless: bool = False, recording: RecordingStream | None = None, ) -> None: + """ + Log an entity. + + Parameters + ---------- + entity_path: + Path to the points in the space hierarchy. + entity: Archetype + The archetype object representing the entity. + ext: + Optional dictionary of extension components. See [rerun.log_extension_components][] + timeless: + If true, the points will be timeless (default: False). + recording: + Specifies the [`rerun.RecordingStream`][] to use. + If left unspecified, defaults to the current active data recording, if there is one. + See also: [`rerun.init`][], [`rerun.set_global_data_recording`][]. + + """ + from .. import strict_mode if strict_mode(): if not isinstance(entity, Archetype): raise TypeError(f"Expected Archetype, got {type(entity)}") - # 0 = instanced, 1 = splat instanced: dict[str, Component] = {} splats: dict[str, Component] = {} - for fld in fields(entity): - if "component" in fld.metadata: - comp: Component = getattr(entity, fld.name) - if fld.metadata["component"] == "primary": - instanced[comp.extension_name] = comp.storage - elif len(comp) == 1: - splats[comp.extension_name] = comp.storage - elif len(comp) > 1: - instanced[comp.extension_name] = comp.storage + # find canonical length of this entity by extracting the maximum length of the + archetype_length = max(len(comp) for comp, primary in _extract_components(entity) if primary) + + for comp, primary in _extract_components(entity): + if primary: + instanced[comp.extension_name] = comp.storage + elif len(comp) == 1 and archetype_length > 1: + splats[comp.extension_name] = comp.storage + elif len(comp) > 1: + instanced[comp.extension_name] = comp.storage if ext: _add_extension_components(instanced, splats, ext, None) From cd7e05fc6ae7245b47fe01a4d723b44c5a878e1f Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Mon, 3 Jul 2023 10:55:38 +0200 Subject: [PATCH 11/14] codegen --- crates/re_types/source_hash.txt | 2 +- rerun_py/rerun_sdk/rerun/_rerun2/archetypes/__init__.py | 2 +- rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py | 2 +- rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py | 2 +- rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py | 2 +- rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py | 2 +- rerun_py/rerun_sdk/rerun/_rerun2/components/color.py | 2 +- rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py | 2 +- rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py | 2 +- rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py | 2 +- rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py | 2 +- rerun_py/rerun_sdk/rerun/_rerun2/components/label.py | 2 +- rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py | 2 +- rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/crates/re_types/source_hash.txt b/crates/re_types/source_hash.txt index bfb98aa5f715..41a3145d0e8f 100644 --- a/crates/re_types/source_hash.txt +++ b/crates/re_types/source_hash.txt @@ -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. -b7927e46605c38a4659f7c90a026f6ce5903e84428414549725107993a4af38a \ No newline at end of file +c0d06250415f4b910072a218e82b969fb33ebca44ef59d544373439d6bb135f1 \ No newline at end of file diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/__init__.py b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/__init__.py index adba56934c13..b718bbc1bf28 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/__init__.py @@ -4,6 +4,6 @@ __all__ = ["Archetype", "AffixFuzzer1", "Points2D"] -from ._base import Archetype +from .._baseclasses import Archetype from .fuzzy import AffixFuzzer1 from .points2d import Points2D diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py index bbb01722a1c5..131509f65096 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py @@ -4,7 +4,7 @@ from dataclasses import dataclass, field -from ._base import Archetype +from .._baseclasses import Archetype __all__ = ["AffixFuzzer1"] diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py index a53b0632ebae..137fefc78fd3 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py @@ -4,7 +4,7 @@ from dataclasses import dataclass, field -from ._base import Archetype +from .._baseclasses import Archetype __all__ = ["Points2D"] diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py index 03e810d8ccf7..544020ec3748 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py @@ -81,7 +81,7 @@ "RadiusType", ] -from ._base import Component +from .._baseclasses import Component from .class_id import ClassId, ClassIdArray, ClassIdArrayLike, ClassIdLike, ClassIdType from .color import Color, ColorArray, ColorArrayLike, ColorLike, ColorType from .draw_order import DrawOrder, DrawOrderArray, DrawOrderArrayLike, DrawOrderLike, DrawOrderType diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py index f9484667052d..9b62102c302f 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py @@ -9,7 +9,7 @@ import numpy.typing as npt import pyarrow as pa -from ._base import Component +from .._baseclasses import Component __all__ = ["ClassId", "ClassIdArray", "ClassIdArrayLike", "ClassIdLike", "ClassIdType"] diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py index fa8915791474..76fc3e37c376 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py @@ -9,7 +9,7 @@ import numpy.typing as npt import pyarrow as pa -from ._base import Component +from .._baseclasses import Component __all__ = ["Color", "ColorArray", "ColorArrayLike", "ColorLike", "ColorType"] diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py index 3b74433ae08b..59335a0c4143 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py @@ -9,7 +9,7 @@ import numpy.typing as npt import pyarrow as pa -from ._base import Component +from .._baseclasses import Component __all__ = ["DrawOrder", "DrawOrderArray", "DrawOrderArrayLike", "DrawOrderLike", "DrawOrderType"] diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py index 8f0c102d61ad..24e4de7d4737 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py @@ -8,7 +8,7 @@ import numpy.typing as npt import pyarrow as pa -from ._base import Component +from .._baseclasses import Component __all__ = [ "AffixFuzzer1", diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py index d50197f657b7..10a85e14daa1 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py @@ -9,7 +9,7 @@ import numpy.typing as npt import pyarrow as pa -from ._base import Component +from .._baseclasses import Component __all__ = ["InstanceKey", "InstanceKeyArray", "InstanceKeyArrayLike", "InstanceKeyLike", "InstanceKeyType"] diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py index 1f9c6dabc4da..e53b0bcb6764 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py @@ -9,7 +9,7 @@ import numpy.typing as npt import pyarrow as pa -from ._base import Component +from .._baseclasses import Component __all__ = ["KeypointId", "KeypointIdArray", "KeypointIdArrayLike", "KeypointIdLike", "KeypointIdType"] diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py index e5c8a44ca1c7..b88d61613761 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py @@ -7,7 +7,7 @@ import pyarrow as pa -from ._base import Component +from .._baseclasses import Component __all__ = ["Label", "LabelArray", "LabelArrayLike", "LabelLike", "LabelType"] diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py index 34e7d28ce673..e456b9791440 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py @@ -9,7 +9,7 @@ import numpy.typing as npt import pyarrow as pa -from ._base import Component +from .._baseclasses import Component __all__ = ["Point2D", "Point2DArray", "Point2DArrayLike", "Point2DLike", "Point2DType"] diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py index 0e58fb790b1a..407755538e74 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py @@ -9,7 +9,7 @@ import numpy.typing as npt import pyarrow as pa -from ._base import Component +from .._baseclasses import Component __all__ = ["Radius", "RadiusArray", "RadiusArrayLike", "RadiusLike", "RadiusType"] From e448c28c1e4657d3252c5f4cbfac098bf1888eac Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Mon, 3 Jul 2023 11:58:12 +0200 Subject: [PATCH 12/14] Removed unneeded np.array and fixed comments --- examples/python/api_demo/main.py | 12 +++++------- rerun_py/rerun_sdk/rerun/_rerun2/log_any.py | 6 +++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/examples/python/api_demo/main.py b/examples/python/api_demo/main.py index e4614345b160..578df1e1cc8c 100755 --- a/examples/python/api_demo/main.py +++ b/examples/python/api_demo/main.py @@ -35,19 +35,17 @@ def run_segmentation() -> None: # Log a bunch of classified 2D points if rr.ENABLE_NEXT_GEN_API: # Note: this uses the new, WIP object-oriented API - rr.log_any("seg_demo/single_point", rr.Points2D(np.array([64, 64]), class_ids=13)) - rr.log_any( - "seg_demo/single_point_labeled", rr.Points2D(np.array([90, 50]), class_ids=13, labels="labeled point") - ) - rr.log_any("seg_demo/several_points0", rr.Points2D(np.array([[20, 50], [100, 70], [60, 30]]), class_ids=42)) + rr.log_any("seg_demo/single_point", rr.Points2D([64, 64], class_ids=13)) + rr.log_any("seg_demo/single_point_labeled", rr.Points2D([90, 50], class_ids=13, labels="labeled point")) + rr.log_any("seg_demo/several_points0", rr.Points2D([[20, 50], [100, 70], [60, 30]], class_ids=42)) rr.log_any( "seg_demo/several_points1", - rr.Points2D(np.array([[40, 50], [120, 70], [80, 30]]), class_ids=np.array([13, 42, 99], dtype=np.uint8)), + rr.Points2D([[40, 50], [120, 70], [80, 30]], class_ids=np.array([13, 42, 99], dtype=np.uint8)), ) rr.log_any( "seg_demo/many points", rr.Points2D( - np.array([[100 + (int(i / 5)) * 2, 100 + (i % 5) * 2] for i in range(25)]), + [[100 + (int(i / 5)) * 2, 100 + (i % 5) * 2] for i in range(25)], class_ids=np.array([42], dtype=np.uint8), ), ) diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/log_any.py b/rerun_py/rerun_sdk/rerun/_rerun2/log_any.py index 74d4b00578ea..6d7c4bbd7bb0 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/log_any.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/log_any.py @@ -85,13 +85,13 @@ def log_any( Parameters ---------- entity_path: - Path to the points in the space hierarchy. + Path to the entity in the space hierarchy. entity: Archetype The archetype object representing the entity. ext: Optional dictionary of extension components. See [rerun.log_extension_components][] timeless: - If true, the points will be timeless (default: False). + If true, the entity will be timeless (default: False). recording: Specifies the [`rerun.RecordingStream`][] to use. If left unspecified, defaults to the current active data recording, if there is one. @@ -108,7 +108,7 @@ def log_any( instanced: dict[str, Component] = {} splats: dict[str, Component] = {} - # find canonical length of this entity by extracting the maximum length of the + # find canonical length of this entity by based on the longest length of any primary component archetype_length = max(len(comp) for comp, primary in _extract_components(entity) if primary) for comp, primary in _extract_components(entity): From 129719a7957f079d70ff60794091ee0c835d4dd9 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Mon, 3 Jul 2023 12:06:07 +0200 Subject: [PATCH 13/14] Codegen --- crates/re_types/source_hash.txt | 2 +- rerun_py/rerun_sdk/rerun/_rerun2/__init__.py | 2 +- .../rerun/_rerun2/archetypes/__init__.py | 1 + .../rerun/_rerun2/archetypes/fuzzy.py | 5 +++ .../rerun/_rerun2/archetypes/points2d.py | 9 +++++- .../rerun/_rerun2/components/__init__.py | 31 ++++++++++--------- .../rerun/_rerun2/components/class_id.py | 10 +++--- .../rerun/_rerun2/components/color.py | 6 ++-- .../rerun/_rerun2/components/draw_order.py | 6 ++-- .../rerun/_rerun2/components/fuzzy.py | 7 +++-- .../rerun/_rerun2/components/instance_key.py | 10 +++--- .../rerun/_rerun2/components/keypoint_id.py | 6 ++-- .../rerun/_rerun2/components/label.py | 12 ++++--- .../rerun/_rerun2/components/point2d.py | 10 +++--- .../rerun/_rerun2/components/radius.py | 10 +++--- .../rerun/_rerun2/datatypes/__init__.py | 6 ++-- .../rerun/_rerun2/datatypes/fuzzy.py | 7 +++-- .../rerun/_rerun2/datatypes/vec2d.py | 11 ++++--- 18 files changed, 91 insertions(+), 60 deletions(-) diff --git a/crates/re_types/source_hash.txt b/crates/re_types/source_hash.txt index 41a3145d0e8f..2edfdc1adebe 100644 --- a/crates/re_types/source_hash.txt +++ b/crates/re_types/source_hash.txt @@ -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. -c0d06250415f4b910072a218e82b969fb33ebca44ef59d544373439d6bb135f1 \ No newline at end of file +2482cd3e136880416056a88c296bd419d5b01626d2db3914e5e375c614123bcc \ No newline at end of file diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/__init__.py b/rerun_py/rerun_sdk/rerun/_rerun2/__init__.py index 436e54dd125e..73c8a2dc7112 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/__init__.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/__init__.py @@ -4,4 +4,4 @@ __all__ = ["AffixFuzzer1", "Points2D"] -from .archetypes import AffixFuzzer1, Points2D +from .archetypes import Points2D, AffixFuzzer1 diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/__init__.py b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/__init__.py index b718bbc1bf28..1bd74d06b5b7 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/__init__.py @@ -5,5 +5,6 @@ __all__ = ["Archetype", "AffixFuzzer1", "Points2D"] from .._baseclasses import Archetype + from .fuzzy import AffixFuzzer1 from .points2d import Points2D diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py index 131509f65096..31d992f31c55 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py @@ -2,7 +2,12 @@ from __future__ import annotations +import numpy as np +import numpy.typing as npt +import pyarrow as pa + from dataclasses import dataclass, field +from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union from .._baseclasses import Archetype diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py index 137fefc78fd3..12901cf23e10 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py @@ -2,7 +2,12 @@ from __future__ import annotations +import numpy as np +import numpy.typing as npt +import pyarrow as pa + from dataclasses import dataclass, field +from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union from .._baseclasses import Archetype @@ -15,7 +20,9 @@ @dataclass class Points2D(Archetype): - """A 2D point cloud with positions and optional colors, radii, labels, etc.""" + """ + A 2D point cloud with positions and optional colors, radii, labels, etc. + """ points: components.Point2DArray = field(metadata={"component": "primary"}) """ diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py index 544020ec3748..b0ab76ccb65d 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py @@ -82,48 +82,49 @@ ] from .._baseclasses import Component -from .class_id import ClassId, ClassIdArray, ClassIdArrayLike, ClassIdLike, ClassIdType -from .color import Color, ColorArray, ColorArrayLike, ColorLike, ColorType -from .draw_order import DrawOrder, DrawOrderArray, DrawOrderArrayLike, DrawOrderLike, DrawOrderType + +from .point2d import Point2D, Point2DLike, Point2DArray, Point2DArrayLike, Point2DType +from .color import Color, ColorLike, ColorArray, ColorArrayLike, ColorType from .fuzzy import ( AffixFuzzer1, + AffixFuzzer1Like, AffixFuzzer1Array, AffixFuzzer1ArrayLike, - AffixFuzzer1Like, AffixFuzzer1Type, AffixFuzzer2, + AffixFuzzer2Like, AffixFuzzer2Array, AffixFuzzer2ArrayLike, - AffixFuzzer2Like, AffixFuzzer2Type, AffixFuzzer3, + AffixFuzzer3Like, AffixFuzzer3Array, AffixFuzzer3ArrayLike, - AffixFuzzer3Like, AffixFuzzer3Type, AffixFuzzer4, + AffixFuzzer4Like, AffixFuzzer4Array, AffixFuzzer4ArrayLike, - AffixFuzzer4Like, AffixFuzzer4Type, AffixFuzzer5, + AffixFuzzer5Like, AffixFuzzer5Array, AffixFuzzer5ArrayLike, - AffixFuzzer5Like, AffixFuzzer5Type, AffixFuzzer6, + AffixFuzzer6Like, AffixFuzzer6Array, AffixFuzzer6ArrayLike, - AffixFuzzer6Like, AffixFuzzer6Type, AffixFuzzer7, + AffixFuzzer7Like, AffixFuzzer7Array, AffixFuzzer7ArrayLike, - AffixFuzzer7Like, AffixFuzzer7Type, ) -from .instance_key import InstanceKey, InstanceKeyArray, InstanceKeyArrayLike, InstanceKeyLike, InstanceKeyType -from .keypoint_id import KeypointId, KeypointIdArray, KeypointIdArrayLike, KeypointIdLike, KeypointIdType -from .label import Label, LabelArray, LabelArrayLike, LabelLike, LabelType -from .point2d import Point2D, Point2DArray, Point2DArrayLike, Point2DLike, Point2DType -from .radius import Radius, RadiusArray, RadiusArrayLike, RadiusLike, RadiusType +from .draw_order import DrawOrder, DrawOrderLike, DrawOrderArray, DrawOrderArrayLike, DrawOrderType +from .keypoint_id import KeypointId, KeypointIdLike, KeypointIdArray, KeypointIdArrayLike, KeypointIdType +from .class_id import ClassId, ClassIdLike, ClassIdArray, ClassIdArrayLike, ClassIdType +from .instance_key import InstanceKey, InstanceKeyLike, InstanceKeyArray, InstanceKeyArrayLike, InstanceKeyType +from .label import Label, LabelLike, LabelArray, LabelArrayLike, LabelType +from .radius import Radius, RadiusLike, RadiusArray, RadiusArrayLike, RadiusType diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py index 9b62102c302f..d5f00200c7d5 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py @@ -2,13 +2,13 @@ from __future__ import annotations -from dataclasses import dataclass -from typing import Any, Sequence, Union - import numpy as np import numpy.typing as npt import pyarrow as pa +from dataclasses import dataclass, field +from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union + from .._baseclasses import Component __all__ = ["ClassId", "ClassIdArray", "ClassIdArrayLike", "ClassIdLike", "ClassIdType"] @@ -19,7 +19,9 @@ @dataclass class ClassId: - """A 16-bit ID representing a type of semantic class.""" + """ + A 16-bit ID representing a type of semantic class. + """ id: int diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py index 76fc3e37c376..df5a7c9f8286 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py @@ -2,13 +2,13 @@ from __future__ import annotations -from dataclasses import dataclass -from typing import Any, Sequence, Union - import numpy as np import numpy.typing as npt import pyarrow as pa +from dataclasses import dataclass, field +from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union + from .._baseclasses import Component __all__ = ["Color", "ColorArray", "ColorArrayLike", "ColorLike", "ColorType"] diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py index 59335a0c4143..2b716abe6091 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py @@ -2,13 +2,13 @@ from __future__ import annotations -from dataclasses import dataclass -from typing import Any, Sequence, Union - import numpy as np import numpy.typing as npt import pyarrow as pa +from dataclasses import dataclass, field +from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union + from .._baseclasses import Component __all__ = ["DrawOrder", "DrawOrderArray", "DrawOrderArrayLike", "DrawOrderLike", "DrawOrderType"] diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py index 24e4de7d4737..ff648e967427 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py @@ -2,12 +2,13 @@ from __future__ import annotations -from dataclasses import dataclass -from typing import Any, Sequence, Union - +import numpy as np import numpy.typing as npt import pyarrow as pa +from dataclasses import dataclass, field +from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union + from .._baseclasses import Component __all__ = [ diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py index 10a85e14daa1..ae92e4f41c5d 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py @@ -2,13 +2,13 @@ from __future__ import annotations -from dataclasses import dataclass -from typing import Any, Sequence, Union - import numpy as np import numpy.typing as npt import pyarrow as pa +from dataclasses import dataclass, field +from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union + from .._baseclasses import Component __all__ = ["InstanceKey", "InstanceKeyArray", "InstanceKeyArrayLike", "InstanceKeyLike", "InstanceKeyType"] @@ -19,7 +19,9 @@ @dataclass class InstanceKey: - """A unique numeric identifier for each individual instance within a batch.""" + """ + A unique numeric identifier for each individual instance within a batch. + """ value: int diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py index e53b0bcb6764..b87942706b29 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py @@ -2,13 +2,13 @@ from __future__ import annotations -from dataclasses import dataclass -from typing import Any, Sequence, Union - import numpy as np import numpy.typing as npt import pyarrow as pa +from dataclasses import dataclass, field +from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union + from .._baseclasses import Component __all__ = ["KeypointId", "KeypointIdArray", "KeypointIdArrayLike", "KeypointIdLike", "KeypointIdType"] diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py index b88d61613761..e0d61814c730 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py @@ -2,11 +2,13 @@ from __future__ import annotations -from dataclasses import dataclass -from typing import Any, Sequence, Union - +import numpy as np +import numpy.typing as npt import pyarrow as pa +from dataclasses import dataclass, field +from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union + from .._baseclasses import Component __all__ = ["Label", "LabelArray", "LabelArrayLike", "LabelLike", "LabelType"] @@ -17,7 +19,9 @@ @dataclass class Label: - """A String label component.""" + """ + A String label component. + """ value: str diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py index e456b9791440..6085a76b97bb 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py @@ -2,13 +2,13 @@ from __future__ import annotations -from dataclasses import dataclass -from typing import Any, Sequence, Tuple, Union - import numpy as np import numpy.typing as npt import pyarrow as pa +from dataclasses import dataclass, field +from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union + from .._baseclasses import Component __all__ = ["Point2D", "Point2DArray", "Point2DArrayLike", "Point2DLike", "Point2DType"] @@ -19,7 +19,9 @@ @dataclass class Point2D: - """A point in 2D space.""" + """ + A point in 2D space. + """ x: float y: float diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py index 407755538e74..a917241c39f3 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py @@ -2,13 +2,13 @@ from __future__ import annotations -from dataclasses import dataclass -from typing import Any, Sequence, Union - import numpy as np import numpy.typing as npt import pyarrow as pa +from dataclasses import dataclass, field +from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union + from .._baseclasses import Component __all__ = ["Radius", "RadiusArray", "RadiusArrayLike", "RadiusLike", "RadiusType"] @@ -19,7 +19,9 @@ @dataclass class Radius: - """A Radius component.""" + """ + A Radius component. + """ value: float diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/__init__.py b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/__init__.py index cec81dfa19cf..f0a5aa33916f 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/__init__.py @@ -23,14 +23,14 @@ from .fuzzy import ( AffixFuzzer1, + AffixFuzzer1Like, AffixFuzzer1Array, AffixFuzzer1ArrayLike, - AffixFuzzer1Like, AffixFuzzer1Type, AffixFuzzer2, + AffixFuzzer2Like, AffixFuzzer2Array, AffixFuzzer2ArrayLike, - AffixFuzzer2Like, AffixFuzzer2Type, ) -from .vec2d import Vec2D, Vec2DArray, Vec2DArrayLike, Vec2DLike, Vec2DType +from .vec2d import Vec2D, Vec2DLike, Vec2DArray, Vec2DArrayLike, Vec2DType diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py index f095027ea27e..796c186ee1b3 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py @@ -2,13 +2,14 @@ from __future__ import annotations -from dataclasses import dataclass -from typing import Any, Sequence, Union - import numpy as np import numpy.typing as npt import pyarrow as pa +from dataclasses import dataclass, field +from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union + + __all__ = [ "AffixFuzzer1", "AffixFuzzer1Array", diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/vec2d.py b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/vec2d.py index 14aa1d0a2a1c..ba9e38373ecb 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/vec2d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/vec2d.py @@ -2,13 +2,14 @@ from __future__ import annotations -from dataclasses import dataclass -from typing import Any, Sequence, Union - import numpy as np import numpy.typing as npt import pyarrow as pa +from dataclasses import dataclass, field +from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union + + __all__ = ["Vec2D", "Vec2DArray", "Vec2DArrayLike", "Vec2DLike", "Vec2DType"] @@ -17,7 +18,9 @@ @dataclass class Vec2D: - """A vector in 2D space.""" + """ + A vector in 2D space. + """ xy: npt.ArrayLike From 710776012317cf7cb5c7c7ca0adbb045a135e36f Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Mon, 3 Jul 2023 12:17:53 +0200 Subject: [PATCH 14/14] Re-codegen --- rerun_py/rerun_sdk/rerun/_rerun2/__init__.py | 2 +- .../rerun/_rerun2/archetypes/__init__.py | 1 - .../rerun/_rerun2/archetypes/fuzzy.py | 5 --- .../rerun/_rerun2/archetypes/points2d.py | 9 +----- .../rerun/_rerun2/components/__init__.py | 31 +++++++++---------- .../rerun/_rerun2/components/class_id.py | 10 +++--- .../rerun/_rerun2/components/color.py | 6 ++-- .../rerun/_rerun2/components/draw_order.py | 6 ++-- .../rerun/_rerun2/components/fuzzy.py | 7 ++--- .../rerun/_rerun2/components/instance_key.py | 10 +++--- .../rerun/_rerun2/components/keypoint_id.py | 6 ++-- .../rerun/_rerun2/components/label.py | 12 +++---- .../rerun/_rerun2/components/point2d.py | 10 +++--- .../rerun/_rerun2/components/radius.py | 10 +++--- .../rerun/_rerun2/datatypes/__init__.py | 6 ++-- .../rerun/_rerun2/datatypes/fuzzy.py | 7 ++--- .../rerun/_rerun2/datatypes/vec2d.py | 11 +++---- 17 files changed, 59 insertions(+), 90 deletions(-) diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/__init__.py b/rerun_py/rerun_sdk/rerun/_rerun2/__init__.py index 73c8a2dc7112..436e54dd125e 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/__init__.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/__init__.py @@ -4,4 +4,4 @@ __all__ = ["AffixFuzzer1", "Points2D"] -from .archetypes import Points2D, AffixFuzzer1 +from .archetypes import AffixFuzzer1, Points2D diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/__init__.py b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/__init__.py index 1bd74d06b5b7..b718bbc1bf28 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/__init__.py @@ -5,6 +5,5 @@ __all__ = ["Archetype", "AffixFuzzer1", "Points2D"] from .._baseclasses import Archetype - from .fuzzy import AffixFuzzer1 from .points2d import Points2D diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py index 31d992f31c55..131509f65096 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py @@ -2,12 +2,7 @@ from __future__ import annotations -import numpy as np -import numpy.typing as npt -import pyarrow as pa - from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union from .._baseclasses import Archetype diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py index 12901cf23e10..137fefc78fd3 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py @@ -2,12 +2,7 @@ from __future__ import annotations -import numpy as np -import numpy.typing as npt -import pyarrow as pa - from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union from .._baseclasses import Archetype @@ -20,9 +15,7 @@ @dataclass class Points2D(Archetype): - """ - A 2D point cloud with positions and optional colors, radii, labels, etc. - """ + """A 2D point cloud with positions and optional colors, radii, labels, etc.""" points: components.Point2DArray = field(metadata={"component": "primary"}) """ diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py index b0ab76ccb65d..544020ec3748 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py @@ -82,49 +82,48 @@ ] from .._baseclasses import Component - -from .point2d import Point2D, Point2DLike, Point2DArray, Point2DArrayLike, Point2DType -from .color import Color, ColorLike, ColorArray, ColorArrayLike, ColorType +from .class_id import ClassId, ClassIdArray, ClassIdArrayLike, ClassIdLike, ClassIdType +from .color import Color, ColorArray, ColorArrayLike, ColorLike, ColorType +from .draw_order import DrawOrder, DrawOrderArray, DrawOrderArrayLike, DrawOrderLike, DrawOrderType from .fuzzy import ( AffixFuzzer1, - AffixFuzzer1Like, AffixFuzzer1Array, AffixFuzzer1ArrayLike, + AffixFuzzer1Like, AffixFuzzer1Type, AffixFuzzer2, - AffixFuzzer2Like, AffixFuzzer2Array, AffixFuzzer2ArrayLike, + AffixFuzzer2Like, AffixFuzzer2Type, AffixFuzzer3, - AffixFuzzer3Like, AffixFuzzer3Array, AffixFuzzer3ArrayLike, + AffixFuzzer3Like, AffixFuzzer3Type, AffixFuzzer4, - AffixFuzzer4Like, AffixFuzzer4Array, AffixFuzzer4ArrayLike, + AffixFuzzer4Like, AffixFuzzer4Type, AffixFuzzer5, - AffixFuzzer5Like, AffixFuzzer5Array, AffixFuzzer5ArrayLike, + AffixFuzzer5Like, AffixFuzzer5Type, AffixFuzzer6, - AffixFuzzer6Like, AffixFuzzer6Array, AffixFuzzer6ArrayLike, + AffixFuzzer6Like, AffixFuzzer6Type, AffixFuzzer7, - AffixFuzzer7Like, AffixFuzzer7Array, AffixFuzzer7ArrayLike, + AffixFuzzer7Like, AffixFuzzer7Type, ) -from .draw_order import DrawOrder, DrawOrderLike, DrawOrderArray, DrawOrderArrayLike, DrawOrderType -from .keypoint_id import KeypointId, KeypointIdLike, KeypointIdArray, KeypointIdArrayLike, KeypointIdType -from .class_id import ClassId, ClassIdLike, ClassIdArray, ClassIdArrayLike, ClassIdType -from .instance_key import InstanceKey, InstanceKeyLike, InstanceKeyArray, InstanceKeyArrayLike, InstanceKeyType -from .label import Label, LabelLike, LabelArray, LabelArrayLike, LabelType -from .radius import Radius, RadiusLike, RadiusArray, RadiusArrayLike, RadiusType +from .instance_key import InstanceKey, InstanceKeyArray, InstanceKeyArrayLike, InstanceKeyLike, InstanceKeyType +from .keypoint_id import KeypointId, KeypointIdArray, KeypointIdArrayLike, KeypointIdLike, KeypointIdType +from .label import Label, LabelArray, LabelArrayLike, LabelLike, LabelType +from .point2d import Point2D, Point2DArray, Point2DArrayLike, Point2DLike, Point2DType +from .radius import Radius, RadiusArray, RadiusArrayLike, RadiusLike, RadiusType diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py index d5f00200c7d5..9b62102c302f 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py @@ -2,13 +2,13 @@ from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Sequence, Union + import numpy as np import numpy.typing as npt import pyarrow as pa -from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union - from .._baseclasses import Component __all__ = ["ClassId", "ClassIdArray", "ClassIdArrayLike", "ClassIdLike", "ClassIdType"] @@ -19,9 +19,7 @@ @dataclass class ClassId: - """ - A 16-bit ID representing a type of semantic class. - """ + """A 16-bit ID representing a type of semantic class.""" id: int diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py index df5a7c9f8286..76fc3e37c376 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py @@ -2,13 +2,13 @@ from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Sequence, Union + import numpy as np import numpy.typing as npt import pyarrow as pa -from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union - from .._baseclasses import Component __all__ = ["Color", "ColorArray", "ColorArrayLike", "ColorLike", "ColorType"] diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py index 2b716abe6091..59335a0c4143 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/draw_order.py @@ -2,13 +2,13 @@ from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Sequence, Union + import numpy as np import numpy.typing as npt import pyarrow as pa -from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union - from .._baseclasses import Component __all__ = ["DrawOrder", "DrawOrderArray", "DrawOrderArrayLike", "DrawOrderLike", "DrawOrderType"] diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py index ff648e967427..24e4de7d4737 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py @@ -2,13 +2,12 @@ from __future__ import annotations -import numpy as np +from dataclasses import dataclass +from typing import Any, Sequence, Union + import numpy.typing as npt import pyarrow as pa -from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union - from .._baseclasses import Component __all__ = [ diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py index ae92e4f41c5d..10a85e14daa1 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/instance_key.py @@ -2,13 +2,13 @@ from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Sequence, Union + import numpy as np import numpy.typing as npt import pyarrow as pa -from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union - from .._baseclasses import Component __all__ = ["InstanceKey", "InstanceKeyArray", "InstanceKeyArrayLike", "InstanceKeyLike", "InstanceKeyType"] @@ -19,9 +19,7 @@ @dataclass class InstanceKey: - """ - A unique numeric identifier for each individual instance within a batch. - """ + """A unique numeric identifier for each individual instance within a batch.""" value: int diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py index b87942706b29..e53b0bcb6764 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py @@ -2,13 +2,13 @@ from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Sequence, Union + import numpy as np import numpy.typing as npt import pyarrow as pa -from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union - from .._baseclasses import Component __all__ = ["KeypointId", "KeypointIdArray", "KeypointIdArrayLike", "KeypointIdLike", "KeypointIdType"] diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py index e0d61814c730..b88d61613761 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/label.py @@ -2,12 +2,10 @@ from __future__ import annotations -import numpy as np -import numpy.typing as npt -import pyarrow as pa +from dataclasses import dataclass +from typing import Any, Sequence, Union -from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union +import pyarrow as pa from .._baseclasses import Component @@ -19,9 +17,7 @@ @dataclass class Label: - """ - A String label component. - """ + """A String label component.""" value: str diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py index 6085a76b97bb..e456b9791440 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py @@ -2,13 +2,13 @@ from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Sequence, Tuple, Union + import numpy as np import numpy.typing as npt import pyarrow as pa -from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union - from .._baseclasses import Component __all__ = ["Point2D", "Point2DArray", "Point2DArrayLike", "Point2DLike", "Point2DType"] @@ -19,9 +19,7 @@ @dataclass class Point2D: - """ - A point in 2D space. - """ + """A point in 2D space.""" x: float y: float diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py index a917241c39f3..407755538e74 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/radius.py @@ -2,13 +2,13 @@ from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Sequence, Union + import numpy as np import numpy.typing as npt import pyarrow as pa -from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union - from .._baseclasses import Component __all__ = ["Radius", "RadiusArray", "RadiusArrayLike", "RadiusLike", "RadiusType"] @@ -19,9 +19,7 @@ @dataclass class Radius: - """ - A Radius component. - """ + """A Radius component.""" value: float diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/__init__.py b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/__init__.py index f0a5aa33916f..cec81dfa19cf 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/__init__.py @@ -23,14 +23,14 @@ from .fuzzy import ( AffixFuzzer1, - AffixFuzzer1Like, AffixFuzzer1Array, AffixFuzzer1ArrayLike, + AffixFuzzer1Like, AffixFuzzer1Type, AffixFuzzer2, - AffixFuzzer2Like, AffixFuzzer2Array, AffixFuzzer2ArrayLike, + AffixFuzzer2Like, AffixFuzzer2Type, ) -from .vec2d import Vec2D, Vec2DLike, Vec2DArray, Vec2DArrayLike, Vec2DType +from .vec2d import Vec2D, Vec2DArray, Vec2DArrayLike, Vec2DLike, Vec2DType diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py index 796c186ee1b3..f095027ea27e 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py @@ -2,14 +2,13 @@ from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Sequence, Union + import numpy as np import numpy.typing as npt import pyarrow as pa -from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union - - __all__ = [ "AffixFuzzer1", "AffixFuzzer1Array", diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/vec2d.py b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/vec2d.py index ba9e38373ecb..14aa1d0a2a1c 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/vec2d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/vec2d.py @@ -2,14 +2,13 @@ from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Sequence, Union + import numpy as np import numpy.typing as npt import pyarrow as pa -from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Sequence, Set, Tuple, Union - - __all__ = ["Vec2D", "Vec2DArray", "Vec2DArrayLike", "Vec2DLike", "Vec2DType"] @@ -18,9 +17,7 @@ @dataclass class Vec2D: - """ - A vector in 2D space. - """ + """A vector in 2D space.""" xy: npt.ArrayLike