From 580101e88ecd7da899ab8d99f566aff67d5ce0ec Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Wed, 13 Sep 2023 10:22:36 -0400 Subject: [PATCH] Create objects for delegating components (#3303) ### What Builds on top of: https://github.com/rerun-io/rerun/pull/3302 One of the items raised by https://github.com/rerun-io/rerun/issues/3268 was wanting to extend a component type. But components previously had no instantiation. This PR creates Component objects that derive from their baseclass as well as the extension class. These can be used anywhere the datatype could be used instead. Example with TextLogLevel: ``` >>> rr2.TextLog(body="Hello", level=rr2.cmp.TextLogLevel.WARN) rr.TextLog( rerun.label( ['Hello'] ) rerun.components.TextLogLevel( ['WARN'] ) rerun.colorrgba( [] ) ) >>> rr2.TextLog(body="World", level=rr2.cmp.TextLogLevel("my custom level")) rr.TextLog( rerun.label( ['World'] ) rerun.components.TextLogLevel( ['my custom level'] ) rerun.colorrgba( [] ) ) ``` ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) * [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/3303) (if applicable) - [PR Build Summary](https://build.rerun.io/pr/3303) - [Docs preview](https://rerun.io/preview/177f58319e85da35d223c1fd0a109d35fbc7bd03/docs) - [Examples preview](https://rerun.io/preview/177f58319e85da35d223c1fd0a109d35fbc7bd03/examples) - [Recent benchmark results](https://ref.rerun.io/dev/bench/) - [Wasm size tracking](https://ref.rerun.io/dev/sizes/) --- crates/re_types/source_hash.txt | 2 +- crates/re_types_builder/src/codegen/python.rs | 177 ++++++++++-------- .../rerun/_rerun2/components/__init__.py | 69 ++++--- .../components/_overrides/text_log_level.py | 21 --- .../rerun/_rerun2/components/affix_fuzzer1.py | 9 +- .../_rerun2/components/affix_fuzzer14.py | 9 +- .../_rerun2/components/affix_fuzzer15.py | 9 +- .../_rerun2/components/affix_fuzzer19.py | 9 +- .../rerun/_rerun2/components/affix_fuzzer2.py | 9 +- .../_rerun2/components/affix_fuzzer20.py | 9 +- .../rerun/_rerun2/components/affix_fuzzer3.py | 9 +- .../rerun/_rerun2/components/affix_fuzzer4.py | 9 +- .../rerun/_rerun2/components/affix_fuzzer5.py | 9 +- .../rerun/_rerun2/components/affix_fuzzer6.py | 9 +- .../rerun/_rerun2/components/class_id.py | 11 +- .../rerun/_rerun2/components/color.py | 20 +- .../rerun/_rerun2/components/half_sizes2d.py | 16 +- .../rerun/_rerun2/components/keypoint_id.py | 18 +- .../rerun/_rerun2/components/origin2d.py | 11 +- .../rerun/_rerun2/components/origin3d.py | 11 +- .../rerun/_rerun2/components/point2d.py | 11 +- .../rerun/_rerun2/components/point3d.py | 11 +- .../rerun/_rerun2/components/tensor_data.py | 9 +- .../rerun/_rerun2/components/text.py | 11 +- .../_rerun2/components/text_log_level.py | 22 ++- .../_rerun2/components/text_log_level_ext.py | 23 +++ .../rerun/_rerun2/components/transform3d.py | 11 +- .../rerun/_rerun2/components/vector3d.py | 11 +- 28 files changed, 413 insertions(+), 142 deletions(-) delete mode 100644 rerun_py/rerun_sdk/rerun/_rerun2/components/_overrides/text_log_level.py create mode 100644 rerun_py/rerun_sdk/rerun/_rerun2/components/text_log_level_ext.py diff --git a/crates/re_types/source_hash.txt b/crates/re_types/source_hash.txt index f65b09b9cb23..07a0c1f4f571 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. -7f79f30e96be92e3552437c4002d0f89aee9ab3cb5c04f8b0a68d712d0ea58fa +e5b4091795cf7d9702b7d034faa0d5338d99af69450b1c9e61f11fa8c8f9e9c7 diff --git a/crates/re_types_builder/src/codegen/python.rs b/crates/re_types_builder/src/codegen/python.rs index 72148f57fd2c..567ffd944520 100644 --- a/crates/re_types_builder/src/codegen/python.rs +++ b/crates/re_types_builder/src/codegen/python.rs @@ -277,7 +277,7 @@ impl PythonCodeGenerator { let name = &obj.name; if obj.is_delegating_component() { - vec![format!("{name}Array"), format!("{name}Type")] + vec![name.clone(), format!("{name}Array"), format!("{name}Type")] } else { vec![ format!("{name}"), @@ -516,10 +516,11 @@ fn code_for_struct( let mut code = String::new(); - if *kind != ObjectKind::Component || obj.is_non_delegating_component() { - // field converters preprocessing pass — must be performed here because we must autogen - // converter function *before* the class - let mut field_converters: HashMap = HashMap::new(); + // field converters preprocessing pass — must be performed here because we must autogen + // converter function *before* the class + let mut field_converters: HashMap = HashMap::new(); + + if !obj.is_delegating_component() { for field in fields { let (default_converter, converter_function) = quote_field_converter_from_field(obj, objects, field); @@ -552,88 +553,116 @@ fn code_for_struct( }; field_converters.insert(field.fqname.clone(), converter); } + } - // If the `ExtensionClass` has its own `__init__` then we need to pass the `init=False` argument - // to the `@define` decorator, to prevent it from generating its own `__init__`, which would - // take precedence over the `ExtensionClass`. - let old_init_override_name = format!("{}__init_override", obj.snake_case_name()); - let init_define_arg = if ext_class.has_init || overrides.contains(&old_init_override_name) { - "init=False".to_owned() - } else { - String::new() - }; + // If the `ExtensionClass` has its own `__init__` then we need to pass the `init=False` argument + // to the `@define` decorator, to prevent it from generating its own `__init__`, which would + // take precedence over the `ExtensionClass`. + let old_init_override_name = format!("{}__init_override", obj.snake_case_name()); + let init_define_arg = if ext_class.has_init || overrides.contains(&old_init_override_name) { + "init=False".to_owned() + } else { + String::new() + }; - let mut superclasses = vec![]; + let mut superclasses = vec![]; - if *kind == ObjectKind::Archetype { - superclasses.push("Archetype"); - } + if *kind == ObjectKind::Archetype { + superclasses.push("Archetype".to_owned()); + } - if ext_class.found { - superclasses.push(ext_class.name.as_str()); - } + if ext_class.found { + superclasses.push(ext_class.name.clone()); + } - let superclass_decl = if superclasses.is_empty() { - String::new() - } else { - format!("({})", superclasses.join(",")) - }; + // Delegating component inheritance comes after the `ExtensionClass` + // This way if a component needs to override `__init__` it still can. + if obj.is_delegating_component() { + superclasses.push(format!( + "datatypes.{}", + obj.delegate_datatype(objects).unwrap().name + )); + } - let define_args = if *kind == ObjectKind::Archetype { - format!( - "str=False, repr=False{}{init_define_arg}", - if init_define_arg.is_empty() { "" } else { ", " } - ) - } else { - init_define_arg - }; + let superclass_decl = if superclasses.is_empty() { + String::new() + } else { + format!("({})", superclasses.join(",")) + }; - let define_args = if define_args.is_empty() { - define_args - } else { - format!("({define_args})") - }; + let define_args = if *kind == ObjectKind::Archetype { + format!( + "str=False, repr=False{}{init_define_arg}", + if init_define_arg.is_empty() { "" } else { ", " } + ) + } else { + init_define_arg + }; - code.push_unindented_text( - format!( - r#" - @define{define_args} + let define_args = if define_args.is_empty() { + define_args + } else { + format!("({define_args})") + }; + + let define_decorator = if obj.is_delegating_component() { + String::new() + } else { + format!("@define{define_args}") + }; + + code.push_unindented_text( + format!( + r#" + {define_decorator} class {name}{superclass_decl}: "# - ), - 0, - ); + ), + 0, + ); - code.push_text(quote_doc_from_docs(docs), 0, 4); + code.push_text(quote_doc_from_docs(docs), 0, 4); - if ext_class.has_init { - code.push_text( - format!("# __init__ can be found in {}", ext_class.file_name), - 2, - 4, - ); - } else if overrides.contains(&old_init_override_name) { - code.push_text( - "def __init__(self, *args, **kwargs): #type: ignore[no-untyped-def]", - 1, - 4, - ); - code.push_text( - format!("{old_init_override_name}(self, *args, **kwargs)"), - 2, - 8, - ); - } else { - code.push_text( - format!( - "# You can define your own __init__ function as a member of {} in {}", - ext_class.name, ext_class.file_name - ), - 2, - 4, - ); - } + if ext_class.has_init { + code.push_text( + format!("# __init__ can be found in {}", ext_class.file_name), + 2, + 4, + ); + } else if overrides.contains(&old_init_override_name) { + code.push_text( + "def __init__(self, *args, **kwargs): #type: ignore[no-untyped-def]", + 1, + 4, + ); + code.push_text( + format!("{old_init_override_name}(self, *args, **kwargs)"), + 2, + 8, + ); + } else { + code.push_text( + format!( + "# You can define your own __init__ function as a member of {} in {}", + ext_class.name, ext_class.file_name + ), + 2, + 4, + ); + } + if obj.is_delegating_component() { + code.push_text( + format!( + "# Note: there are no fields here because {} delegates to datatypes.{}", + obj.name, + obj.delegate_datatype(objects).unwrap().name + ), + 1, + 4, + ); + code.push_text("pass", 2, 4); + } else { // NOTE: We need to add required fields first, and then optional ones, otherwise mypy // complains. // TODO(ab, #2641): this is required because fields without default should appear before fields diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py index 6c993ffaf7cf..863a13166754 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py @@ -2,12 +2,12 @@ from __future__ import annotations -from .affix_fuzzer1 import AffixFuzzer1Array, AffixFuzzer1Type -from .affix_fuzzer2 import AffixFuzzer2Array, AffixFuzzer2Type -from .affix_fuzzer3 import AffixFuzzer3Array, AffixFuzzer3Type -from .affix_fuzzer4 import AffixFuzzer4Array, AffixFuzzer4Type -from .affix_fuzzer5 import AffixFuzzer5Array, AffixFuzzer5Type -from .affix_fuzzer6 import AffixFuzzer6Array, AffixFuzzer6Type +from .affix_fuzzer1 import AffixFuzzer1, AffixFuzzer1Array, AffixFuzzer1Type +from .affix_fuzzer2 import AffixFuzzer2, AffixFuzzer2Array, AffixFuzzer2Type +from .affix_fuzzer3 import AffixFuzzer3, AffixFuzzer3Array, AffixFuzzer3Type +from .affix_fuzzer4 import AffixFuzzer4, AffixFuzzer4Array, AffixFuzzer4Type +from .affix_fuzzer5 import AffixFuzzer5, AffixFuzzer5Array, AffixFuzzer5Type +from .affix_fuzzer6 import AffixFuzzer6, AffixFuzzer6Array, AffixFuzzer6Type from .affix_fuzzer7 import AffixFuzzer7, AffixFuzzer7Array, AffixFuzzer7ArrayLike, AffixFuzzer7Like, AffixFuzzer7Type from .affix_fuzzer8 import AffixFuzzer8, AffixFuzzer8Array, AffixFuzzer8ArrayLike, AffixFuzzer8Like, AffixFuzzer8Type from .affix_fuzzer9 import AffixFuzzer9, AffixFuzzer9Array, AffixFuzzer9ArrayLike, AffixFuzzer9Like, AffixFuzzer9Type @@ -39,8 +39,8 @@ AffixFuzzer13Like, AffixFuzzer13Type, ) -from .affix_fuzzer14 import AffixFuzzer14Array, AffixFuzzer14Type -from .affix_fuzzer15 import AffixFuzzer15Array, AffixFuzzer15Type +from .affix_fuzzer14 import AffixFuzzer14, AffixFuzzer14Array, AffixFuzzer14Type +from .affix_fuzzer15 import AffixFuzzer15, AffixFuzzer15Array, AffixFuzzer15Type from .affix_fuzzer16 import ( AffixFuzzer16, AffixFuzzer16Array, @@ -62,8 +62,8 @@ AffixFuzzer18Like, AffixFuzzer18Type, ) -from .affix_fuzzer19 import AffixFuzzer19Array, AffixFuzzer19Type -from .affix_fuzzer20 import AffixFuzzer20Array, AffixFuzzer20Type +from .affix_fuzzer19 import AffixFuzzer19, AffixFuzzer19Array, AffixFuzzer19Type +from .affix_fuzzer20 import AffixFuzzer20, AffixFuzzer20Array, AffixFuzzer20Type from .annotation_context import ( AnnotationContext, AnnotationContextArray, @@ -71,7 +71,7 @@ AnnotationContextLike, AnnotationContextType, ) -from .class_id import ClassIdArray, ClassIdType +from .class_id import ClassId, ClassIdArray, ClassIdType from .clear_settings import ( ClearSettings, ClearSettingsArray, @@ -79,7 +79,7 @@ ClearSettingsLike, ClearSettingsType, ) -from .color import ColorArray, ColorType +from .color import Color, ColorArray, ColorType from .depth_meter import DepthMeter, DepthMeterArray, DepthMeterArrayLike, DepthMeterLike, DepthMeterType from .disconnected_space import ( DisconnectedSpace, @@ -89,23 +89,24 @@ DisconnectedSpaceType, ) from .draw_order import DrawOrder, DrawOrderArray, DrawOrderArrayLike, DrawOrderLike, DrawOrderType -from .half_sizes2d import HalfSizes2DArray, HalfSizes2DType +from .half_sizes2d import HalfSizes2D, HalfSizes2DArray, HalfSizes2DType from .instance_key import InstanceKey, InstanceKeyArray, InstanceKeyArrayLike, InstanceKeyLike, InstanceKeyType -from .keypoint_id import KeypointIdArray, KeypointIdType +from .keypoint_id import KeypointId, KeypointIdArray, KeypointIdType from .line_strip2d import LineStrip2D, LineStrip2DArray, LineStrip2DArrayLike, LineStrip2DLike, LineStrip2DType from .line_strip3d import LineStrip3D, LineStrip3DArray, LineStrip3DArrayLike, LineStrip3DLike, LineStrip3DType -from .origin2d import Origin2DArray, Origin2DType -from .origin3d import Origin3DArray, Origin3DType -from .point2d import Point2DArray, Point2DType -from .point3d import Point3DArray, Point3DType +from .origin2d import Origin2D, Origin2DArray, Origin2DType +from .origin3d import Origin3D, Origin3DArray, Origin3DType +from .point2d import Point2D, Point2DArray, Point2DType +from .point3d import Point3D, Point3DArray, Point3DType from .radius import Radius, RadiusArray, RadiusArrayLike, RadiusLike, RadiusType -from .tensor_data import TensorDataArray, TensorDataType -from .text import TextArray, TextType -from .text_log_level import TextLogLevelArray, TextLogLevelType -from .transform3d import Transform3DArray, Transform3DType -from .vector3d import Vector3DArray, Vector3DType +from .tensor_data import TensorData, TensorDataArray, TensorDataType +from .text import Text, TextArray, TextType +from .text_log_level import TextLogLevel, TextLogLevelArray, TextLogLevelType +from .transform3d import Transform3D, Transform3DArray, Transform3DType +from .vector3d import Vector3D, Vector3DArray, Vector3DType __all__ = [ + "AffixFuzzer1", "AffixFuzzer10", "AffixFuzzer10Array", "AffixFuzzer10ArrayLike", @@ -126,8 +127,10 @@ "AffixFuzzer13ArrayLike", "AffixFuzzer13Like", "AffixFuzzer13Type", + "AffixFuzzer14", "AffixFuzzer14Array", "AffixFuzzer14Type", + "AffixFuzzer15", "AffixFuzzer15Array", "AffixFuzzer15Type", "AffixFuzzer16", @@ -145,20 +148,27 @@ "AffixFuzzer18ArrayLike", "AffixFuzzer18Like", "AffixFuzzer18Type", + "AffixFuzzer19", "AffixFuzzer19Array", "AffixFuzzer19Type", "AffixFuzzer1Array", "AffixFuzzer1Type", + "AffixFuzzer2", + "AffixFuzzer20", "AffixFuzzer20Array", "AffixFuzzer20Type", "AffixFuzzer2Array", "AffixFuzzer2Type", + "AffixFuzzer3", "AffixFuzzer3Array", "AffixFuzzer3Type", + "AffixFuzzer4", "AffixFuzzer4Array", "AffixFuzzer4Type", + "AffixFuzzer5", "AffixFuzzer5Array", "AffixFuzzer5Type", + "AffixFuzzer6", "AffixFuzzer6Array", "AffixFuzzer6Type", "AffixFuzzer7", @@ -181,6 +191,7 @@ "AnnotationContextArrayLike", "AnnotationContextLike", "AnnotationContextType", + "ClassId", "ClassIdArray", "ClassIdType", "ClearSettings", @@ -188,6 +199,7 @@ "ClearSettingsArrayLike", "ClearSettingsLike", "ClearSettingsType", + "Color", "ColorArray", "ColorType", "DepthMeter", @@ -205,6 +217,7 @@ "DrawOrderArrayLike", "DrawOrderLike", "DrawOrderType", + "HalfSizes2D", "HalfSizes2DArray", "HalfSizes2DType", "InstanceKey", @@ -212,6 +225,7 @@ "InstanceKeyArrayLike", "InstanceKeyLike", "InstanceKeyType", + "KeypointId", "KeypointIdArray", "KeypointIdType", "LineStrip2D", @@ -224,12 +238,16 @@ "LineStrip3DArrayLike", "LineStrip3DLike", "LineStrip3DType", + "Origin2D", "Origin2DArray", "Origin2DType", + "Origin3D", "Origin3DArray", "Origin3DType", + "Point2D", "Point2DArray", "Point2DType", + "Point3D", "Point3DArray", "Point3DType", "Radius", @@ -237,14 +255,19 @@ "RadiusArrayLike", "RadiusLike", "RadiusType", + "TensorData", "TensorDataArray", "TensorDataType", + "Text", "TextArray", + "TextLogLevel", "TextLogLevelArray", "TextLogLevelType", "TextType", + "Transform3D", "Transform3DArray", "Transform3DType", + "Vector3D", "Vector3DArray", "Vector3DType", ] diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/_overrides/text_log_level.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/_overrides/text_log_level.py deleted file mode 100644 index 1f85eec700df..000000000000 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/_overrides/text_log_level.py +++ /dev/null @@ -1,21 +0,0 @@ -from __future__ import annotations - -from .. import TextLogLevelType - -setattr(TextLogLevelType, "CRITICAL", "CRITICAL") -TextLogLevelType.CRITICAL.__doc__ = """ Designates catastrophic failures. """ - -setattr(TextLogLevelType, "ERROR", "ERROR") -TextLogLevelType.ERROR.__doc__ = """ Designates very serious errors. """ - -setattr(TextLogLevelType, "WARN", "WARN") -TextLogLevelType.WARN.__doc__ = """ Designates hazardous situations. """ - -setattr(TextLogLevelType, "INFO", "INFO") -TextLogLevelType.INFO.__doc__ = """ Designates useful information. """ - -setattr(TextLogLevelType, "DEBUG", "DEBUG") -TextLogLevelType.DEBUG.__doc__ = """ Designates lower priority information. """ - -setattr(TextLogLevelType, "TRACE", "TRACE") -TextLogLevelType.TRACE.__doc__ = """ Designates very low priority, often extremely verbose, information. """ diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer1.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer1.py index 1a461214be8b..a92353d459b3 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer1.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer1.py @@ -11,7 +11,14 @@ BaseDelegatingExtensionType, ) -__all__ = ["AffixFuzzer1Array", "AffixFuzzer1Type"] +__all__ = ["AffixFuzzer1", "AffixFuzzer1Array", "AffixFuzzer1Type"] + + +class AffixFuzzer1(datatypes.AffixFuzzer1): + # You can define your own __init__ function as a member of AffixFuzzer1Ext in affix_fuzzer1_ext.py + + # Note: there are no fields here because AffixFuzzer1 delegates to datatypes.AffixFuzzer1 + pass class AffixFuzzer1Type(BaseDelegatingExtensionType): diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer14.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer14.py index 6a3ee1198163..20bf3cc962ee 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer14.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer14.py @@ -11,7 +11,14 @@ BaseDelegatingExtensionType, ) -__all__ = ["AffixFuzzer14Array", "AffixFuzzer14Type"] +__all__ = ["AffixFuzzer14", "AffixFuzzer14Array", "AffixFuzzer14Type"] + + +class AffixFuzzer14(datatypes.AffixFuzzer3): + # You can define your own __init__ function as a member of AffixFuzzer14Ext in affix_fuzzer14_ext.py + + # Note: there are no fields here because AffixFuzzer14 delegates to datatypes.AffixFuzzer3 + pass class AffixFuzzer14Type(BaseDelegatingExtensionType): diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer15.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer15.py index 58f791abcddf..9bdcb80efc93 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer15.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer15.py @@ -11,7 +11,14 @@ BaseDelegatingExtensionType, ) -__all__ = ["AffixFuzzer15Array", "AffixFuzzer15Type"] +__all__ = ["AffixFuzzer15", "AffixFuzzer15Array", "AffixFuzzer15Type"] + + +class AffixFuzzer15(datatypes.AffixFuzzer3): + # You can define your own __init__ function as a member of AffixFuzzer15Ext in affix_fuzzer15_ext.py + + # Note: there are no fields here because AffixFuzzer15 delegates to datatypes.AffixFuzzer3 + pass class AffixFuzzer15Type(BaseDelegatingExtensionType): diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer19.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer19.py index 38d48a3e33ff..9e7d1b1c2fc5 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer19.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer19.py @@ -11,7 +11,14 @@ BaseDelegatingExtensionType, ) -__all__ = ["AffixFuzzer19Array", "AffixFuzzer19Type"] +__all__ = ["AffixFuzzer19", "AffixFuzzer19Array", "AffixFuzzer19Type"] + + +class AffixFuzzer19(datatypes.AffixFuzzer5): + # You can define your own __init__ function as a member of AffixFuzzer19Ext in affix_fuzzer19_ext.py + + # Note: there are no fields here because AffixFuzzer19 delegates to datatypes.AffixFuzzer5 + pass class AffixFuzzer19Type(BaseDelegatingExtensionType): diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer2.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer2.py index 62b6aee5b0d9..8576244e8048 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer2.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer2.py @@ -11,7 +11,14 @@ BaseDelegatingExtensionType, ) -__all__ = ["AffixFuzzer2Array", "AffixFuzzer2Type"] +__all__ = ["AffixFuzzer2", "AffixFuzzer2Array", "AffixFuzzer2Type"] + + +class AffixFuzzer2(datatypes.AffixFuzzer1): + # You can define your own __init__ function as a member of AffixFuzzer2Ext in affix_fuzzer2_ext.py + + # Note: there are no fields here because AffixFuzzer2 delegates to datatypes.AffixFuzzer1 + pass class AffixFuzzer2Type(BaseDelegatingExtensionType): diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer20.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer20.py index 596424da3220..1a74ae5d7a88 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer20.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer20.py @@ -11,7 +11,14 @@ BaseDelegatingExtensionType, ) -__all__ = ["AffixFuzzer20Array", "AffixFuzzer20Type"] +__all__ = ["AffixFuzzer20", "AffixFuzzer20Array", "AffixFuzzer20Type"] + + +class AffixFuzzer20(datatypes.AffixFuzzer20): + # You can define your own __init__ function as a member of AffixFuzzer20Ext in affix_fuzzer20_ext.py + + # Note: there are no fields here because AffixFuzzer20 delegates to datatypes.AffixFuzzer20 + pass class AffixFuzzer20Type(BaseDelegatingExtensionType): diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer3.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer3.py index f693f9405f25..35fac3716e58 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer3.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer3.py @@ -11,7 +11,14 @@ BaseDelegatingExtensionType, ) -__all__ = ["AffixFuzzer3Array", "AffixFuzzer3Type"] +__all__ = ["AffixFuzzer3", "AffixFuzzer3Array", "AffixFuzzer3Type"] + + +class AffixFuzzer3(datatypes.AffixFuzzer1): + # You can define your own __init__ function as a member of AffixFuzzer3Ext in affix_fuzzer3_ext.py + + # Note: there are no fields here because AffixFuzzer3 delegates to datatypes.AffixFuzzer1 + pass class AffixFuzzer3Type(BaseDelegatingExtensionType): diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer4.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer4.py index cc18a5113e87..70eab78927c7 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer4.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer4.py @@ -11,7 +11,14 @@ BaseDelegatingExtensionType, ) -__all__ = ["AffixFuzzer4Array", "AffixFuzzer4Type"] +__all__ = ["AffixFuzzer4", "AffixFuzzer4Array", "AffixFuzzer4Type"] + + +class AffixFuzzer4(datatypes.AffixFuzzer1): + # You can define your own __init__ function as a member of AffixFuzzer4Ext in affix_fuzzer4_ext.py + + # Note: there are no fields here because AffixFuzzer4 delegates to datatypes.AffixFuzzer1 + pass class AffixFuzzer4Type(BaseDelegatingExtensionType): diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer5.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer5.py index a17b9e20bb41..f9389444ac29 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer5.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer5.py @@ -11,7 +11,14 @@ BaseDelegatingExtensionType, ) -__all__ = ["AffixFuzzer5Array", "AffixFuzzer5Type"] +__all__ = ["AffixFuzzer5", "AffixFuzzer5Array", "AffixFuzzer5Type"] + + +class AffixFuzzer5(datatypes.AffixFuzzer1): + # You can define your own __init__ function as a member of AffixFuzzer5Ext in affix_fuzzer5_ext.py + + # Note: there are no fields here because AffixFuzzer5 delegates to datatypes.AffixFuzzer1 + pass class AffixFuzzer5Type(BaseDelegatingExtensionType): diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer6.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer6.py index 5c7d832abba8..64275421a620 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer6.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/affix_fuzzer6.py @@ -11,7 +11,14 @@ BaseDelegatingExtensionType, ) -__all__ = ["AffixFuzzer6Array", "AffixFuzzer6Type"] +__all__ = ["AffixFuzzer6", "AffixFuzzer6Array", "AffixFuzzer6Type"] + + +class AffixFuzzer6(datatypes.AffixFuzzer1): + # You can define your own __init__ function as a member of AffixFuzzer6Ext in affix_fuzzer6_ext.py + + # Note: there are no fields here because AffixFuzzer6 delegates to datatypes.AffixFuzzer1 + pass class AffixFuzzer6Type(BaseDelegatingExtensionType): 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 e16b85cf846c..23742051e108 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/class_id.py @@ -11,7 +11,16 @@ BaseDelegatingExtensionType, ) -__all__ = ["ClassIdArray", "ClassIdType"] +__all__ = ["ClassId", "ClassIdArray", "ClassIdType"] + + +class ClassId(datatypes.ClassId): + """A 16-bit ID representing a type of semantic class.""" + + # You can define your own __init__ function as a member of ClassIdExt in class_id_ext.py + + # Note: there are no fields here because ClassId delegates to datatypes.ClassId + pass class ClassIdType(BaseDelegatingExtensionType): diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py index 31497d269cdb..df4bfbc9271c 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/color.py @@ -11,7 +11,25 @@ BaseDelegatingExtensionType, ) -__all__ = ["ColorArray", "ColorType"] +__all__ = ["Color", "ColorArray", "ColorType"] + + +class Color(datatypes.Color): + """ + An RGBA color with unmultiplied/separate alpha, in sRGB gamma space with linear alpha. + + The color is stored as a 32-bit integer, where the most significant + byte is `R` and the least significant byte is `A`. + + Float colors are assumed to be in 0-1 gamma sRGB space. + All other colors are assumed to be in 0-255 gamma sRGB space. + If there is an alpha, we assume it is in linear space, and separate (NOT pre-multiplied). + """ + + # You can define your own __init__ function as a member of ColorExt in color_ext.py + + # Note: there are no fields here because Color delegates to datatypes.Color + pass class ColorType(BaseDelegatingExtensionType): diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/half_sizes2d.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/half_sizes2d.py index c72bad3da27f..fe194318a4c6 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/half_sizes2d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/half_sizes2d.py @@ -11,7 +11,21 @@ BaseDelegatingExtensionType, ) -__all__ = ["HalfSizes2DArray", "HalfSizes2DType"] +__all__ = ["HalfSizes2D", "HalfSizes2DArray", "HalfSizes2DType"] + + +class HalfSizes2D(datatypes.Vec2D): + """ + Half-sizes (extents) of a 2D box along its local axis, starting at its local origin/center. + + The box extends both in negative and positive direction along each axis. + Negative sizes indicate that the box is flipped along the respective axis, but this has no effect on how it is displayed. + """ + + # You can define your own __init__ function as a member of HalfSizes2DExt in half_sizes2d_ext.py + + # Note: there are no fields here because HalfSizes2D delegates to datatypes.Vec2D + pass class HalfSizes2DType(BaseDelegatingExtensionType): 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 20d6f68b0d0c..1843c2479543 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/keypoint_id.py @@ -11,7 +11,23 @@ BaseDelegatingExtensionType, ) -__all__ = ["KeypointIdArray", "KeypointIdType"] +__all__ = ["KeypointId", "KeypointIdArray", "KeypointIdType"] + + +class KeypointId(datatypes.KeypointId): + """ + A 16-bit ID representing a type of semantic keypoint within a class. + + `KeypointId`s are only meaningful within the context of a [`rerun.components.ClassDescription`][]. + + Used to look up an [`rerun.components.AnnotationInfo`][] for a Keypoint within the + [`rerun.components.AnnotationContext`]. + """ + + # You can define your own __init__ function as a member of KeypointIdExt in keypoint_id_ext.py + + # Note: there are no fields here because KeypointId delegates to datatypes.KeypointId + pass class KeypointIdType(BaseDelegatingExtensionType): diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/origin2d.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/origin2d.py index 659fc42f3e7e..20b4d35f2e86 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/origin2d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/origin2d.py @@ -11,7 +11,16 @@ BaseDelegatingExtensionType, ) -__all__ = ["Origin2DArray", "Origin2DType"] +__all__ = ["Origin2D", "Origin2DArray", "Origin2DType"] + + +class Origin2D(datatypes.Vec2D): + """A point of origin in 2D space.""" + + # You can define your own __init__ function as a member of Origin2DExt in origin2d_ext.py + + # Note: there are no fields here because Origin2D delegates to datatypes.Vec2D + pass class Origin2DType(BaseDelegatingExtensionType): diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/origin3d.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/origin3d.py index d325e5e8508c..add337ea7790 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/origin3d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/origin3d.py @@ -11,7 +11,16 @@ BaseDelegatingExtensionType, ) -__all__ = ["Origin3DArray", "Origin3DType"] +__all__ = ["Origin3D", "Origin3DArray", "Origin3DType"] + + +class Origin3D(datatypes.Vec3D): + """A point of origin in 3D space.""" + + # You can define your own __init__ function as a member of Origin3DExt in origin3d_ext.py + + # Note: there are no fields here because Origin3D delegates to datatypes.Vec3D + pass class Origin3DType(BaseDelegatingExtensionType): diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py index 5e6533fb2678..8dd57deaa5eb 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/point2d.py @@ -11,7 +11,16 @@ BaseDelegatingExtensionType, ) -__all__ = ["Point2DArray", "Point2DType"] +__all__ = ["Point2D", "Point2DArray", "Point2DType"] + + +class Point2D(datatypes.Vec2D): + """A point in 2D space.""" + + # You can define your own __init__ function as a member of Point2DExt in point2d_ext.py + + # Note: there are no fields here because Point2D delegates to datatypes.Vec2D + pass class Point2DType(BaseDelegatingExtensionType): diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/point3d.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/point3d.py index e1a5eb2be487..4668658e6ea8 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/point3d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/point3d.py @@ -11,7 +11,16 @@ BaseDelegatingExtensionType, ) -__all__ = ["Point3DArray", "Point3DType"] +__all__ = ["Point3D", "Point3DArray", "Point3DType"] + + +class Point3D(datatypes.Vec3D): + """A point in 3D space.""" + + # You can define your own __init__ function as a member of Point3DExt in point3d_ext.py + + # Note: there are no fields here because Point3D delegates to datatypes.Vec3D + pass class Point3DType(BaseDelegatingExtensionType): diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/tensor_data.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/tensor_data.py index 50fd8dfa9703..43a7dcaa9434 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/tensor_data.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/tensor_data.py @@ -11,7 +11,14 @@ BaseDelegatingExtensionType, ) -__all__ = ["TensorDataArray", "TensorDataType"] +__all__ = ["TensorData", "TensorDataArray", "TensorDataType"] + + +class TensorData(datatypes.TensorData): + # You can define your own __init__ function as a member of TensorDataExt in tensor_data_ext.py + + # Note: there are no fields here because TensorData delegates to datatypes.TensorData + pass class TensorDataType(BaseDelegatingExtensionType): diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/text.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/text.py index e76162611e47..9ccf63cdca8e 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/text.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/text.py @@ -11,7 +11,16 @@ BaseDelegatingExtensionType, ) -__all__ = ["TextArray", "TextType"] +__all__ = ["Text", "TextArray", "TextType"] + + +class Text(datatypes.Utf8): + """A string of text, e.g. for labels and text documents.""" + + # You can define your own __init__ function as a member of TextExt in text_ext.py + + # Note: there are no fields here because Text delegates to datatypes.Utf8 + pass class TextType(BaseDelegatingExtensionType): diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/text_log_level.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/text_log_level.py index 2a3f88118127..472c678d0150 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/text_log_level.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/text_log_level.py @@ -10,8 +10,28 @@ BaseDelegatingExtensionArray, BaseDelegatingExtensionType, ) +from .text_log_level_ext import TextLogLevelExt -__all__ = ["TextLogLevelArray", "TextLogLevelType"] +__all__ = ["TextLogLevel", "TextLogLevelArray", "TextLogLevelType"] + + +class TextLogLevel(TextLogLevelExt, datatypes.Utf8): + """ + The severity level of a text log message. + + Recommended to be one of: + * `"CRITICAL"` + * `"ERROR"` + * `"WARN"` + * `"INFO"` + * `"DEBUG"` + * `"TRACE"` + """ + + # You can define your own __init__ function as a member of TextLogLevelExt in text_log_level_ext.py + + # Note: there are no fields here because TextLogLevel delegates to datatypes.Utf8 + pass class TextLogLevelType(BaseDelegatingExtensionType): diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/text_log_level_ext.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/text_log_level_ext.py new file mode 100644 index 000000000000..f02e25cba51b --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/text_log_level_ext.py @@ -0,0 +1,23 @@ +from __future__ import annotations + +from typing import Final + + +class TextLogLevelExt: + CRITICAL: Final = "CRITICAL" + """ Designates catastrophic failures. """ + + ERROR: Final = "ERROR" + """ Designates very serious errors. """ + + WARN: Final = "WARN" + """ Designates hazardous situations. """ + + INFO: Final = "INFO" + """ Designates useful information. """ + + DEBUG: Final = "DEBUG" + """ Designates lower priority information. """ + + TRACE: Final = "TRACE" + """ Designates very low priority, often extremely verbose, information. """ diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/transform3d.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/transform3d.py index f8d664ae8210..734ee384f14a 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/transform3d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/transform3d.py @@ -11,7 +11,16 @@ BaseDelegatingExtensionType, ) -__all__ = ["Transform3DArray", "Transform3DType"] +__all__ = ["Transform3D", "Transform3DArray", "Transform3DType"] + + +class Transform3D(datatypes.Transform3D): + """An affine transform between two 3D spaces, represented in a given direction.""" + + # You can define your own __init__ function as a member of Transform3DExt in transform3d_ext.py + + # Note: there are no fields here because Transform3D delegates to datatypes.Transform3D + pass class Transform3DType(BaseDelegatingExtensionType): diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/vector3d.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/vector3d.py index 074c0d644c98..5adbba4f08aa 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/vector3d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/vector3d.py @@ -11,7 +11,16 @@ BaseDelegatingExtensionType, ) -__all__ = ["Vector3DArray", "Vector3DType"] +__all__ = ["Vector3D", "Vector3DArray", "Vector3DType"] + + +class Vector3D(datatypes.Vec3D): + """A vector in 3D space.""" + + # You can define your own __init__ function as a member of Vector3DExt in vector3d_ext.py + + # Note: there are no fields here because Vector3D delegates to datatypes.Vec3D + pass class Vector3DType(BaseDelegatingExtensionType):