To make it more ergonomic for users to log their own types that are translated into Rerun archetypes, we should introduce a protocol that all archetypes implement:
from typing import Iterable, Protocol
class ComponentsGroup(Protocol): # TODO: find a better name than ComponentsGroup
def as_components(self) -> Iterable[rerun.Component]:
...
We should then make sure that
rr.log("path", SomeArchetype(a, b=b, c=c))
# is equivalent to (and even implemented by)
rr.log_components("path", SomeArchetype(a, b=b, c=c).as_components())
That way, if a user already has a type MyPointCloud in their code, they can log it as
point_cloud = MyPointCloud(...)
rr.log("path", point_cloud)
By letting MyPointCloud implement as_components(). Could in the simplest case be
class MyPointCloud:
...
def as_components(self) -> Iterable[rr.Component]:
rertun rr.Points3D(self.positions, ...).as_components()
TODO:
To make it more ergonomic for users to log their own types that are translated into Rerun archetypes, we should introduce a protocol that all archetypes implement:
We should then make sure that
That way, if a user already has a type
MyPointCloudin their code, they can log it asBy letting
MyPointCloudimplementas_components(). Could in the simplest case beTODO: