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

Fix loading file via CLI #2807

Merged
merged 3 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions crates/re_log_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,12 @@ pub enum StoreSource {
llvm_version: String,
},

/// Loading a file directly from disk via the CLI.
FileFromCli {
rustc_version: String,
llvm_version: String,
},

/// Perhaps from some manual data ingestion?
Other(String),
}
Expand All @@ -338,9 +344,13 @@ impl std::fmt::Display for StoreSource {
Self::CSdk => "C SDK".fmt(f),
Self::PythonSdk(version) => write!(f, "Python {version} SDK"),
Self::RustSdk {
rustc_version: rust_version,
rustc_version,
llvm_version: _,
} => write!(f, "Rust {rustc_version} SDK"),
Self::FileFromCli {
rustc_version,
llvm_version: _,
} => write!(f, "Rust {rust_version} SDK"),
} => write!(f, "File via CLI {rustc_version} "),
Self::Other(string) => format!("{string:?}").fmt(f), // put it in quotes
}
}
Expand Down
1 change: 0 additions & 1 deletion crates/re_viewer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,6 @@ impl App {
/// Top-level ui function.
///
/// Shows the viewer ui.
#[allow(clippy::too_many_arguments)]
fn ui(
&mut self,
egui_ctx: &egui::Context,
Expand Down
11 changes: 9 additions & 2 deletions crates/re_viewer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,17 @@ impl AppEnvironment {
StoreSource::CSdk => Self::CSdk,
StoreSource::PythonSdk(python_version) => Self::PythonSdk(python_version.clone()),
StoreSource::RustSdk {
rustc_version: rust_version,
rustc_version,
llvm_version,
} => Self::RustSdk {
rustc_version: rust_version.clone(),
rustc_version: rustc_version.clone(),
llvm_version: llvm_version.clone(),
},
StoreSource::FileFromCli {
rustc_version,
llvm_version,
} => Self::RerunCli {
rustc_version: rustc_version.clone(),
llvm_version: llvm_version.clone(),
},
StoreSource::Unknown | StoreSource::Other(_) => Self::RustSdk {
Expand Down
35 changes: 22 additions & 13 deletions crates/re_viewer/src/viewer_analytics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ impl ViewerAnalytics {
StoreSource::CSdk => "c_sdk".to_owned(),
StoreSource::PythonSdk(_version) => "python_sdk".to_owned(),
StoreSource::RustSdk { .. } => "rust_sdk".to_owned(),
StoreSource::FileFromCli { .. } => "file_cli".to_owned(),
StoreSource::Other(other) => other.clone(),
};

Expand All @@ -168,19 +169,27 @@ impl ViewerAnalytics {
//
// The Python/Rust versions appearing in events always apply to the recording
// environment, _not_ the environment in which the viewer is running!
if let StoreSource::RustSdk {
rustc_version: rust_version,
llvm_version,
} = &store_info.store_source
{
self.register("rust_version", rust_version.to_string());
self.register("llvm_version", llvm_version.to_string());
self.deregister("python_version"); // can't be both!
}
if let StoreSource::PythonSdk(version) = &store_info.store_source {
self.register("python_version", version.to_string());
self.deregister("rust_version"); // can't be both!
self.deregister("llvm_version"); // can't be both!
#[allow(clippy::match_same_arms)]
match &store_info.store_source {
StoreSource::FileFromCli {
rustc_version,
llvm_version,
}
| StoreSource::RustSdk {
rustc_version,
llvm_version,
} => {
self.register("rust_version", rustc_version.to_string());
self.register("llvm_version", llvm_version.to_string());
self.deregister("python_version"); // can't be both!
}
StoreSource::PythonSdk(version) => {
self.register("python_version", version.to_string());
self.deregister("rust_version"); // can't be both!
self.deregister("llvm_version"); // can't be both!
}
StoreSource::CSdk => {} // TODO(andreas): Send version and set it.
StoreSource::Unknown | StoreSource::Other(_) => {}
}

self.register("store_source", store_source);
Expand Down
27 changes: 24 additions & 3 deletions crates/rerun/src/run.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::path::{Path, PathBuf};

use itertools::Itertools;
use re_log_types::{LogMsg, PythonVersion};
use re_log_types::{LogMsg, PythonVersion, SetStoreInfo};
use re_smart_channel::{Receiver, SmartMessagePayload};

use anyhow::Context as _;
Expand Down Expand Up @@ -872,8 +872,29 @@ fn load_file_to_channel_at(
} else {
#[cfg(feature = "sdk")]
{
let log_msg = re_sdk::MsgSender::from_file_path(path)?.into_log_msg(store_id)?;
tx.send(log_msg).ok(); // .ok(): we may be running in a background thread, so who knows if the receiver is still open
// First, set a store info since this is the first thing the application expects.
tx.send(LogMsg::SetStoreInfo(SetStoreInfo {
row_id: re_log_types::RowId::random(),
info: re_log_types::StoreInfo {
application_id: re_log_types::ApplicationId(
path.to_str().unwrap_or("file").to_owned(),
),
store_id: store_id.clone(),
is_official_example: false,
started: re_log_types::Time::now(),
store_source: re_log_types::StoreSource::FileFromCli {
rustc_version: env!("RE_BUILD_RUSTC_VERSION").into(),
llvm_version: env!("RE_BUILD_LLVM_VERSION").into(),
},
store_kind: re_log_types::StoreKind::Recording,
},
}))
.ok(); // .ok(): we may be running in a background thread, so who knows if the receiver is still open

// Send actual file.
tx.send(re_sdk::MsgSender::from_file_path(path)?.into_log_msg(store_id)?)
.ok();

tx.quit(None).ok();
Ok(())
}
Expand Down