Skip to content

Commit

Permalink
Better handle redundant time ranges (#6306)
Browse files Browse the repository at this point in the history
### What

* Fixes #6276
* Better doc visibility
* Warn if a timeline is specified twice

Collateral:
* generate `__hash__` methods for trivial python classes
* fix issue with `pixi run py-test`

### 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 the web demo (if applicable):
* Using examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6306?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6306?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!

- [PR Build Summary](https://build.rerun.io/pr/6306)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.
  • Loading branch information
Wumpf committed May 14, 2024
1 parent 3ad7245 commit 15511fa
Show file tree
Hide file tree
Showing 39 changed files with 174 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ table VisibleTimeRanges (
) {
/// The time ranges to show for each timeline unless specified otherwise on a per-entity basis.
///
/// If a timeline is listed twice, the first entry will be used.
/// If a timeline is specified more than once, the first entry will be used.
ranges: [rerun.blueprint.components.VisibleTimeRange] ("attr.rerun.component_required", order: 1000);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ table Spatial2DView (
visual_bounds: rerun.blueprint.archetypes.VisualBounds (order: 2000);

/// Configures which range on each timeline is shown by this view (unless specified differently per entity).
///
/// If not specified, the default is to show the latest state of each component.
/// If a timeline is specified more than once, the first entry will be used.
time_ranges: rerun.blueprint.archetypes.VisibleTimeRanges (order: 10000);

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ table Spatial3DView (
background: rerun.blueprint.archetypes.Background (order: 1000);

/// Configures which range on each timeline is shown by this view (unless specified differently per entity).
///
/// If not specified, the default is to show the latest state of each component.
/// If a timeline is specified more than once, the first entry will be used.
time_ranges: rerun.blueprint.archetypes.VisibleTimeRanges (order: 10000);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ table TimeSeriesView (
plot_legend: rerun.blueprint.archetypes.PlotLegend (order: 2000);

/// Configures which range on each timeline is shown by this view (unless specified differently per entity).
///
/// If not specified, the default is to show the entire timeline.
/// If a timeline is specified more than once, the first entry will be used.
time_ranges: rerun.blueprint.archetypes.VisibleTimeRanges (order: 10000);
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/re_types/src/blueprint/views/spatial2d_view.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/re_types/src/blueprint/views/spatial3d_view.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/re_types/src/blueprint/views/time_series_view.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion crates/re_types_builder/src/codegen/python/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,7 @@ fn quote_array_method_from_obj(
))
}

/// Automatically implement `__str__`, `__int__`, or `__float__` method if the object has a single
/// Automatically implement `__str__`, `__int__`, or `__float__` as well as `__hash__` methods if the object has a single
/// field of the corresponding type that is not optional.
///
/// Only applies to datatypes and components.
Expand All @@ -1309,6 +1309,9 @@ fn quote_native_types_method_from_obj(objects: &Objects, obj: &Object) -> String
"
def __{typ}__(self) -> {typ}:
return {typ}(self.{field_name})
def __hash__(self) -> int:
return hash(self.{field_name})
",
))
}
Expand Down
7 changes: 5 additions & 2 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,16 @@ pip = ">=23"
# around that and executes `rerun` from the system shell within the context of the pixi environment.
rerun-from-path = "rerun"

# Duplicate of `py-build` but within the `wheel-test` environment.
py-build-wheel-test = { cmd = "pixi run -e wheel-test py-build" }

# Run the Python tests.
# Don't call this on CI - use `nox` to run tests on all supported Python versions instead.
py-test = { cmd = "python -m pytest -vv rerun_py/tests/unit", depends_on = [
"py-build",
"py-build-wheel-test",
] }
py-bench = { cmd = "python -m pytest -c rerun_py/pyproject.toml --benchmark-only", depends_on = [
"py-build",
"py-build-wheel-test",
] }

[feature.base.dependencies]
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from __future__ import annotations

from typing import Any

from ... import datatypes
from ...error_utils import _send_warning_or_raise, catch_and_log_exceptions


class VisibleTimeRangesExt:
"""Extension for [VisibleTimeRanges][rerun.blueprint.archetypes.VisibleTimeRanges]."""

def __init__(self: Any, ranges: datatypes.VisibleTimeRangeArrayLike):
"""
Create a new instance of the VisibleTimeRanges archetype.
Parameters
----------
ranges:
The time ranges to show for each timeline unless specified otherwise on a per-entity basis.
If a timeline is listed twice, a warning will be issued and the first entry will be used.
"""

if isinstance(ranges, datatypes.VisibleTimeRange):
ranges = [ranges]

timelines = set()
for range in ranges:
if range.timeline in timelines:
_send_warning_or_raise(
f"Warning: Timeline {range.timeline} is listed twice in the list of visible time ranges. Only the first entry will be used.",
1,
)
timelines.add(range.timeline)

with catch_and_log_exceptions(context=self.__class__.__name__):
self.__attrs_init__(ranges=ranges)
return
self.__attrs_clear__()
3 changes: 3 additions & 0 deletions rerun_py/rerun_sdk/rerun/blueprint/components/column_share.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions rerun_py/rerun_sdk/rerun/blueprint/components/grid_columns.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions rerun_py/rerun_sdk/rerun/blueprint/components/row_share.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions rerun_py/rerun_sdk/rerun/blueprint/views/spatial2d_view.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions rerun_py/rerun_sdk/rerun/blueprint/views/spatial3d_view.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions rerun_py/rerun_sdk/rerun/blueprint/views/time_series_view.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions rerun_py/rerun_sdk/rerun/components/depth_meter.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions rerun_py/rerun_sdk/rerun/components/draw_order.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions rerun_py/rerun_sdk/rerun/components/marker_size.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions rerun_py/rerun_sdk/rerun/components/radius.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions rerun_py/rerun_sdk/rerun/components/scalar.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions rerun_py/rerun_sdk/rerun/components/stroke_width.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions rerun_py/rerun_sdk/rerun/datatypes/class_id.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions rerun_py/rerun_sdk/rerun/datatypes/entity_path.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions rerun_py/rerun_sdk/rerun/datatypes/float32.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions rerun_py/rerun_sdk/rerun/datatypes/keypoint_id.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions rerun_py/rerun_sdk/rerun/datatypes/rgba32.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 15511fa

Please sign in to comment.