Skip to content

Commit

Permalink
Better organization of types so that they are importable
Browse files Browse the repository at this point in the history
  • Loading branch information
jleibs committed Sep 26, 2024
1 parent fe37c0d commit dd04745
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 19 deletions.
2 changes: 2 additions & 0 deletions rerun_py/rerun_bindings/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import TYPE_CHECKING, TypeAlias, Union

from .rerun_bindings import *
23 changes: 4 additions & 19 deletions rerun_py/rerun_bindings/rerun_bindings.pyi
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
from typing import Optional, Sequence, Union
from typing import Optional, Sequence

import pyarrow as pa
from rerun._baseclasses import ComponentMixin

AnyColumn = Union[
ControlColumnDescriptor,
TimeColumnDescriptor,
ComponentColumnDescriptor,
ControlColumnSelector,
TimeColumnSelector,
ComponentColumnSelector,
]

AnyComponentColumn = Union[
ComponentColumnDescriptor,
ComponentColumnSelector,
]

ComponentLike = Union[str, type[ComponentMixin]]
from .types import AnyColumn, AnyComponentColumn, ComponentLike

class ControlColumnDescriptor:
"""A control-level column such as `RowId`."""
Expand All @@ -44,7 +29,7 @@ class ComponentColumnDescriptor:
class ComponentColumnSelector:
"""A selector for a component column."""

def __init__(self, entity_path: str, component_type: ComponentLike): ...
def __new__(cls, entity_path: str, component_type: ComponentLike): ...
def with_dictionary_encoding(self) -> ComponentColumnSelector: ...

class Schema:
Expand All @@ -53,7 +38,7 @@ class Schema:
def control_columns(self) -> list[ControlColumnDescriptor]: ...
def time_columns(self) -> list[TimeColumnDescriptor]: ...
def component_columns(self) -> list[ComponentColumnDescriptor]: ...
def column_for(self, entity_path: str, ComponentLike) -> Optional[ComponentColumnDescriptor]: ...
def column_for(self, entity_path: str, component: ComponentLike) -> Optional[ComponentColumnDescriptor]: ...

class TimeRange:
"""A time range with a start and end time."""
Expand Down
32 changes: 32 additions & 0 deletions rerun_py/rerun_bindings/types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from __future__ import annotations

from typing import TYPE_CHECKING, TypeAlias, Union

if TYPE_CHECKING:
from rerun._baseclasses import ComponentMixin

from .rerun_bindings import (
ComponentColumnDescriptor as ComponentColumnDescriptor,
ComponentColumnSelector as ComponentColumnSelector,
ControlColumnDescriptor as ControlColumnDescriptor,
ControlColumnSelector as ControlColumnSelector,
TimeColumnDescriptor as TimeColumnDescriptor,
TimeColumnSelector as TimeColumnSelector,
)


ComponentLike: TypeAlias = Union[str, type["ComponentMixin"]]

AnyColumn: TypeAlias = Union[
"ControlColumnDescriptor",
"TimeColumnDescriptor",
"ComponentColumnDescriptor",
"ControlColumnSelector",
"TimeColumnSelector",
"ComponentColumnSelector",
]

AnyComponentColumn: TypeAlias = Union[
"ComponentColumnDescriptor",
"ComponentColumnSelector",
]
5 changes: 5 additions & 0 deletions rerun_py/rerun_sdk/rerun/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@
load_archive as load_archive,
load_recording as load_recording,
)
from rerun_bindings.types import (
AnyColumn as AnyColumn,
AnyComponentColumn as AnyComponentColumn,
ComponentLike as ComponentLike,
)

0 comments on commit dd04745

Please sign in to comment.