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

Introduce AnyValues as an alternative to extension_components #3561

Merged
merged 11 commits into from
Oct 2, 2023

Conversation

jleibs
Copy link
Member

@jleibs jleibs commented Sep 29, 2023

What

The old ext= helper functions didn't match the new object APIs particularly well.

This migrates the code to a more object-oriented struct, currently called AnyValues.

Checklist

@jleibs jleibs marked this pull request as ready for review September 29, 2023 17:17
@jleibs jleibs changed the title Introduce AnyValue as an alternative to extension_components Introduce AnyValues as an alternative to extension_components Sep 29, 2023
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.

Looks great!

Is this supposed to play nice with datatypes? I tried this and it didn't work:

rr.log(
    "any_values",
    rr.AnyValues(pts=rr.datatypes.Vec2DBatch([(0, 1), (2, 3), (4, 5)])),
)

Either way, I guess it'd be nice to have a note about it in the docstring.

rerun_py/rerun_sdk/rerun/any_value.py Outdated Show resolved Hide resolved
@jleibs
Copy link
Member Author

jleibs commented Oct 2, 2023

Is this supposed to play nice with datatypes? I tried this and it didn't work.

I hadn't though of doing that, but it's a great idea. No reason not to.

@jleibs jleibs merged commit a044f51 into main Oct 2, 2023
30 of 31 checks passed
@jleibs jleibs deleted the jleibs/any_value branch October 2, 2023 17:34
jleibs added a commit that referenced this pull request Oct 2, 2023
### What
- Builds on top of #3561

With `AnyValues` as a means of quickly creating arbitrary component
bundles, it's nice to be able to log these on a single line.

I briefly looked into adding `+` to components, but making it guaranteed
to play nicely with arbitrary user extension components introduced more
risk than I think it gained in clarity.

This simply allows `log` to consume any additional unnamed args as extra
sets of components which are merged into the logging set.

This replaces:
```
rr.log(
    "extra_values",
    rr.Points2D([[-1, -1], [-1, 1], [1, -1], [1, 1]]),
    ext={'confidence': [0.3, 0.4, 0.5, 0.6]}
)
```

With
```
rr.log(
    "extra_values",
    rr.Points2D([[-1, -1], [-1, 1], [1, -1], [1, 1]]),
    rr.AnyValues(
        confidence=[0.3, 0.4, 0.5, 0.6],
    ),
)
```

A bit more typing involved, but gets rid of special handling of an ext
keyword in a way that paves a much clearer path to users adding their
own custom components.

### 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 [demo.rerun.io](https://demo.rerun.io/pr/3562) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/3562)
- [Docs
preview](https://rerun.io/preview/0c41bf3abc4e9bfe1ea4af77a662bf2268e42162/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/0c41bf3abc4e9bfe1ea4af77a662bf2268e42162/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://ref.rerun.io/dev/bench/)
- [Wasm size tracking](https://ref.rerun.io/dev/sizes/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants