From 2a9ae36672d799eb73b3b902f2722de7f0291227 Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Tue, 15 Oct 2024 11:52:59 -0400 Subject: [PATCH 1/3] Add getters for entity_path, component_name, and index name --- rerun_py/rerun_bindings/rerun_bindings.pyi | 50 ++++++++++++++++++++++ rerun_py/src/dataframe.rs | 30 +++++++++++++ 2 files changed, 80 insertions(+) diff --git a/rerun_py/rerun_bindings/rerun_bindings.pyi b/rerun_py/rerun_bindings/rerun_bindings.pyi index 11e1f61423e6..100874dbb433 100644 --- a/rerun_py/rerun_bindings/rerun_bindings.pyi +++ b/rerun_py/rerun_bindings/rerun_bindings.pyi @@ -8,18 +8,68 @@ from .types import AnyColumn, ComponentLike, IndexValuesLike, ViewContentsLike class IndexColumnDescriptor: """A column containing the index values for when the component data was updated.""" + def name(self) -> str: + """ + The name of the index. + + This property is read-only. + """ + ... + class IndexColumnSelector: """A selector for an index column.""" def __init__(self, index: str): ... + def name(self) -> str: + """ + The name of the index. + + This property is read-only. + """ + ... class ComponentColumnDescriptor: """A column containing the component data.""" + @property + def entity_path(self) -> str: + """ + The entity path. + + This property is read-only. + """ + ... + + @property + def component_name(self) -> str: + """ + The component name. + + This property is read-only. + """ + ... + class ComponentColumnSelector: """A selector for a component column.""" def __init__(self, entity_path: str, component: ComponentLike): ... + @property + def entity_path(self) -> str: + """ + The entity path. + + This property is read-only. + """ + ... + + @property + def component_name(self) -> str: + """ + The component name. + + This property is read-only. + """ + ... class Schema: """The schema representing all columns in a [`Recording`][].""" diff --git a/rerun_py/src/dataframe.rs b/rerun_py/src/dataframe.rs index 32a0aedd8c12..caf1409b5858 100644 --- a/rerun_py/src/dataframe.rs +++ b/rerun_py/src/dataframe.rs @@ -52,6 +52,11 @@ impl PyIndexColumnDescriptor { fn __repr__(&self) -> String { format!("Index(timeline:{})", self.0.timeline.name()) } + + #[getter] + fn name(&self) -> &str { + self.0.timeline.name() + } } impl From for PyIndexColumnDescriptor { @@ -78,6 +83,11 @@ impl PyIndexColumnSelector { fn __repr__(&self) -> String { format!("Index(timeline:{})", self.0.timeline) } + + #[getter] + fn name(&self) -> &str { + &self.0.timeline + } } /// Python binding for [`ComponentColumnDescriptor`] @@ -105,6 +115,16 @@ impl PyComponentColumnDescriptor { fn __eq__(&self, other: &Self) -> bool { self.0 == other.0 } + + #[getter] + fn entity_path(&self) -> String { + self.0.entity_path.to_string() + } + + #[getter] + fn component_name(&self) -> &str { + &self.0.component_name + } } impl From for ComponentColumnDescriptor { @@ -135,6 +155,16 @@ impl PyComponentColumnSelector { self.0.entity_path, self.0.component_name ) } + + #[getter] + fn entity_path(&self) -> String { + self.0.entity_path.to_string() + } + + #[getter] + fn component_name(&self) -> &str { + &self.0.component_name + } } /// Python binding for [`AnyColumn`] type-alias. From 8fe0372785cce78cdda98aabe60f8d7f4a23cbc2 Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Tue, 15 Oct 2024 11:59:50 -0400 Subject: [PATCH 2/3] Unit test to verify we can inspect the schema contents --- rerun_py/tests/unit/test_dataframe.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/rerun_py/tests/unit/test_dataframe.py b/rerun_py/tests/unit/test_dataframe.py index 072542d239c9..0f09cdc029d4 100644 --- a/rerun_py/tests/unit/test_dataframe.py +++ b/rerun_py/tests/unit/test_dataframe.py @@ -95,6 +95,23 @@ def test_recording_info(self) -> None: assert self.recording.application_id() == APP_ID assert self.recording.recording_id() == str(RECORDING_ID) + def test_schema(self) -> None: + schema = self.recording.schema() + + assert len(schema.index_columns()) == 3 + # Points3DIndicator, Position3D, Color + assert len(schema.component_columns()) == 3 + + assert schema.index_columns()[0].name == "log_tick" + assert schema.index_columns()[1].name == "log_time" + assert schema.index_columns()[2].name == "my_index" + assert schema.component_columns()[0].entity_path == "/points" + assert schema.component_columns()[0].component_name == "rerun.components.Color" + assert schema.component_columns()[1].entity_path == "/points" + assert schema.component_columns()[1].component_name == "rerun.components.Points3DIndicator" + assert schema.component_columns()[2].entity_path == "/points" + assert schema.component_columns()[2].component_name == "rerun.components.Position3D" + def test_full_view(self) -> None: view = self.recording.view(index="my_index", contents="points") From 475ed5b5ddea0950af4977fb90b4b4d5d7ed88e8 Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Tue, 15 Oct 2024 12:12:23 -0400 Subject: [PATCH 3/3] Update signature checker for property-getters --- scripts/ci/python_check_signatures.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/ci/python_check_signatures.py b/scripts/ci/python_check_signatures.py index 41f303c39e77..4257173f39d3 100644 --- a/scripts/ci/python_check_signatures.py +++ b/scripts/ci/python_check_signatures.py @@ -112,6 +112,11 @@ def load_runtime_signatures(module_name: str) -> TotalSignature: class_def[method_name] = inspect.signature(method_obj) except Exception: pass + # Get property getters + for method_name, method_obj in inspect.getmembers( + obj, lambda o: o.__class__.__name__ == "getset_descriptor" + ): + class_def[method_name] = Signature(parameters=[Parameter("self", Parameter.POSITIONAL_ONLY)]) signatures[name] = class_def return signatures