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

Support loading .rbl blueprint files #5513

Merged
merged 14 commits into from
Mar 15, 2024
6 changes: 4 additions & 2 deletions crates/re_data_source/src/data_loader/loader_rrd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ impl crate::DataLoader for RrdLoader {
re_tracing::profile_function!(filepath.display().to_string());

let extension = crate::extension(&filepath);
if extension != "rrd" {
if !matches!(extension.as_str(), "rbl" | "rrd") {
// NOTE: blueprints and recordings has the same file format
return Err(crate::DataLoaderError::Incompatible(filepath.clone()));
}

Expand Down Expand Up @@ -66,7 +67,8 @@ impl crate::DataLoader for RrdLoader {
re_tracing::profile_function!(filepath.display().to_string());

let extension = crate::extension(&filepath);
if extension != "rrd" {
if !matches!(extension.as_str(), "rbl" | "rrd") {
// NOTE: blueprints and recordings has the same file format
return Err(crate::DataLoaderError::Incompatible(filepath));
}

Expand Down
18 changes: 18 additions & 0 deletions crates/re_data_source/src/data_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,24 @@ impl DataSource {
}
}

pub fn file_name(&self) -> Option<String> {
match self {
DataSource::RrdHttpUrl(url) => url.split('/').last().map(|r| r.to_owned()),
#[cfg(not(target_arch = "wasm32"))]
DataSource::FilePath(_, path) => {
path.file_name().map(|s| s.to_string_lossy().to_string())
}
DataSource::FileContents(_, file_contents) => Some(file_contents.name.clone()),
DataSource::WebSocketAddr(_) => None,
#[cfg(not(target_arch = "wasm32"))]
DataSource::Stdin => None,
}
}

pub fn is_blueprint(&self) -> Option<bool> {
self.file_name().map(|name| name.ends_with(".rbl"))
}

/// Stream the data from the given data source.
///
/// Will do minimal checks (e.g. that the file exists), for synchronous errors,
Expand Down
13 changes: 11 additions & 2 deletions crates/re_data_source/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,21 @@ pub use self::load_file::load_from_path;
/// This is what you get when loading a file on Web, or when using drag-n-drop.
//
// TODO(#4554): drag-n-drop streaming support
#[derive(Clone, Debug)]
#[derive(Clone)]
pub struct FileContents {
pub name: String,
pub bytes: std::sync::Arc<[u8]>,
}

impl std::fmt::Debug for FileContents {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("FileContents")
.field("name", &self.name)
.field("bytes", &format_args!("{} bytes", self.bytes.len()))
.finish()
}
}

// …given that all feature flags are turned on for the `image` crate.
pub const SUPPORTED_IMAGE_EXTENSIONS: &[&str] = &[
"avif", "bmp", "dds", "exr", "farbfeld", "ff", "gif", "hdr", "ico", "jpeg", "jpg", "pam",
Expand All @@ -55,7 +64,7 @@ pub const SUPPORTED_MESH_EXTENSIONS: &[&str] = &["glb", "gltf", "obj", "stl"];
// TODO(#4532): `.ply` data loader should support 2D point cloud & meshes
pub const SUPPORTED_POINT_CLOUD_EXTENSIONS: &[&str] = &["ply"];

pub const SUPPORTED_RERUN_EXTENSIONS: &[&str] = &["rrd"];
pub const SUPPORTED_RERUN_EXTENSIONS: &[&str] = &["rbl", "rrd"];

// TODO(#4555): Add catch-all builtin `DataLoader` for text files
pub const SUPPORTED_TEXT_EXTENSIONS: &[&str] = &["txt", "md"];
Expand Down
4 changes: 2 additions & 2 deletions crates/re_data_source/src/load_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub fn load_from_path(

re_log::info!("Loading {path:?}…");

let data = load(settings, path, None)?;
let rx = load(settings, path, None)?;

// TODO(cmc): should we always unconditionally set store info though?
// If we reach this point, then at least one compatible `DataLoader` has been found.
Expand All @@ -45,7 +45,7 @@ pub fn load_from_path(
}
}

send(&settings.store_id, data, tx);
send(&settings.store_id, rx, tx);

Ok(())
}
Expand Down
9 changes: 2 additions & 7 deletions crates/re_entity_db/src/entity_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ fn insert_row_with_retries(
///
/// NOTE: all mutation is to be done via public functions!
pub struct EntityDb {
/// The [`StoreId`] for this log.
store_id: StoreId,

/// Set by whomever created this [`EntityDb`].
pub data_source: Option<re_smart_channel::SmartChannelSource>,

Expand Down Expand Up @@ -126,7 +123,6 @@ impl EntityDb {
);
let query_caches = re_query_cache::Caches::new(&data_store);
Self {
store_id: store_id.clone(),
data_source: None,
set_store_info: None,
last_modified_at: web_time::Instant::now(),
Expand Down Expand Up @@ -193,11 +189,11 @@ impl EntityDb {
}

pub fn store_kind(&self) -> StoreKind {
self.store_id.kind
self.store_id().kind
}

pub fn store_id(&self) -> &StoreId {
&self.store_id
self.data_store.id()
}

pub fn timelines(&self) -> impl ExactSizeIterator<Item = &Timeline> {
Expand Down Expand Up @@ -486,7 +482,6 @@ impl EntityDb {
re_tracing::profile_function!();

let Self {
store_id: _,
data_source: _,
set_store_info: _,
last_modified_at: _,
Expand Down
11 changes: 11 additions & 0 deletions crates/re_log_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,17 @@ impl LogMsg {
Self::ArrowMsg(store_id, _) => store_id,
}
}

pub fn set_store_id(&mut self, new_store_id: StoreId) {
match self {
LogMsg::SetStoreInfo(store_info) => {
store_info.info.store_id = new_store_id;
}
LogMsg::ArrowMsg(msg_store_id, _) => {
*msg_store_id = new_store_id;
}
}
}
}

impl_into_enum!(SetStoreInfo, LogMsg, SetStoreInfo);
Expand Down
Loading
Loading