Skip to content
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

Generic component placeholders #7447

Merged
merged 5 commits into from
Oct 25, 2024
Merged

Conversation

Wumpf
Copy link
Member

@Wumpf Wumpf commented Sep 19, 2024

What

Introduces generic placeholders, allowing to..

  • leave out Default implementations in many cases
  • fearless request a placeholder because it's guaranteed to be available

Mostly for testing I removed a few known strange defaults:

  • Blob
  • ImageData
  • ShowLabels

.. and tested that all fallback & default displays work fine afterwards. Seemed robust!
I'm not doing a sweep over existing components because that would imply a lot more testing for changed behavior would be necessary and I don't see a lot of value in that right now.

Wrinkles:

  • component name must be registered. If that's not the case we're kinda lost, just like in other places in the code. The workaround here is that you get the placeholder for Null datatype
  • a bit excessive on the allocation side, some caching might be nice, then we could return references to arrow data instead of giving out boxes again. Unlikely to be an actual perf concern afaik

Checklist

  • I have read and agree to Contributor Guide and the Code of Conduct
  • I've included a screenshot or gif (if applicable)
  • I have tested the web demo (if applicable):
  • The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG
  • If applicable, add a new check to the release checklist!
  • If have noted any breaking changes to the log API in CHANGELOG.md and the migration guide

To run all checks from main, comment on the PR with @rerun-bot full-check.

@Wumpf Wumpf changed the title Andreas/automatic component placeholders Generic component placeholders Sep 19, 2024
@Wumpf Wumpf added the 🚜 refactor Change the code, not the functionality label Sep 19, 2024
@Wumpf Wumpf force-pushed the andreas/automatic-component-placeholders branch from f90a880 to 41ed32f Compare October 4, 2024 15:17
@Wumpf Wumpf force-pushed the andreas/automatic-component-placeholders branch from 41ed32f to 5696f01 Compare October 24, 2024 09:33
@Wumpf Wumpf changed the base branch from antoine/codegen-no-default to main October 24, 2024 09:33
@Wumpf Wumpf added the exclude from changelog PRs with this won't show up in CHANGELOG.md label Oct 24, 2024
@Wumpf Wumpf force-pushed the andreas/automatic-component-placeholders branch from 5696f01 to 77b6ca6 Compare October 24, 2024 13:09
@Wumpf Wumpf marked this pull request as ready for review October 24, 2024 13:17
Copy link
Member

@abey79 abey79 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

Comment on lines +164 to +173
/// Returns a placeholder value for a given component, solely identified by its name.
///
/// A placeholder is an array of the component type with a single element which takes on some default value.
/// It can be set as part of the reflection information, see [`re_types_core::reflection::ComponentReflection::custom_placeholder`].
/// Note that automatically generated placeholders ignore any extension types.
///
/// This requires the component name to be known by either datastore or blueprint store and
/// will return a placeholder for a nulltype otherwise, logging an error.
/// The rationale is that to get into this situation, we need to know of a component name for which
/// we don't have a datatype, meaning that we can't make any statement about what data this component should represent.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice

crates/viewer/re_viewer_context/src/viewer_context.rs Outdated Show resolved Hide resolved
Co-authored-by: Antoine Beyeler <49431240+abey79@users.noreply.github.com>
@Wumpf Wumpf merged commit 27ea795 into main Oct 25, 2024
9 of 17 checks passed
@Wumpf Wumpf deleted the andreas/automatic-component-placeholders branch October 25, 2024 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exclude from changelog PRs with this won't show up in CHANGELOG.md 🚜 refactor Change the code, not the functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix component reflection such as to not force the component to impl Default
2 participants