-
Notifications
You must be signed in to change notification settings - Fork 482
Archetype based overrides & defaults #9209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
2e8b494
to
24490ea
Compare
Web viewer built successfully. If applicable, you should also test it:
Note: This comment is updated whenever you push a commit. |
Latest documentation preview deployed successfully.
Note: This comment is updated whenever you push a commit. |
back to draft: Really unhappy with how I handled (Edit: Fixed, see updated description) |
a0c7254
to
b66ff13
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff!
crates/store/re_types/definitions/rerun/blueprint/archetypes/visualizer_overrides.fbs
Outdated
Show resolved
Hide resolved
### Related * Fixes #9059 ### What Defaults and overrides can now be set using archetypes. This not only leads to a much more ergonomic API with working auto-complete for archetype fields, but also paves the way for handling tagging in blueprint overrides/defaults which in the future will allow more fine grained defaults/overrides using the archetype "context information". ### Examples Setting default & override for radius Before: ```py rrb.Spatial2DView( name="Rect 1", origin="/", contents=["/**"], defaults=[rr.components.Radius(2)], overrides={"rect/0": [rr.components.Radius(1)]}, ) ``` After: ```py rrb.Spatial2DView( name="Rect 1", origin="/", contents=["/**"], defaults=[rr.Boxes2D.from_fields(radii=1)], overrides={"rect/0": rr.Boxes2D.from_fields(radii=2)}, ) ``` Setting up styles for a plot. Before: ```py rrb.TimeSeriesView( name="Trig", origin="/trig", overrides={ "/trig/sin": [rr.components.Color([255, 0, 0]), rr.components.Name("sin(0.01t)")], "/trig/cos": [rr.components.Color([0, 255, 0]), rr.components.Name("cos(0.01t)")], }, ), rrb.TimeSeriesView( name="Classification", origin="/classification", overrides={ "classification/line": [rr.components.Color([255, 255, 0]), rr.components.StrokeWidth(3.0)], "classification/samples": [rrb.VisualizerOverrides("SeriesPoint")], # This ensures that the `SeriesPoint` visualizers is used for this entity. }, ), ``` After: ```py rrb.TimeSeriesView( name="Trig", origin="/trig", overrides={ "/trig/sin": rr.SeriesLine.from_fields(color=[255, 0, 0], name="sin(0.01t)"), "/trig/cos": rr.SeriesLine.from_fields(color=[0, 255, 0], name="cos(0.01t)"), }, ), rrb.TimeSeriesView( name="Classification", origin="/classification", overrides={ "classification/line": rr.SeriesLine.from_fields(color=[255, 255, 0], width=3.0), "classification/samples": rrb.VisualizerOverrides("SeriesPoint"), # This ensures that the `SeriesPoint` visualizers is used for this entity. }, ), ``` --- ### Technical notes on corner cases There's two special cases that were loose component so far: * `VisualizerOverrides` * the former component becomes an archetype with a list of VisualizerOverride components each being a rerun.datatypes.Utf8. rerun.datatypes.Utf8List which was previously used goes away * `VisualTimeRange` * we _already_ have an archetype for this, it's called `VisualTimeRanges`. There's a bit of an ergonomic issue with this since `VisualTimeRanges` has to be constructed from one or more `VisualTimeRange`. But decided to enforce the archetype here. To avoid accidentally using the component instead of the datatype with the same name, I moved the component out and the datatype in to the rrb namespace --- * [x] go through override/default docs & associated snippets --------- Co-authored-by: Antoine Beyeler <[email protected]>
…9260) ### Related * Some more leftovers from #9209 ### What Snippets, a key aspect of our documentation, were not typed checked by mypy so far... 😱 No longer. This lead to several fixes in user-facing typing annotation in the python SDK. Plus the usual load of fixes in the snippets themselves. Note: snippets that are "not runnable" (as per `snippets.toml`) must now also be mypy-ignore in our `pyproject.toml`. I don't mind this added complexity a single second: make your snippets runnable! :)
Related
What
Defaults and overrides can now be set using archetypes. This not only leads to a much more ergonomic API with working auto-complete for archetype fields, but also paves the way for handling tagging in blueprint overrides/defaults which in the future will allow more fine grained defaults/overrides using the archetype "context information".
Examples
Setting default & override for radius
Before:
After:
Setting up styles for a plot.
Before:
After:
Technical notes on corner cases
There's two special cases that were loose component so far:
VisualizerOverrides
VisualTimeRange
VisualTimeRanges
. There's a bit of an ergonomic issue with this sinceVisualTimeRanges
has to be constructed from one or moreVisualTimeRange
. But decided to enforce the archetype here. To avoid accidentally using the component instead of the datatype with the same name, I moved the component out and the datatype in to the rrb namespace