Skip to content

Commit

Permalink
Introduce python serialization for ContainerBlueprint (#5390)
Browse files Browse the repository at this point in the history
### What
Cherry-picked over the Name / Visibillity changes from
`andreas/serializable-spaceviewblueprint`, so we'll need to navigate
merge conflicts there.

Standard implementation of serializers and a unit-test for them:

After talking to @Wumpf I moved some of the list-types up a level to
simplify the serialization code, but this raised an issue with
mismatched dimensions. Need to discuss if we want to remove this check
(in light of the instance-key simplification), or push things back down
to mono-components with internal lists.

### TODO

- [x] Dragging onto a Grid container breaks due to the mismatched
dimensions between the contents and the row-shares.
  - Fixed by: #5399
```
[2024-03-04T23:10:53Z WARN  re_log::result_extensions] crates/re_viewport/src/container.rs:240 Failed to create Container blueprint.: Each cell must contain either 0, 1 or `num_instances` instances, but cell 'rerun.blueprint.components.RowShare' in '/container/439ad7ad-829c-4085-833b-eb30efae0810' holds 2 instances (expected 3)
```

### 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 newly built examples:
[app.rerun.io](https://app.rerun.io/pr/5390/index.html)
* Using examples from latest `main` build:
[app.rerun.io](https://app.rerun.io/pr/5390/index.html?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[app.rerun.io](https://app.rerun.io/pr/5390/index.html?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/5390)
- [Docs
preview](https://rerun.io/preview/6964d9643faba86a734746885f4a8792da3685f1/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/6964d9643faba86a734746885f4a8792da3685f1/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

---------

Co-authored-by: Andreas Reich <[email protected]>
  • Loading branch information
jleibs and Wumpf authored Mar 5, 2024
1 parent d23c977 commit bdc987c
Show file tree
Hide file tree
Showing 52 changed files with 1,330 additions and 1,278 deletions.
6 changes: 3 additions & 3 deletions crates/re_types/definitions/rerun/blueprint.fbs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
include "./blueprint/components/active_tab.fbs";
include "./blueprint/components/auto_layout.fbs";
include "./blueprint/components/auto_space_views.fbs";
include "./blueprint/components/column_shares.fbs";
include "./blueprint/components/column_share.fbs";
include "./blueprint/components/container_kind.fbs";
include "./blueprint/components/entities_determined_by_user.fbs";
include "./blueprint/components/entity_properties_component.fbs";
include "./blueprint/components/grid_columns.fbs";
include "./blueprint/components/included_contents.fbs";
include "./blueprint/components/included_content.fbs";
include "./blueprint/components/included_queries.fbs";
include "./blueprint/components/included_space_view.fbs";
include "./blueprint/components/panel_view.fbs";
include "./blueprint/components/query_expressions.fbs";
include "./blueprint/components/root_container.fbs";
include "./blueprint/components/row_shares.fbs";
include "./blueprint/components/row_share.fbs";
include "./blueprint/components/space_view_class.fbs";
include "./blueprint/components/space_view_maximized.fbs";
include "./blueprint/components/space_view_origin.fbs";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ table ContainerBlueprint (
display_name: rerun.components.Name ("attr.rerun.component_optional", nullable, order: 200);

/// `ContainerIds`s or `SpaceViewId`s that are children of this container.
contents: rerun.blueprint.components.IncludedContents ("attr.rerun.component_optional", nullable, order: 300);
contents: [rerun.blueprint.components.IncludedContent] ("attr.rerun.component_optional", nullable, order: 300);

/// The layout shares of each column in the container.
///
/// For `Horizontal` containers, the length of this list should always match the number of contents.
///
/// Ignored for `Vertical` containers.
col_shares: rerun.blueprint.components.ColumnShares ("attr.rerun.component_optional", nullable, order: 400);
col_shares: [rerun.blueprint.components.ColumnShare] ("attr.rerun.component_optional", nullable, order: 400);

/// The layout shares of each row of the container.
///
/// For `Vertical` containers, the length of this list should always match the number of contents.
///
/// Ignored for `Horizontal` containers.
row_shares: rerun.blueprint.components.RowShares ("attr.rerun.component_optional", nullable, order: 500);
row_shares: [rerun.blueprint.components.RowShare] ("attr.rerun.component_optional", nullable, order: 500);

/// Which tab is active.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ namespace rerun.blueprint.components;

// ---

/// The layout shares of each row in the container.
table RowShares (

/// The layout share of a column in the container.
table ColumnShare (
"attr.python.aliases": "float",
"attr.python.array_aliases": "npt.ArrayLike",
"attr.rerun.scope": "blueprint",
"attr.rust.derive": "Default"
) {
/// The layout shares of each row in the container.
shares: [float] (order: 100);
/// The layout shares of a column in the container.
share: float (order: 100);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ namespace rerun.blueprint.components;

/// Whether the space view entities were manually edited.
table EntitiesDeterminedByUser (
"attr.arrow.transparent",
"attr.rerun.scope": "blueprint",
"attr.rust.derive": "Default, PartialEq, Eq, PartialOrd, Ord",
"attr.rust.repr": "transparent"
"attr.rust.repr": "transparent",
"attr.rust.tuple_struct"
) {
value: bool (order: 100);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace rerun.blueprint.components;
/// How many columns a grid container should have.
table GridColumns (
"attr.rerun.scope": "blueprint",
"attr.python.aliases": "int",
"attr.rust.derive": "Default, PartialEq, Eq, PartialOrd, Ord",
"attr.rust.override_crate": "re_viewport"
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace rerun.blueprint.components;


/// All the contents in the container.
table IncludedContents (
table IncludedContent (
"attr.rerun.scope": "blueprint",
"attr.rust.derive": "Default"
) {
Expand All @@ -20,5 +20,5 @@ table IncludedContents (
/// This must be a path in the blueprint store.
/// Typically structure as `<blueprint_registry>/<uuid>`.
// TODO(jleibs): Maybe make this a typed UUID in the future.
contents: [rerun.datatypes.EntityPath] (order: 100);
contents: rerun.datatypes.EntityPath (order: 100);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ namespace rerun.blueprint.components;

// ---


/// The layout shares of each column in the container.
table ColumnShares (
/// The layout share of a row in the container.
table RowShare (
"attr.python.aliases": "float",
"attr.python.array_aliases": "npt.ArrayLike",
"attr.rerun.scope": "blueprint",
"attr.rust.derive": "Default"
) {
/// The layout shares of each column in the container.
shares: [float] (order: 100);
/// The layout share of a row in the container.
share: float (order: 100);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace rerun.blueprint.components;
struct Visible (
"attr.arrow.transparent",
"attr.rerun.scope": "blueprint",
"attr.python.aliases": "bool",
"attr.rust.derive": "Copy, PartialEq, Eq",
"attr.rust.repr": "transparent",
"attr.rust.tuple_struct"
Expand Down
2 changes: 2 additions & 0 deletions crates/re_types/definitions/rerun/datatypes/entity_path.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ namespace rerun.datatypes;
/// A path to an entity in the `DataStore`.
table EntityPath (
"attr.arrow.transparent",
"attr.python.aliases": "str",
"attr.python.array_aliases": "Sequence[str]",
"attr.rust.derive": "PartialEq, Eq, PartialOrd, Ord, Default",
"attr.rust.repr": "transparent",
"attr.rust.tuple_struct",
Expand Down
6 changes: 3 additions & 3 deletions crates/re_types/src/blueprint/components/.gitattributes

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

165 changes: 165 additions & 0 deletions crates/re_types/src/blueprint/components/column_share.rs

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

Loading

0 comments on commit bdc987c

Please sign in to comment.