-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Silence spammy blueprint warnings and validate blueprint on load (#4303)
### What - Resolves: #4299 Adding a helper to silence the error messages only solved half the problem. Nothing prevented this corrupt data from being removed from the store, and worse, in some cases the corrupt data subsequently prevented new writes. We now validate that all the data in the blueprint has a valid schema or else we refuse to load it. ### 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/4303) (if applicable) * [x] The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG - [PR Build Summary](https://build.rerun.io/pr/4303) - [Docs preview](https://rerun.io/preview/5a85ed646d8a7c585804909613689c461fa0929e/docs) <!--DOCS-PREVIEW--> - [Examples preview](https://rerun.io/preview/5a85ed646d8a7c585804909613689c461fa0929e/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: Clement Rey <cr.rey.clement@gmail.com>
- Loading branch information
Showing
8 changed files
with
140 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
use re_arrow_store::LatestAtQuery; | ||
use re_data_store::{EntityPropertiesComponent, StoreDb}; | ||
use re_log_types::Timeline; | ||
use re_types_core::Component; | ||
use re_viewport::{ | ||
blueprint::{AutoSpaceViews, SpaceViewComponent, SpaceViewMaximized, ViewportLayout}, | ||
external::re_space_view::QueryExpressions, | ||
}; | ||
|
||
use crate::blueprint::PanelView; | ||
|
||
fn validate_component<C: Component>(blueprint: &StoreDb) -> bool { | ||
let query = LatestAtQuery::latest(Timeline::default()); | ||
|
||
if let Some(data_type) = blueprint.entity_db().data_store.lookup_datatype(&C::name()) { | ||
if data_type != &C::arrow_datatype() { | ||
// If the schemas don't match, we definitely have a problem | ||
re_log::debug!( | ||
"Unexpected datatype for component {:?}.\nFound: {:#?}\nExpected: {:#?}", | ||
C::name(), | ||
data_type, | ||
C::arrow_datatype() | ||
); | ||
return false; | ||
} else { | ||
// Otherwise, our usage of serde-fields means we still might have a problem | ||
// this can go away once we stop using serde-fields. | ||
// Walk the blueprint and see if any cells fail to deserialize for this component type. | ||
for path in blueprint.entity_db().entity_paths() { | ||
if let Some([Some(cell)]) = blueprint | ||
.entity_db() | ||
.data_store | ||
.latest_at(&query, path, C::name(), &[C::name()]) | ||
.map(|(_, cells)| cells) | ||
{ | ||
if let Err(err) = cell.try_to_native_mono::<C>() { | ||
re_log::debug!( | ||
"Failed to deserialize component {:?}: {:?}", | ||
C::name(), | ||
err | ||
); | ||
return false; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
true | ||
} | ||
|
||
/// Because blueprints are both read and written the schema must match what | ||
/// we expect to find or else we will run into all kinds of problems. | ||
pub fn is_valid_blueprint(blueprint: &StoreDb) -> bool { | ||
// TODO(jleibs): Generate this from codegen. | ||
validate_component::<AutoSpaceViews>(blueprint) | ||
&& validate_component::<EntityPropertiesComponent>(blueprint) | ||
&& validate_component::<PanelView>(blueprint) | ||
&& validate_component::<QueryExpressions>(blueprint) | ||
&& validate_component::<SpaceViewComponent>(blueprint) | ||
&& validate_component::<SpaceViewMaximized>(blueprint) | ||
&& validate_component::<ViewportLayout>(blueprint) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters