-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drive blueprints off of a DataStore (#2010)
- Uses the new serde-helper from: #2004 to stick space-views in the data-store - Refactors the frame loop to follow this basic logic: - Materialize the blueprint from the store - Save a snapshot of the materialized blueprint - Run most of the legacy code as is - If the blueprint has been modified then save the modifications back to the store - In the internals of the Python, this introduces a new `global_blueprint_stream()` - Adds a few python APIs that send data to the stream. - RecordingId is now a string, and we use a special condition of RecordingId == AppId to determine that a blueprint is the "default blueprint" for an app. - The default behavior of rr.init() now uses this special recording-id, which means in the common case your blueprint API calls do almost exactly what you want, but an expert can still opt out using `add_to_app_default_blueprint=False` (this might need a better name), in which case they get complete control over a new blueprint. - SpaceViewIds generated by the app use a hash of the spaceview name to avoid repeated appends. - The "selected blueprint" is determined based on app-id. There is a "currently selected" blueprint for each app, which defaults to the special global blueprint.
- Loading branch information
Showing
52 changed files
with
1,880 additions
and
330 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,88 @@ | ||
use re_arrow_store::LatestAtQuery; | ||
use re_log_types::{ | ||
DataRow, DeserializableComponent, EntityPath, RowId, SerializableComponent, TimeInt, TimePoint, | ||
Timeline, | ||
}; | ||
|
||
use crate::LogDb; | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
/// Get the latest value for a given [`re_log_types::Component`]. | ||
/// | ||
/// This assumes that the row we get from the store only contains a single instance for this | ||
/// component; it will log a warning otherwise. | ||
/// | ||
/// This should only be used for "mono-components" such as `Transform` and `Tensor`. | ||
pub fn query_latest_single<C: DeserializableComponent>( | ||
data_store: &re_arrow_store::DataStore, | ||
entity_path: &EntityPath, | ||
query: &LatestAtQuery, | ||
) -> Option<C> | ||
where | ||
for<'b> &'b C::ArrayType: IntoIterator, | ||
{ | ||
crate::profile_function!(); | ||
|
||
// Although it would be nice to use the `re_query` helpers for this, we would need to move | ||
// this out of re_data_store to avoid a circular dep. Since we don't need to do a join for | ||
// single components this is easy enough. | ||
|
||
let (_, cells) = data_store.latest_at(query, entity_path, C::name(), &[C::name()])?; | ||
let cell = cells.get(0)?.as_ref()?; | ||
|
||
let mut iter = cell.try_to_native::<C>().ok()?; | ||
|
||
let component = iter.next(); | ||
|
||
if iter.next().is_some() { | ||
re_log::warn_once!("Unexpected batch for {} at: {}", C::name(), entity_path); | ||
} | ||
|
||
component | ||
} | ||
|
||
/// Get the latest value for a given [`re_log_types::Component`] assuming it is timeless. | ||
/// | ||
/// This assumes that the row we get from the store only contains a single instance for this | ||
/// component; it will log a warning otherwise. | ||
pub fn query_timeless_single<C: DeserializableComponent>( | ||
data_store: &re_arrow_store::DataStore, | ||
entity_path: &EntityPath, | ||
) -> Option<C> | ||
where | ||
for<'b> &'b C::ArrayType: IntoIterator, | ||
{ | ||
let query = re_arrow_store::LatestAtQuery::new(Timeline::default(), TimeInt::MAX); | ||
query_latest_single(data_store, entity_path, &query) | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
/// Store a single value for a given [`re_log_types::Component`]. | ||
pub fn store_one_component<C: SerializableComponent>( | ||
log_db: &mut LogDb, | ||
entity_path: &EntityPath, | ||
timepoint: &TimePoint, | ||
component: C, | ||
) { | ||
let mut row = DataRow::from_cells1( | ||
RowId::random(), | ||
entity_path.clone(), | ||
timepoint.clone(), | ||
1, | ||
[component].as_slice(), | ||
); | ||
row.compute_all_size_bytes(); | ||
|
||
match log_db.entity_db.try_add_data_row(&row) { | ||
Ok(()) => {} | ||
Err(err) => { | ||
re_log::warn_once!( | ||
"Failed to store component {}.{}: {err}", | ||
entity_path, | ||
C::name(), | ||
); | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.