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

Python union serialization codegen #6258

Merged
merged 6 commits into from
May 8, 2024
Merged

Conversation

Wumpf
Copy link
Member

@Wumpf Wumpf commented May 7, 2024

What

Part of a train

This is fair chunk of:

In theory this should have been enough to be able to serialize Transform3D with generated code. However, I ran into native crashes in unrelated tests when trying to do so. Also, this requires shuffling around some other manual serialization code where we don't generate serialization for structs yet.

are you sure this works? Passes existing python test & comparison tests. For the new unit-union variants check the last part of the train.

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!

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

@Wumpf Wumpf added 🐍 Python API Python logging API do-not-merge Do not merge this PR codegen/idl exclude from changelog PRs with this won't show up in CHANGELOG.md labels May 7, 2024
@Wumpf Wumpf changed the title Andreas/python union codegen Python union serialization codegen May 7, 2024
Comment on lines 2085 to 2088
try:
iter(data) # type: ignore[arg-type]
except TypeError:
data = [data] # type: ignore[list-item]
Copy link
Member

Choose a reason for hiding this comment

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

This only works if none of the element-types themselves are iterable. Specifically I think this will cause a problem in the situation of a Union that has a string as a union-arm.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmm true. This is surprisingly tricky. For starters I can check for the union itself and any of its arms, but we might also want to check for all type aliases of each arm 😱

Copy link
Member Author

@Wumpf Wumpf May 8, 2024

Choose a reason for hiding this comment

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

how about 4cd630d

not doing type aliases of arms so far

Base automatically changed from andreas/union-unit-types to main May 8, 2024 08:52
Wumpf added a commit that referenced this pull request May 8, 2024
### What

Part of a train 
* ➡️ #6257
* #6258
* #6259

This is needed to implement `TimeRangeBoundary` nicer: the `infinite`
variant is supposed to use this unit type.
The way I solved it is by introducing a special built-in `UnitType` that
we always map to `Type::Unit`. For purposes of serialization this is
just a variant of type null, i.e. we append to a `NullArray`.

_are you sure this works?_ Yes, check the last piece of the train!

### 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/{{pr.number}}?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/{{pr.number}}?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/{{pr.number}})
- [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`.
Wumpf added 2 commits May 8, 2024 10:53
# Conflicts:
#	rerun_py/rerun_sdk/rerun/datatypes/time_range_boundary.py
@Wumpf Wumpf force-pushed the andreas/python-union-codegen branch from 36cdca9 to 447881c Compare May 8, 2024 08:53
Wumpf and others added 4 commits May 8, 2024 11:38
…#6259)

### What

Part of a train 
* #6257
* #6258
* ➡️ #6259

Replaces a fair chunk of
* #6221

Makes `VisibleTimeRange` a union - the motivator for this pr train in
the first place. Adds a roundtrip test that compares the serialization
of`VisibleTimeRange` archetype across sdk languages. (the archetype is
meant for blueprint only, but I'm simply using the datastore for this
comparision)

### 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/6259?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/6259?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/6259)
- [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`.
@Wumpf Wumpf merged commit 0b26712 into main May 8, 2024
7 of 19 checks passed
@Wumpf Wumpf deleted the andreas/python-union-codegen branch May 8, 2024 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codegen/idl do-not-merge Do not merge this PR exclude from changelog PRs with this won't show up in CHANGELOG.md 🐍 Python API Python logging API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants