diff --git a/docs/content/reference/migration/migration-0-22.md b/docs/content/reference/migration/migration-0-22.md index 265b1876cadf..09806a9e8e56 100644 --- a/docs/content/reference/migration/migration-0-22.md +++ b/docs/content/reference/migration/migration-0-22.md @@ -1,9 +1,9 @@ --- -title: Migrating from 0.20 to 0.21 -order: 989 +title: Migrating from 0.21 to 0.22 +order: 988 --- -### Previously deprecated `DisconnectedSpace` archetype/component got now removed. +### Previously deprecated `DisconnectedSpace` archetype/component got now removed The deprecated `DisconnectedSpace` archetype and `DisconnectedSpace` component have been removed. To achieve the same effect, you can log any of the following "invalid" transforms: @@ -16,3 +16,12 @@ Previously, the `DisconnectedSpace` archetype played a double role by governing This led to a lot of complexity and often broke or caused confusion (see https://github.com/rerun-io/rerun/issues/6817, https://github.com/rerun-io/rerun/issues/4465, https://github.com/rerun-io/rerun/issues/4221). By now, explicit blueprints offer a better way to express which views should be spawned and what content they should query. (you can learn more about blueprints [here](https://rerun.io/docs/getting-started/configure-the-viewer/through-code-tutorial)). + + +### Removed `num_instances` keyword argument to `rr.log_components()` + +For historical reasons, the `rr.log_components()` function of the Python SDK accepts an optional, keyword-only argument `num_instances`. +It was no longer used for several releases, so we removed it. + +**Note**: although `rr.log_components()` is technically a public API, it is undocumented, and we discourage using it. +For logging custom components, use [`rr.AnyValue`](https://ref.rerun.io/docs/python/main/common/custom_data/#rerun.AnyValues) and [`rr.AnyBatchValue`](https://ref.rerun.io/docs/python/main/common/custom_data/#rerun.AnyBatchValue). diff --git a/rerun_py/rerun_sdk/rerun/_baseclasses.py b/rerun_py/rerun_sdk/rerun/_baseclasses.py index 9c5056e64c74..efe7b52852ca 100644 --- a/rerun_py/rerun_sdk/rerun/_baseclasses.py +++ b/rerun_py/rerun_sdk/rerun/_baseclasses.py @@ -147,13 +147,7 @@ def as_arrow_array(self) -> pa.Array: class AsComponents(Protocol): - """ - Describes interface for interpreting an object as a bundle of Components. - - Note: the `num_instances()` function is an optional part of this interface. The method does not need to be - implemented as it is only used after checking for its existence. (There is unfortunately no way to express this - correctly with the Python typing system, see ). - """ + """Describes interface for interpreting an object as a bundle of Components.""" def as_component_batches(self) -> Iterable[ComponentBatchLike]: """ @@ -198,22 +192,6 @@ def indicator(cls) -> ComponentBatchLike: return IndicatorComponentBatch(cls.archetype_name()) - def num_instances(self) -> int: - """ - The number of instances that make up the batch. - - Part of the `AsComponents` logging interface. - """ - num_instances = 0 - for fld in fields(type(self)): - if "component" in fld.metadata: - try: - num_instances = max(num_instances, len(getattr(self, fld.name))) - except TypeError: # Happens for indicator batches. - num_instances = max(num_instances, 1) - - return num_instances - def as_component_batches(self) -> Iterable[ComponentBatchLike]: """ Return all the component batches that make up the archetype. diff --git a/rerun_py/rerun_sdk/rerun/_log.py b/rerun_py/rerun_sdk/rerun/_log.py index 5dc405c4a4ac..b624e2ab3090 100644 --- a/rerun_py/rerun_sdk/rerun/_log.py +++ b/rerun_py/rerun_sdk/rerun/_log.py @@ -172,15 +172,9 @@ def log( f"but got {type(entity)} instead." ) - if hasattr(entity, "num_instances"): - num_instances = entity.num_instances() - else: - num_instances = None - log_components( entity_path=entity_path, components=components, - num_instances=num_instances, static=static, recording=recording, # NOLINT ) @@ -191,7 +185,6 @@ def log_components( entity_path: str | list[str], components: Iterable[ComponentBatchLike], *, - num_instances: int | None = None, timeless: bool = False, static: bool = False, recording: RecordingStream | None = None, @@ -216,11 +209,7 @@ def log_components( See for more on entity paths. components: - A collection of `ComponentBatchLike` objects that - - num_instances: - Optional. The number of instances in each batch. If not provided, the max of all - components will be used instead. + A collection of `ComponentBatchLike` objects. timeless: Deprecated. Refer to `static` instead. @@ -263,9 +252,6 @@ def log_components( descriptors = [comp.component_descriptor() for comp in components] arrow_arrays = [comp.as_arrow_array() for comp in components] - if num_instances is None: - num_instances = max(len(arr) for arr in arrow_arrays) - if isinstance(entity_path, list): entity_path = bindings.new_entity_path([str(part) for part in entity_path]) diff --git a/rerun_py/rerun_sdk/rerun/components/view_coordinates_ext.py b/rerun_py/rerun_sdk/rerun/components/view_coordinates_ext.py index abc1559fde84..c98b7d1ad6fe 100644 --- a/rerun_py/rerun_sdk/rerun/components/view_coordinates_ext.py +++ b/rerun_py/rerun_sdk/rerun/components/view_coordinates_ext.py @@ -36,10 +36,6 @@ def as_component_batches(self) -> Iterable[ComponentBatchLike]: return ViewCoordinates(cast(ViewCoordinatesComponent, self)).as_component_batches() - def num_instances(self) -> int: - # Always a mono-component - return 1 - # # This section is generated by running `scripts/generate_view_coordinate_defs.py --python` # The following declarations are replaced in `deferred_patch_class`.