From 53fa97013f958c8c5eb46e44979fb543cc5e67e5 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Wed, 11 Oct 2023 17:05:34 +0200 Subject: [PATCH 01/20] Add basic support for in-app "Getting Started" guides --- Cargo.lock | 1 + crates/re_viewer/Cargo.toml | 1 + crates/re_viewer/src/app.rs | 7 ++ crates/re_viewer/src/ui/welcome_screen/mod.rs | 1 + .../ui/welcome_screen/python_quick_start.rs | 88 +++++++++++++++++++ .../src/ui/welcome_screen/welcome_page.rs | 13 ++- .../re_viewer_context/src/command_sender.rs | 5 +- 7 files changed, 111 insertions(+), 5 deletions(-) create mode 100644 crates/re_viewer/src/ui/welcome_screen/python_quick_start.rs diff --git a/Cargo.lock b/Cargo.lock index e14c6ec94fba..0b8f630a7157 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4805,6 +4805,7 @@ dependencies = [ "re_log_types", "re_memory", "re_renderer", + "re_sdk", "re_smart_channel", "re_space_view_bar_chart", "re_space_view_spatial", diff --git a/crates/re_viewer/Cargo.toml b/crates/re_viewer/Cargo.toml index f4d19503cae0..520507b186c7 100644 --- a/crates/re_viewer/Cargo.toml +++ b/crates/re_viewer/Cargo.toml @@ -50,6 +50,7 @@ re_log_types.workspace = true re_log.workspace = true re_memory.workspace = true re_renderer = { workspace = true, default-features = false } +re_sdk.workspace = true re_smart_channel.workspace = true re_space_view_bar_chart.workspace = true re_space_view_spatial.workspace = true diff --git a/crates/re_viewer/src/app.rs b/crates/re_viewer/src/app.rs index 05812cd1a194..182fc8e610f4 100644 --- a/crates/re_viewer/src/app.rs +++ b/crates/re_viewer/src/app.rs @@ -349,6 +349,13 @@ impl App { } } + SystemCommand::LoadLogMessage(mut log_messages) => { + for log_msg in log_messages.drain(..) { + let store_db = store_hub.store_db_mut(log_msg.store_id()); + store_db.add(&log_msg).unwrap(); + } + } + SystemCommand::ResetViewer => self.reset(store_hub, egui_ctx), SystemCommand::UpdateBlueprint(blueprint_id, updates) => { let blueprint_db = store_hub.store_db_mut(&blueprint_id); diff --git a/crates/re_viewer/src/ui/welcome_screen/mod.rs b/crates/re_viewer/src/ui/welcome_screen/mod.rs index fc0491bca8bf..27c41da81d40 100644 --- a/crates/re_viewer/src/ui/welcome_screen/mod.rs +++ b/crates/re_viewer/src/ui/welcome_screen/mod.rs @@ -1,4 +1,5 @@ mod example_page; +mod python_quick_start; mod welcome_page; use egui::Widget; diff --git a/crates/re_viewer/src/ui/welcome_screen/python_quick_start.rs b/crates/re_viewer/src/ui/welcome_screen/python_quick_start.rs new file mode 100644 index 000000000000..0642e57016aa --- /dev/null +++ b/crates/re_viewer/src/ui/welcome_screen/python_quick_start.rs @@ -0,0 +1,88 @@ +use re_viewer_context::{SystemCommand, SystemCommandSender}; + +pub(super) fn python_quick_start( + command_sender: &re_viewer_context::CommandSender, +) -> re_sdk::RecordingStreamResult<()> { + let (rec, storage) = re_sdk::RecordingStreamBuilder::new("Python Getting Started").memory()?; + + rec.log( + "markdown", + &re_sdk::TextDocument::new( + r#"# Python Quick Start + +## Installing the Rerun SDK + +The Rerun SDK is available on [PyPI](https://pypi.org/) under the +[`rerun-sdk`](https://pypi.org/project/rerun-sdk/) name. It can be installed like any other +Python package: + +```sh +pip3 install rerun-sdk +``` + +## Try out the viewer + +The Rerun SDK comes with a demo that can be used to try the viewer. You can send a demo recording +to this viewer using the following command: + +```sh +python3 -m rerun_sdk.demo --connect +``` + +This will open a new recording that looks like this: + +![Demo recording](https://static.rerun.io/quickstart2_simple_cube/632a8f1c79f70a2355fad294fe085291fcf3a8ae/768w.png) + + +## Logging your own data + +Instead of a pre-packaged demo, you can log your own data. Copy and paste the following snippet in a new +Python file and execute it to create a new recording in this viewer: + +```python +import rerun as rr +import numpy as np + +# Initialize the SDK and give our recording a unique name +rr.init("my_own_data") + +# Connect to a local viewer using the default port +rr.connect() + + +# Create some data +SIZE = 10 + +pos_grid = np.meshgrid(*[np.linspace(-10, 10, SIZE)]*3) +positions = np.vstack([d.reshape(-1) for d in pos_grid]).T + +col_grid = np.meshgrid(*[np.linspace(0, 255, SIZE)]*3) +colors = np.vstack([c.reshape(-1) for c in col_grid]).astype(np.uint8).T + +# Log the data +rr.log( + # name under which this entity is logged (known as "entity path") + "my_points", + # log data as a 3D point cloud archetype + rr.Points3D(positions, colors=colors, radii=0.5) +) +``` + +## How does it work? + +TBC +"# + .trim(), + ) + .with_media_type(re_sdk::MediaType::markdown()), + )?; + + let log_msgs = storage.take(); + let store_id = rec.store_info().map(|info| info.store_id.clone()); + command_sender.send_system(SystemCommand::LoadLogMessage(log_msgs)); + if let Some(store_id) = store_id { + command_sender.send_system(SystemCommand::SetRecordingId(store_id)); + } + + Ok(()) +} diff --git a/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs b/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs index 8b5920b61962..2ec5616db8ba 100644 --- a/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs +++ b/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs @@ -1,11 +1,12 @@ -use super::{large_text_button, status_strings, url_large_text_button, WelcomeScreenResponse}; +use super::{ + large_text_button, python_quick_start::python_quick_start, status_strings, + url_large_text_button, WelcomeScreenResponse, +}; use egui::{NumExt, Ui}; use re_log_types::LogMsg; use re_smart_channel::ReceiveSet; use re_ui::UICommandSender; -//const CPP_QUICKSTART: &str = "https://www.rerun.io/docs/getting-started/cpp"; -const PYTHON_QUICKSTART: &str = "https://www.rerun.io/docs/getting-started/python"; const RUST_QUICKSTART: &str = "https://www.rerun.io/docs/getting-started/rust"; const SPACE_VIEWS_HELP: &str = "https://www.rerun.io/docs/getting-started/viewer-walkthrough"; @@ -60,7 +61,11 @@ fn onboarding_content_ui( add_buttons: Box::new(|ui: &mut egui::Ui| { // TODO(ab): activate when C++ is ready! // url_large_text_button(ui, "C++", CPP_QUICKSTART); - url_large_text_button(ui, "Python", PYTHON_QUICKSTART); + if large_text_button(ui, "Python").clicked() { + if let Err(err) = python_quick_start(command_sender) { + re_log::error!("Failed to load Python quick start: {}", err); + } + } url_large_text_button(ui, "Rust", RUST_QUICKSTART); false diff --git a/crates/re_viewer_context/src/command_sender.rs b/crates/re_viewer_context/src/command_sender.rs index c3923a6f3b4d..7b28c5da3892 100644 --- a/crates/re_viewer_context/src/command_sender.rs +++ b/crates/re_viewer_context/src/command_sender.rs @@ -1,5 +1,5 @@ use re_data_source::DataSource; -use re_log_types::{DataRow, StoreId}; +use re_log_types::{DataRow, LogMsg, StoreId}; use re_ui::{UICommand, UICommandSender}; // ---------------------------------------------------------------------------- @@ -10,6 +10,9 @@ pub enum SystemCommand { /// Load some data. LoadDataSource(DataSource), + /// Load some log messages. + LoadLogMessage(Vec), + /// Reset the `Viewer` to the default state ResetViewer, From 247585730fd929ad2e4242e8f23b70d701c38a00 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Wed, 11 Oct 2023 17:24:20 +0200 Subject: [PATCH 02/20] Work around #3612 by not using H1 --- .../src/ui/welcome_screen/python_quick_start.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/re_viewer/src/ui/welcome_screen/python_quick_start.rs b/crates/re_viewer/src/ui/welcome_screen/python_quick_start.rs index 0642e57016aa..d7e1d39b88c1 100644 --- a/crates/re_viewer/src/ui/welcome_screen/python_quick_start.rs +++ b/crates/re_viewer/src/ui/welcome_screen/python_quick_start.rs @@ -8,9 +8,10 @@ pub(super) fn python_quick_start( rec.log( "markdown", &re_sdk::TextDocument::new( - r#"# Python Quick Start + r#" +## Python Quick Start -## Installing the Rerun SDK +### Installing the Rerun SDK The Rerun SDK is available on [PyPI](https://pypi.org/) under the [`rerun-sdk`](https://pypi.org/project/rerun-sdk/) name. It can be installed like any other @@ -20,7 +21,7 @@ Python package: pip3 install rerun-sdk ``` -## Try out the viewer +### Try out the viewer The Rerun SDK comes with a demo that can be used to try the viewer. You can send a demo recording to this viewer using the following command: @@ -34,7 +35,7 @@ This will open a new recording that looks like this: ![Demo recording](https://static.rerun.io/quickstart2_simple_cube/632a8f1c79f70a2355fad294fe085291fcf3a8ae/768w.png) -## Logging your own data +### Logging your own data Instead of a pre-packaged demo, you can log your own data. Copy and paste the following snippet in a new Python file and execute it to create a new recording in this viewer: @@ -68,7 +69,7 @@ rr.log( ) ``` -## How does it work? +### How does it work? TBC "# From 47127df34d085b65cd8daa620c56654b330a9f80 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Thu, 12 Oct 2023 11:37:39 +0200 Subject: [PATCH 03/20] Low-level recording creation instead of using `re_sdk`. --- Cargo.lock | 2 +- crates/re_data_store/Cargo.toml | 1 + crates/re_data_store/src/store_db.rs | 25 +++++++++++- crates/re_log_types/src/lib.rs | 4 ++ crates/re_viewer/Cargo.toml | 1 - crates/re_viewer/src/app.rs | 9 ++--- crates/re_viewer/src/lib.rs | 5 ++- crates/re_viewer/src/store_hub.rs | 8 ++++ .../ui/welcome_screen/python_quick_start.rs | 40 +++++++++++++------ crates/re_viewer/src/viewer_analytics.rs | 3 +- .../re_viewer_context/src/command_sender.rs | 5 ++- 11 files changed, 78 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0b8f630a7157..169928469022 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4180,6 +4180,7 @@ dependencies = [ name = "re_data_store" version = "0.10.0-alpha.7+dev" dependencies = [ + "anyhow", "criterion", "document-features", "itertools 0.11.0", @@ -4805,7 +4806,6 @@ dependencies = [ "re_log_types", "re_memory", "re_renderer", - "re_sdk", "re_smart_channel", "re_space_view_bar_chart", "re_space_view_spatial", diff --git a/crates/re_data_store/Cargo.toml b/crates/re_data_store/Cargo.toml index 89a8789e199b..84ebfcfc9687 100644 --- a/crates/re_data_store/Cargo.toml +++ b/crates/re_data_store/Cargo.toml @@ -34,6 +34,7 @@ re_smart_channel.workspace = true re_tracing.workspace = true re_types.workspace = true +anyhow.workspace = true document-features.workspace = true itertools.workspace = true nohash-hasher.workspace = true diff --git a/crates/re_data_store/src/store_db.rs b/crates/re_data_store/src/store_db.rs index 26b94a42b1e5..8d0afdb309b7 100644 --- a/crates/re_data_store/src/store_db.rs +++ b/crates/re_data_store/src/store_db.rs @@ -210,7 +210,7 @@ impl EntityDb { // ---------------------------------------------------------------------------- -/// A in-memory database built from a stream of [`LogMsg`]es. +/// An in-memory database built from a stream of [`LogMsg`]es. /// /// NOTE: all mutation is to be done via public functions! pub struct StoreDb { @@ -237,6 +237,29 @@ impl StoreDb { } } + /// Helper function to create a recording from a [`StoreInfo`] and a some [`DataRow`]s. + /// + /// This is useful to programmatically create recordings from within the viewer, which cannot + /// use the `re_sdk`, which is not Wasm-compatible. + pub fn from_info_and_rows( + store_info: StoreInfo, + rows: impl IntoIterator, + ) -> anyhow::Result { + let arrow_msg = DataTable::from_rows(TableId::random(), rows).to_arrow_msg()?; + let store_id = store_info.store_id.clone(); + let mut store_db = StoreDb::new(store_id.clone()); + store_db.add( + &SetStoreInfo { + row_id: RowId::random(), + info: store_info, + } + .into(), + )?; + store_db.add(&LogMsg::ArrowMsg(store_id, arrow_msg))?; + + Ok(store_db) + } + #[inline] pub fn entity_db(&self) -> &EntityDb { &self.entity_db diff --git a/crates/re_log_types/src/lib.rs b/crates/re_log_types/src/lib.rs index 6f97bcb09aae..b116069c1834 100644 --- a/crates/re_log_types/src/lib.rs +++ b/crates/re_log_types/src/lib.rs @@ -346,6 +346,9 @@ pub enum StoreSource { file_source: FileSource, }, + /// In-app guides. + InAppGuides, + /// Perhaps from some manual data ingestion? Other(String), } @@ -362,6 +365,7 @@ impl std::fmt::Display for StoreSource { FileSource::DragAndDrop => write!(f, "File via drag-and-drop"), FileSource::FileDialog => write!(f, "File via file dialog"), }, + Self::InAppGuides => write!(f, "In-app guide"), Self::Other(string) => format!("{string:?}").fmt(f), // put it in quotes } } diff --git a/crates/re_viewer/Cargo.toml b/crates/re_viewer/Cargo.toml index 520507b186c7..f4d19503cae0 100644 --- a/crates/re_viewer/Cargo.toml +++ b/crates/re_viewer/Cargo.toml @@ -50,7 +50,6 @@ re_log_types.workspace = true re_log.workspace = true re_memory.workspace = true re_renderer = { workspace = true, default-features = false } -re_sdk.workspace = true re_smart_channel.workspace = true re_space_view_bar_chart.workspace = true re_space_view_spatial.workspace = true diff --git a/crates/re_viewer/src/app.rs b/crates/re_viewer/src/app.rs index 182fc8e610f4..597fd545ba3a 100644 --- a/crates/re_viewer/src/app.rs +++ b/crates/re_viewer/src/app.rs @@ -349,11 +349,10 @@ impl App { } } - SystemCommand::LoadLogMessage(mut log_messages) => { - for log_msg in log_messages.drain(..) { - let store_db = store_hub.store_db_mut(log_msg.store_id()); - store_db.add(&log_msg).unwrap(); - } + SystemCommand::LoadStoreDb(store_db) => { + let store_id = store_db.store_id().clone(); + store_hub.insert_recording(store_db); + store_hub.set_recording_id(store_id); } SystemCommand::ResetViewer => self.reset(store_hub, egui_ctx), diff --git a/crates/re_viewer/src/lib.rs b/crates/re_viewer/src/lib.rs index ebee21a08060..33d092768f83 100644 --- a/crates/re_viewer/src/lib.rs +++ b/crates/re_viewer/src/lib.rs @@ -103,7 +103,10 @@ impl AppEnvironment { llvm_version: llvm_version.clone(), }, - StoreSource::File { .. } | StoreSource::Unknown | StoreSource::Other(_) => { + StoreSource::File { .. } + | StoreSource::Unknown + | StoreSource::InAppGuides + | StoreSource::Other(_) => { // We should not really get here #[cfg(debug_assertions)] diff --git a/crates/re_viewer/src/store_hub.rs b/crates/re_viewer/src/store_hub.rs index 7479886fd67c..ea376ad5d578 100644 --- a/crates/re_viewer/src/store_hub.rs +++ b/crates/re_viewer/src/store_hub.rs @@ -192,6 +192,14 @@ impl StoreHub { } } + /// Insert a new recording into the [`StoreHub`]. + /// + /// Note that the recording is not automatically made active. Use [`StoreHub::set_recording_id`] + /// if needed. + pub fn insert_recording(&mut self, store_db: StoreDb) { + self.store_dbs.insert_recording(store_db); + } + /// Mutable access to a [`StoreDb`] by id pub fn store_db_mut(&mut self, store_id: &StoreId) -> &mut StoreDb { self.store_dbs.store_db_entry(store_id) diff --git a/crates/re_viewer/src/ui/welcome_screen/python_quick_start.rs b/crates/re_viewer/src/ui/welcome_screen/python_quick_start.rs index d7e1d39b88c1..519076286e7d 100644 --- a/crates/re_viewer/src/ui/welcome_screen/python_quick_start.rs +++ b/crates/re_viewer/src/ui/welcome_screen/python_quick_start.rs @@ -1,13 +1,15 @@ +use re_data_store::StoreDb; +use re_log_types::{ + ApplicationId, DataRow, EntityPath, RowId, StoreId, StoreInfo, StoreKind, StoreSource, Time, + TimePoint, +}; use re_viewer_context::{SystemCommand, SystemCommandSender}; pub(super) fn python_quick_start( command_sender: &re_viewer_context::CommandSender, -) -> re_sdk::RecordingStreamResult<()> { - let (rec, storage) = re_sdk::RecordingStreamBuilder::new("Python Getting Started").memory()?; - - rec.log( - "markdown", - &re_sdk::TextDocument::new( +) -> anyhow::Result<()> { + let text_doc = + re_types::archetypes::TextDocument::new( r#" ## Python Quick Start @@ -75,15 +77,27 @@ TBC "# .trim(), ) - .with_media_type(re_sdk::MediaType::markdown()), + .with_media_type(re_types::components::MediaType::markdown()); + + let row = DataRow::from_archetype( + RowId::random(), + TimePoint::timeless(), + EntityPath::from("quick_start"), + &text_doc, )?; - let log_msgs = storage.take(); - let store_id = rec.store_info().map(|info| info.store_id.clone()); - command_sender.send_system(SystemCommand::LoadLogMessage(log_msgs)); - if let Some(store_id) = store_id { - command_sender.send_system(SystemCommand::SetRecordingId(store_id)); - } + let store_info = StoreInfo { + application_id: ApplicationId::from("Python Quick Start"), + store_id: StoreId::random(StoreKind::Recording), + is_official_example: true, + started: Time::now(), + store_source: StoreSource::InAppGuides, + store_kind: StoreKind::Recording, + }; + + let store_db = StoreDb::from_info_and_rows(store_info, [row])?; + + command_sender.send_system(SystemCommand::LoadStoreDb(store_db)); Ok(()) } diff --git a/crates/re_viewer/src/viewer_analytics.rs b/crates/re_viewer/src/viewer_analytics.rs index 4a8a280afba9..8837f58be811 100644 --- a/crates/re_viewer/src/viewer_analytics.rs +++ b/crates/re_viewer/src/viewer_analytics.rs @@ -181,6 +181,7 @@ impl ViewerAnalytics { re_log_types::FileSource::DragAndDrop => "file_drag_and_drop".to_owned(), re_log_types::FileSource::FileDialog => "file_dialog".to_owned(), }, + StoreSource::InAppGuides => "in_app_guides".to_owned(), StoreSource::Other(other) => other.clone(), }; @@ -210,7 +211,7 @@ impl ViewerAnalytics { self.deregister("llvm_version"); // can't be both! } StoreSource::CSdk => {} // TODO(andreas): Send version and set it. - StoreSource::Unknown | StoreSource::Other(_) => {} + StoreSource::Unknown | StoreSource::InAppGuides | StoreSource::Other(_) => {} } self.register("store_source", store_source); diff --git a/crates/re_viewer_context/src/command_sender.rs b/crates/re_viewer_context/src/command_sender.rs index 7b28c5da3892..4de6ac5ed72a 100644 --- a/crates/re_viewer_context/src/command_sender.rs +++ b/crates/re_viewer_context/src/command_sender.rs @@ -1,5 +1,6 @@ use re_data_source::DataSource; -use re_log_types::{DataRow, LogMsg, StoreId}; +use re_data_store::StoreDb; +use re_log_types::{DataRow, StoreId}; use re_ui::{UICommand, UICommandSender}; // ---------------------------------------------------------------------------- @@ -11,7 +12,7 @@ pub enum SystemCommand { LoadDataSource(DataSource), /// Load some log messages. - LoadLogMessage(Vec), + LoadStoreDb(StoreDb), /// Reset the `Viewer` to the default state ResetViewer, From 54efcd18e30ec7b167c1b8d9e26e4361adf48751 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Thu, 12 Oct 2023 16:34:20 +0200 Subject: [PATCH 04/20] Refactored quick start code --- .../data/quick_start_guides/cpp_native.md | 3 + .../quick_start_guides/how_does_it_work.md | 3 + .../quick_start_guides/python_native.md} | 46 +-------- .../data/quick_start_guides/rust_native.md | 3 + crates/re_viewer/src/ui/welcome_screen/mod.rs | 1 - .../src/ui/welcome_screen/welcome_page.rs | 96 ++++++++++++++++--- 6 files changed, 94 insertions(+), 58 deletions(-) create mode 100644 crates/re_viewer/data/quick_start_guides/cpp_native.md create mode 100644 crates/re_viewer/data/quick_start_guides/how_does_it_work.md rename crates/re_viewer/{src/ui/welcome_screen/python_quick_start.rs => data/quick_start_guides/python_native.md} (56%) create mode 100644 crates/re_viewer/data/quick_start_guides/rust_native.md diff --git a/crates/re_viewer/data/quick_start_guides/cpp_native.md b/crates/re_viewer/data/quick_start_guides/cpp_native.md new file mode 100644 index 000000000000..60714b19e548 --- /dev/null +++ b/crates/re_viewer/data/quick_start_guides/cpp_native.md @@ -0,0 +1,3 @@ +## C++ Quick Start + +TODO(ab) \ No newline at end of file diff --git a/crates/re_viewer/data/quick_start_guides/how_does_it_work.md b/crates/re_viewer/data/quick_start_guides/how_does_it_work.md new file mode 100644 index 000000000000..fd28ee6a7f0f --- /dev/null +++ b/crates/re_viewer/data/quick_start_guides/how_does_it_work.md @@ -0,0 +1,3 @@ +### How does it work? + +TBC \ No newline at end of file diff --git a/crates/re_viewer/src/ui/welcome_screen/python_quick_start.rs b/crates/re_viewer/data/quick_start_guides/python_native.md similarity index 56% rename from crates/re_viewer/src/ui/welcome_screen/python_quick_start.rs rename to crates/re_viewer/data/quick_start_guides/python_native.md index 519076286e7d..c0f7e844b871 100644 --- a/crates/re_viewer/src/ui/welcome_screen/python_quick_start.rs +++ b/crates/re_viewer/data/quick_start_guides/python_native.md @@ -1,16 +1,3 @@ -use re_data_store::StoreDb; -use re_log_types::{ - ApplicationId, DataRow, EntityPath, RowId, StoreId, StoreInfo, StoreKind, StoreSource, Time, - TimePoint, -}; -use re_viewer_context::{SystemCommand, SystemCommandSender}; - -pub(super) fn python_quick_start( - command_sender: &re_viewer_context::CommandSender, -) -> anyhow::Result<()> { - let text_doc = - re_types::archetypes::TextDocument::new( - r#" ## Python Quick Start ### Installing the Rerun SDK @@ -69,35 +56,4 @@ rr.log( # log data as a 3D point cloud archetype rr.Points3D(positions, colors=colors, radii=0.5) ) -``` - -### How does it work? - -TBC -"# - .trim(), - ) - .with_media_type(re_types::components::MediaType::markdown()); - - let row = DataRow::from_archetype( - RowId::random(), - TimePoint::timeless(), - EntityPath::from("quick_start"), - &text_doc, - )?; - - let store_info = StoreInfo { - application_id: ApplicationId::from("Python Quick Start"), - store_id: StoreId::random(StoreKind::Recording), - is_official_example: true, - started: Time::now(), - store_source: StoreSource::InAppGuides, - store_kind: StoreKind::Recording, - }; - - let store_db = StoreDb::from_info_and_rows(store_info, [row])?; - - command_sender.send_system(SystemCommand::LoadStoreDb(store_db)); - - Ok(()) -} +``` \ No newline at end of file diff --git a/crates/re_viewer/data/quick_start_guides/rust_native.md b/crates/re_viewer/data/quick_start_guides/rust_native.md new file mode 100644 index 000000000000..615db72247c0 --- /dev/null +++ b/crates/re_viewer/data/quick_start_guides/rust_native.md @@ -0,0 +1,3 @@ +## Rust Quick Start + +TODO(ab) \ No newline at end of file diff --git a/crates/re_viewer/src/ui/welcome_screen/mod.rs b/crates/re_viewer/src/ui/welcome_screen/mod.rs index 27c41da81d40..fc0491bca8bf 100644 --- a/crates/re_viewer/src/ui/welcome_screen/mod.rs +++ b/crates/re_viewer/src/ui/welcome_screen/mod.rs @@ -1,5 +1,4 @@ mod example_page; -mod python_quick_start; mod welcome_page; use egui::Widget; diff --git a/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs b/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs index 2ec5616db8ba..aea4c0014feb 100644 --- a/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs +++ b/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs @@ -1,13 +1,15 @@ -use super::{ - large_text_button, python_quick_start::python_quick_start, status_strings, - url_large_text_button, WelcomeScreenResponse, -}; +use super::{large_text_button, status_strings, url_large_text_button, WelcomeScreenResponse}; use egui::{NumExt, Ui}; -use re_log_types::LogMsg; +use itertools::Itertools; +use re_data_store::StoreDb; +use re_log_types::{ + ApplicationId, DataRow, EntityPath, LogMsg, RowId, StoreId, StoreInfo, StoreKind, StoreSource, + Time, TimePoint, +}; use re_smart_channel::ReceiveSet; use re_ui::UICommandSender; +use re_viewer_context::{SystemCommand, SystemCommandSender}; -const RUST_QUICKSTART: &str = "https://www.rerun.io/docs/getting-started/rust"; const SPACE_VIEWS_HELP: &str = "https://www.rerun.io/docs/getting-started/viewer-walkthrough"; /// Show the welcome page. @@ -59,14 +61,39 @@ fn onboarding_content_ui( Visualize synchronized data from multiple processes, locally or over a network.", image: &re_ui::icons::WELCOME_SCREEN_LIVE_DATA, add_buttons: Box::new(|ui: &mut egui::Ui| { - // TODO(ab): activate when C++ is ready! - // url_large_text_button(ui, "C++", CPP_QUICKSTART); + if large_text_button(ui, "C++").clicked() { + open_quick_start( + command_sender, + [ + include_str!("../../../data/quick_start_guides/cpp_native.md"), + include_str!("../../../data/quick_start_guides/how_does_it_work.md"), + ], + "C++ Quick Start", + "cpp_quick_start", + ); + } if large_text_button(ui, "Python").clicked() { - if let Err(err) = python_quick_start(command_sender) { - re_log::error!("Failed to load Python quick start: {}", err); - } + open_quick_start( + command_sender, + [ + include_str!("../../../data/quick_start_guides/python_native.md"), + include_str!("../../../data/quick_start_guides/how_does_it_work.md"), + ], + "Python Quick Start", + "python_quick_start", + ); + } + if large_text_button(ui, "Rust").clicked() { + open_quick_start( + command_sender, + [ + include_str!("../../../data/quick_start_guides/rust_native.md"), + include_str!("../../../data/quick_start_guides/how_does_it_work.md"), + ], + "Rust Quick Start", + "rust_quick_start", + ); } - url_large_text_button(ui, "Rust", RUST_QUICKSTART); false }), @@ -236,3 +263,48 @@ fn image_banner(ui: &mut egui::Ui, icon: &re_ui::Icon, column_width: f32, max_im ); }); } + +fn open_quick_start<'a>( + command_sender: &re_viewer_context::CommandSender, + parts: impl IntoIterator, + app_id: impl AsRef, + entity_path: impl AsRef, +) { + let markdown = parts.into_iter().join("\n"); + let res = open_markdown_recording(command_sender, &markdown, app_id, entity_path); + if let Err(err) = res { + re_log::error!("Failed to load quick start: {}", err); + } +} + +fn open_markdown_recording( + command_sender: &re_viewer_context::CommandSender, + markdown: impl AsRef, + app_id: impl AsRef, + entity_path: impl AsRef, +) -> anyhow::Result<()> { + let text_doc = re_types::archetypes::TextDocument::new(markdown.as_ref()) + .with_media_type(re_types::components::MediaType::markdown()); + + let row = DataRow::from_archetype( + RowId::random(), + TimePoint::timeless(), + EntityPath::from(entity_path.as_ref()), + &text_doc, + )?; + + let store_info = StoreInfo { + application_id: ApplicationId::from(app_id.as_ref()), + store_id: StoreId::random(StoreKind::Recording), + is_official_example: true, + started: Time::now(), + store_source: StoreSource::InAppGuides, + store_kind: StoreKind::Recording, + }; + + let store_db = StoreDb::from_info_and_rows(store_info, [row])?; + + command_sender.send_system(SystemCommand::LoadStoreDb(store_db)); + + Ok(()) +} From a7bf17deef495714c39d6539e0383e0218094888 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Thu, 12 Oct 2023 16:52:23 +0200 Subject: [PATCH 05/20] Fix rebase + clean code --- crates/re_data_store/src/store_db.rs | 20 +++++++++---------- .../data/quick_start_guides/cpp_native.md | 2 +- .../quick_start_guides/how_does_it_work.md | 2 +- .../data/quick_start_guides/python_native.md | 2 +- .../data/quick_start_guides/rust_native.md | 2 +- .../src/ui/welcome_screen/welcome_page.rs | 2 +- 6 files changed, 14 insertions(+), 16 deletions(-) diff --git a/crates/re_data_store/src/store_db.rs b/crates/re_data_store/src/store_db.rs index 8d0afdb309b7..128caa4e4818 100644 --- a/crates/re_data_store/src/store_db.rs +++ b/crates/re_data_store/src/store_db.rs @@ -245,17 +245,15 @@ impl StoreDb { store_info: StoreInfo, rows: impl IntoIterator, ) -> anyhow::Result { - let arrow_msg = DataTable::from_rows(TableId::random(), rows).to_arrow_msg()?; - let store_id = store_info.store_id.clone(); - let mut store_db = StoreDb::new(store_id.clone()); - store_db.add( - &SetStoreInfo { - row_id: RowId::random(), - info: store_info, - } - .into(), - )?; - store_db.add(&LogMsg::ArrowMsg(store_id, arrow_msg))?; + let mut store_db = StoreDb::new(store_info.store_id.clone()); + + store_db.set_store_info(SetStoreInfo { + row_id: RowId::random(), + info: store_info, + }); + for row in rows { + store_db.add_data_row(&row)?; + } Ok(store_db) } diff --git a/crates/re_viewer/data/quick_start_guides/cpp_native.md b/crates/re_viewer/data/quick_start_guides/cpp_native.md index 60714b19e548..5c1b1a84e183 100644 --- a/crates/re_viewer/data/quick_start_guides/cpp_native.md +++ b/crates/re_viewer/data/quick_start_guides/cpp_native.md @@ -1,3 +1,3 @@ ## C++ Quick Start -TODO(ab) \ No newline at end of file +TODO(ab) diff --git a/crates/re_viewer/data/quick_start_guides/how_does_it_work.md b/crates/re_viewer/data/quick_start_guides/how_does_it_work.md index fd28ee6a7f0f..54171efc8919 100644 --- a/crates/re_viewer/data/quick_start_guides/how_does_it_work.md +++ b/crates/re_viewer/data/quick_start_guides/how_does_it_work.md @@ -1,3 +1,3 @@ ### How does it work? -TBC \ No newline at end of file +TBC diff --git a/crates/re_viewer/data/quick_start_guides/python_native.md b/crates/re_viewer/data/quick_start_guides/python_native.md index c0f7e844b871..f3933859f1ed 100644 --- a/crates/re_viewer/data/quick_start_guides/python_native.md +++ b/crates/re_viewer/data/quick_start_guides/python_native.md @@ -56,4 +56,4 @@ rr.log( # log data as a 3D point cloud archetype rr.Points3D(positions, colors=colors, radii=0.5) ) -``` \ No newline at end of file +``` diff --git a/crates/re_viewer/data/quick_start_guides/rust_native.md b/crates/re_viewer/data/quick_start_guides/rust_native.md index 615db72247c0..dc8a66f1634f 100644 --- a/crates/re_viewer/data/quick_start_guides/rust_native.md +++ b/crates/re_viewer/data/quick_start_guides/rust_native.md @@ -1,3 +1,3 @@ ## Rust Quick Start -TODO(ab) \ No newline at end of file +TODO(ab) diff --git a/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs b/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs index aea4c0014feb..375740e82ed1 100644 --- a/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs +++ b/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs @@ -271,7 +271,7 @@ fn open_quick_start<'a>( entity_path: impl AsRef, ) { let markdown = parts.into_iter().join("\n"); - let res = open_markdown_recording(command_sender, &markdown, app_id, entity_path); + let res = open_markdown_recording(command_sender, markdown, app_id, entity_path); if let Err(err) = res { re_log::error!("Failed to load quick start: {}", err); } From 233248f0cea1d0f524b52c114c85a57c6c9db8cf Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Thu, 12 Oct 2023 17:04:01 +0200 Subject: [PATCH 06/20] Cleaned up API --- crates/re_data_store/src/store_db.rs | 16 +++++++++++++--- crates/re_log_types/src/lib.rs | 6 +++--- crates/re_viewer/src/lib.rs | 2 +- .../src/ui/welcome_screen/welcome_page.rs | 17 ++--------------- crates/re_viewer/src/viewer_analytics.rs | 4 ++-- 5 files changed, 21 insertions(+), 24 deletions(-) diff --git a/crates/re_data_store/src/store_db.rs b/crates/re_data_store/src/store_db.rs index 128caa4e4818..d0b00158d32b 100644 --- a/crates/re_data_store/src/store_db.rs +++ b/crates/re_data_store/src/store_db.rs @@ -5,7 +5,8 @@ use nohash_hasher::IntMap; use re_arrow_store::{DataStoreConfig, GarbageCollectionOptions}; use re_log_types::{ ApplicationId, ComponentPath, DataCell, DataRow, DataTable, EntityPath, EntityPathHash, LogMsg, - PathOp, RowId, SetStoreInfo, StoreId, StoreInfo, StoreKind, TimePoint, Timeline, + PathOp, RowId, SetStoreInfo, StoreId, StoreInfo, StoreKind, StoreSource, Time, TimePoint, + Timeline, }; use re_types::{components::InstanceKey, Loggable as _}; @@ -241,10 +242,19 @@ impl StoreDb { /// /// This is useful to programmatically create recordings from within the viewer, which cannot /// use the `re_sdk`, which is not Wasm-compatible. - pub fn from_info_and_rows( - store_info: StoreInfo, + pub fn from_rows( + app_id: impl Into, rows: impl IntoIterator, ) -> anyhow::Result { + let store_info = StoreInfo { + application_id: app_id.into(), + store_id: StoreId::random(StoreKind::Recording), + is_official_example: true, + started: Time::now(), + store_source: StoreSource::Viewer, + store_kind: StoreKind::Recording, + }; + let mut store_db = StoreDb::new(store_info.store_id.clone()); store_db.set_store_info(SetStoreInfo { diff --git a/crates/re_log_types/src/lib.rs b/crates/re_log_types/src/lib.rs index b116069c1834..ea452e54db25 100644 --- a/crates/re_log_types/src/lib.rs +++ b/crates/re_log_types/src/lib.rs @@ -346,8 +346,8 @@ pub enum StoreSource { file_source: FileSource, }, - /// In-app guides. - InAppGuides, + /// Generated from the viewer itself. + Viewer, /// Perhaps from some manual data ingestion? Other(String), @@ -365,7 +365,7 @@ impl std::fmt::Display for StoreSource { FileSource::DragAndDrop => write!(f, "File via drag-and-drop"), FileSource::FileDialog => write!(f, "File via file dialog"), }, - Self::InAppGuides => write!(f, "In-app guide"), + Self::Viewer => write!(f, "Viewer generated"), Self::Other(string) => format!("{string:?}").fmt(f), // put it in quotes } } diff --git a/crates/re_viewer/src/lib.rs b/crates/re_viewer/src/lib.rs index 33d092768f83..8cb993f9e1f3 100644 --- a/crates/re_viewer/src/lib.rs +++ b/crates/re_viewer/src/lib.rs @@ -105,7 +105,7 @@ impl AppEnvironment { StoreSource::File { .. } | StoreSource::Unknown - | StoreSource::InAppGuides + | StoreSource::Viewer | StoreSource::Other(_) => { // We should not really get here diff --git a/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs b/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs index 375740e82ed1..fe355ca658dc 100644 --- a/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs +++ b/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs @@ -2,10 +2,7 @@ use super::{large_text_button, status_strings, url_large_text_button, WelcomeScr use egui::{NumExt, Ui}; use itertools::Itertools; use re_data_store::StoreDb; -use re_log_types::{ - ApplicationId, DataRow, EntityPath, LogMsg, RowId, StoreId, StoreInfo, StoreKind, StoreSource, - Time, TimePoint, -}; +use re_log_types::{DataRow, EntityPath, LogMsg, RowId, TimePoint}; use re_smart_channel::ReceiveSet; use re_ui::UICommandSender; use re_viewer_context::{SystemCommand, SystemCommandSender}; @@ -293,17 +290,7 @@ fn open_markdown_recording( &text_doc, )?; - let store_info = StoreInfo { - application_id: ApplicationId::from(app_id.as_ref()), - store_id: StoreId::random(StoreKind::Recording), - is_official_example: true, - started: Time::now(), - store_source: StoreSource::InAppGuides, - store_kind: StoreKind::Recording, - }; - - let store_db = StoreDb::from_info_and_rows(store_info, [row])?; - + let store_db = StoreDb::from_rows(app_id.as_ref(), [row])?; command_sender.send_system(SystemCommand::LoadStoreDb(store_db)); Ok(()) diff --git a/crates/re_viewer/src/viewer_analytics.rs b/crates/re_viewer/src/viewer_analytics.rs index 8837f58be811..9317318e7ae0 100644 --- a/crates/re_viewer/src/viewer_analytics.rs +++ b/crates/re_viewer/src/viewer_analytics.rs @@ -181,7 +181,7 @@ impl ViewerAnalytics { re_log_types::FileSource::DragAndDrop => "file_drag_and_drop".to_owned(), re_log_types::FileSource::FileDialog => "file_dialog".to_owned(), }, - StoreSource::InAppGuides => "in_app_guides".to_owned(), + StoreSource::Viewer => "viewer".to_owned(), StoreSource::Other(other) => other.clone(), }; @@ -211,7 +211,7 @@ impl ViewerAnalytics { self.deregister("llvm_version"); // can't be both! } StoreSource::CSdk => {} // TODO(andreas): Send version and set it. - StoreSource::Unknown | StoreSource::InAppGuides | StoreSource::Other(_) => {} + StoreSource::Unknown | StoreSource::Viewer | StoreSource::Other(_) => {} } self.register("store_source", store_source); From d3648db4345b26d1e22f65356a75ce85bfa64d8a Mon Sep 17 00:00:00 2001 From: Antoine Beyeler <49431240+abey79@users.noreply.github.com> Date: Mon, 16 Oct 2023 09:30:06 +0200 Subject: [PATCH 07/20] Update crates/re_log_types/src/lib.rs Co-authored-by: Emil Ernerfeldt --- crates/re_log_types/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/re_log_types/src/lib.rs b/crates/re_log_types/src/lib.rs index ea452e54db25..e7be31e66588 100644 --- a/crates/re_log_types/src/lib.rs +++ b/crates/re_log_types/src/lib.rs @@ -365,7 +365,7 @@ impl std::fmt::Display for StoreSource { FileSource::DragAndDrop => write!(f, "File via drag-and-drop"), FileSource::FileDialog => write!(f, "File via file dialog"), }, - Self::Viewer => write!(f, "Viewer generated"), + Self::Viewer => write!(f, "Viewer-generated"), Self::Other(string) => format!("{string:?}").fmt(f), // put it in quotes } } From c44ac4b949b5775a865e30946cad0b93195fba74 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler <49431240+abey79@users.noreply.github.com> Date: Mon, 16 Oct 2023 09:34:33 +0200 Subject: [PATCH 08/20] Update crates/re_viewer/data/quick_start_guides/python_native.md Co-authored-by: Emil Ernerfeldt --- crates/re_viewer/data/quick_start_guides/python_native.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/re_viewer/data/quick_start_guides/python_native.md b/crates/re_viewer/data/quick_start_guides/python_native.md index f3933859f1ed..19e2a10e4299 100644 --- a/crates/re_viewer/data/quick_start_guides/python_native.md +++ b/crates/re_viewer/data/quick_start_guides/python_native.md @@ -34,7 +34,7 @@ import rerun as rr import numpy as np # Initialize the SDK and give our recording a unique name -rr.init("my_own_data") +rr.init("rerun_example_data") # Connect to a local viewer using the default port rr.connect() From b1cff6b5fe75fbfc5412da06f89bcc58b5ab9405 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Mon, 16 Oct 2023 10:07:16 +0200 Subject: [PATCH 09/20] Addressed review comments --- Cargo.lock | 3 +- crates/re_data_store/Cargo.toml | 1 - crates/re_data_store/src/store_db.rs | 18 +++-------- .../data/quick_start_guides/python_native.md | 4 +-- .../src/ui/welcome_screen/welcome_page.rs | 31 +++++++++++++------ 5 files changed, 28 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 169928469022..eacdec8bee1a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4180,8 +4180,7 @@ dependencies = [ name = "re_data_store" version = "0.10.0-alpha.7+dev" dependencies = [ - "anyhow", - "criterion", +w "criterion", "document-features", "itertools 0.11.0", "mimalloc", diff --git a/crates/re_data_store/Cargo.toml b/crates/re_data_store/Cargo.toml index 84ebfcfc9687..89a8789e199b 100644 --- a/crates/re_data_store/Cargo.toml +++ b/crates/re_data_store/Cargo.toml @@ -34,7 +34,6 @@ re_smart_channel.workspace = true re_tracing.workspace = true re_types.workspace = true -anyhow.workspace = true document-features.workspace = true itertools.workspace = true nohash-hasher.workspace = true diff --git a/crates/re_data_store/src/store_db.rs b/crates/re_data_store/src/store_db.rs index d0b00158d32b..1fc25cd05bd2 100644 --- a/crates/re_data_store/src/store_db.rs +++ b/crates/re_data_store/src/store_db.rs @@ -5,8 +5,7 @@ use nohash_hasher::IntMap; use re_arrow_store::{DataStoreConfig, GarbageCollectionOptions}; use re_log_types::{ ApplicationId, ComponentPath, DataCell, DataRow, DataTable, EntityPath, EntityPathHash, LogMsg, - PathOp, RowId, SetStoreInfo, StoreId, StoreInfo, StoreKind, StoreSource, Time, TimePoint, - Timeline, + PathOp, RowId, SetStoreInfo, StoreId, StoreInfo, StoreKind, TimePoint, Timeline, }; use re_types::{components::InstanceKey, Loggable as _}; @@ -242,19 +241,10 @@ impl StoreDb { /// /// This is useful to programmatically create recordings from within the viewer, which cannot /// use the `re_sdk`, which is not Wasm-compatible. - pub fn from_rows( - app_id: impl Into, + pub fn from_info_and_rows( + store_info: StoreInfo, rows: impl IntoIterator, - ) -> anyhow::Result { - let store_info = StoreInfo { - application_id: app_id.into(), - store_id: StoreId::random(StoreKind::Recording), - is_official_example: true, - started: Time::now(), - store_source: StoreSource::Viewer, - store_kind: StoreKind::Recording, - }; - + ) -> Result { let mut store_db = StoreDb::new(store_info.store_id.clone()); store_db.set_store_info(SetStoreInfo { diff --git a/crates/re_viewer/data/quick_start_guides/python_native.md b/crates/re_viewer/data/quick_start_guides/python_native.md index 19e2a10e4299..d875037f410f 100644 --- a/crates/re_viewer/data/quick_start_guides/python_native.md +++ b/crates/re_viewer/data/quick_start_guides/python_native.md @@ -7,7 +7,7 @@ The Rerun SDK is available on [PyPI](https://pypi.org/) under the Python package: ```sh -pip3 install rerun-sdk +pip install rerun-sdk ``` ### Try out the viewer @@ -16,7 +16,7 @@ The Rerun SDK comes with a demo that can be used to try the viewer. You can send to this viewer using the following command: ```sh -python3 -m rerun_sdk.demo --connect +python -m rerun_sdk.demo --connect ``` This will open a new recording that looks like this: diff --git a/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs b/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs index fe355ca658dc..e472dfd55dc0 100644 --- a/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs +++ b/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs @@ -2,7 +2,9 @@ use super::{large_text_button, status_strings, url_large_text_button, WelcomeScr use egui::{NumExt, Ui}; use itertools::Itertools; use re_data_store::StoreDb; -use re_log_types::{DataRow, EntityPath, LogMsg, RowId, TimePoint}; +use re_log_types::{ + DataRow, EntityPath, LogMsg, RowId, StoreId, StoreInfo, StoreKind, StoreSource, Time, TimePoint, +}; use re_smart_channel::ReceiveSet; use re_ui::UICommandSender; use re_viewer_context::{SystemCommand, SystemCommandSender}; @@ -264,11 +266,11 @@ fn image_banner(ui: &mut egui::Ui, icon: &re_ui::Icon, column_width: f32, max_im fn open_quick_start<'a>( command_sender: &re_viewer_context::CommandSender, parts: impl IntoIterator, - app_id: impl AsRef, - entity_path: impl AsRef, + app_id: &str, + entity_path: &str, ) { let markdown = parts.into_iter().join("\n"); - let res = open_markdown_recording(command_sender, markdown, app_id, entity_path); + let res = open_markdown_recording(command_sender, markdown.as_str(), app_id, entity_path); if let Err(err) = res { re_log::error!("Failed to load quick start: {}", err); } @@ -276,21 +278,30 @@ fn open_quick_start<'a>( fn open_markdown_recording( command_sender: &re_viewer_context::CommandSender, - markdown: impl AsRef, - app_id: impl AsRef, - entity_path: impl AsRef, + markdown: &str, + app_id: &str, + entity_path: &str, ) -> anyhow::Result<()> { - let text_doc = re_types::archetypes::TextDocument::new(markdown.as_ref()) + let text_doc = re_types::archetypes::TextDocument::new(markdown) .with_media_type(re_types::components::MediaType::markdown()); let row = DataRow::from_archetype( RowId::random(), TimePoint::timeless(), - EntityPath::from(entity_path.as_ref()), + EntityPath::from(entity_path), &text_doc, )?; - let store_db = StoreDb::from_rows(app_id.as_ref(), [row])?; + let store_info = StoreInfo { + application_id: app_id.into(), + store_id: StoreId::random(StoreKind::Recording), + is_official_example: true, + started: Time::now(), + store_source: StoreSource::Viewer, + store_kind: StoreKind::Recording, + }; + + let store_db = StoreDb::from_info_and_rows(store_info, [row])?; command_sender.send_system(SystemCommand::LoadStoreDb(store_db)); Ok(()) From 6e2ff143c0850c5c0796008b8505880f4fbc0ba6 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Mon, 16 Oct 2023 10:08:46 +0200 Subject: [PATCH 10/20] Fixed Cargo.lock --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index eacdec8bee1a..e14c6ec94fba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4180,7 +4180,7 @@ dependencies = [ name = "re_data_store" version = "0.10.0-alpha.7+dev" dependencies = [ -w "criterion", + "criterion", "document-features", "itertools 0.11.0", "mimalloc", From 98a0e5bb76d97ece57b45026d77e3878a543d858 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Mon, 16 Oct 2023 15:09:13 +0200 Subject: [PATCH 11/20] Draft for both Python and Rust Quick start guides --- .../data/quick_start_guides/cpp_native.md | 2 +- .../quick_start_guides/how_does_it_work.md | 8 ++- .../data/quick_start_guides/python_native.md | 3 +- .../data/quick_start_guides/rust_native.md | 51 ++++++++++++++++++- .../src/ui/welcome_screen/welcome_page.rs | 27 ++++++---- 5 files changed, 75 insertions(+), 16 deletions(-) diff --git a/crates/re_viewer/data/quick_start_guides/cpp_native.md b/crates/re_viewer/data/quick_start_guides/cpp_native.md index 5c1b1a84e183..9ecf1ce33907 100644 --- a/crates/re_viewer/data/quick_start_guides/cpp_native.md +++ b/crates/re_viewer/data/quick_start_guides/cpp_native.md @@ -1,3 +1,3 @@ ## C++ Quick Start -TODO(ab) +TODO(ab): https://github.com/rerun-io/rerun/issues/3870 diff --git a/crates/re_viewer/data/quick_start_guides/how_does_it_work.md b/crates/re_viewer/data/quick_start_guides/how_does_it_work.md index 54171efc8919..b61c4551efa5 100644 --- a/crates/re_viewer/data/quick_start_guides/how_does_it_work.md +++ b/crates/re_viewer/data/quick_start_guides/how_does_it_work.md @@ -1,3 +1,9 @@ ### How does it work? -TBC +Rerun's goal is to make handling and visualizing multimodal data streams easy and performant. + +Rerun is made of two main building blocks: the SDK and the Viewer. The data provided by the user code is serialised by the SDK and transferred (via a log file, a TCP socket, a WebSocket, etc.) to the Viewer process for visualization. You can learn more about Rerun's operating modes [here](https://www.rerun.io/docs/reference/sdk-operating-modes). + +In the example above, the SDK connects via a TCP socket to the present viewer. + +The `log()` function logs _entities_ represented by the "entity path" provided as first argument. Entities are a collection of _components_, which hold the actual data such as position, color, or pixel data. _Archetypes_ such as `Points3D` are builder objects which help creating entities with a consistent set of components that are recognized by the Viewer (they can be entirely bypassed when required by advanced use-cases). You can learn more about Rerun's data model [here](https://www.rerun.io/docs/concepts/entity-component). \ No newline at end of file diff --git a/crates/re_viewer/data/quick_start_guides/python_native.md b/crates/re_viewer/data/quick_start_guides/python_native.md index d875037f410f..8e72605cefba 100644 --- a/crates/re_viewer/data/quick_start_guides/python_native.md +++ b/crates/re_viewer/data/quick_start_guides/python_native.md @@ -26,8 +26,7 @@ This will open a new recording that looks like this: ### Logging your own data -Instead of a pre-packaged demo, you can log your own data. Copy and paste the following snippet in a new -Python file and execute it to create a new recording in this viewer: +Instead of a pre-packaged demo, you can log your own data. Copy and paste the following snippet in a new Python file and execute it to create a new recording in this viewer: ```python import rerun as rr diff --git a/crates/re_viewer/data/quick_start_guides/rust_native.md b/crates/re_viewer/data/quick_start_guides/rust_native.md index dc8a66f1634f..c938b6b9e2ee 100644 --- a/crates/re_viewer/data/quick_start_guides/rust_native.md +++ b/crates/re_viewer/data/quick_start_guides/rust_native.md @@ -1,3 +1,52 @@ ## Rust Quick Start -TODO(ab) +### Installing Rerun + +To use the Rerun SDK in your project, you need the [rerun crate](https://crates.io/crates/rerun) which you can add with `cargo add rerun`. + +Let's try it out in a brand-new Rust project: + +```sh +cargo init cube && cd cube && cargo add rerun --features native_viewer +``` + +Note that the Rerun SDK requires a working installation of Rust 1.72+. + +### Logging your own data + +Add the following code to your `main.rs` file: + +```rust +use rerun::{demo_util::grid, external::glam}; + +fn main() -> Result<(), Box> { + // Create a new `RecordingStream` which sends data over TCP to the viewer process. + let rec = rerun::RecordingStreamBuilder::new("rerun_example_demo_rs") + .connect("127.0.0.1:9876".parse()?, None)?; + + // Create some data using the `grid` utility function. + let points = grid(glam::Vec3::splat(-10.0), glam::Vec3::splat(10.0), 10); + let colors = grid(glam::Vec3::ZERO, glam::Vec3::splat(255.0), 10) + .map(|v| rerun::Color::from_rgb(v.x as u8, v.y as u8, v.z as u8)); + + // Log the "my_points" entity with our data, using the `Points3D` archetype. + rec.log( + "my_points", + &rerun::Points3D::new(points) + .with_colors(colors) + .with_radii([0.5]), + )?; + + Ok(()) +} +``` + +You can now your application: + +```shell +cargo run +``` + +Once everything finishes compiling, you will see the points in this viewer: + +![Demo recording](https://static.rerun.io/intro_rust_result/cc780eb9bf014d8b1a68fac174b654931f92e14f/768w.png) \ No newline at end of file diff --git a/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs b/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs index e472dfd55dc0..edff128f70b4 100644 --- a/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs +++ b/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs @@ -60,16 +60,21 @@ fn onboarding_content_ui( Visualize synchronized data from multiple processes, locally or over a network.", image: &re_ui::icons::WELCOME_SCREEN_LIVE_DATA, add_buttons: Box::new(|ui: &mut egui::Ui| { - if large_text_button(ui, "C++").clicked() { - open_quick_start( - command_sender, - [ - include_str!("../../../data/quick_start_guides/cpp_native.md"), - include_str!("../../../data/quick_start_guides/how_does_it_work.md"), - ], - "C++ Quick Start", - "cpp_quick_start", - ); + //TODO(#3870): enable with C++ guides are completed + if false { + if large_text_button(ui, "C++").clicked() { + open_quick_start( + command_sender, + [ + include_str!("../../../data/quick_start_guides/cpp_native.md"), + include_str!( + "../../../data/quick_start_guides/how_does_it_work.md" + ), + ], + "C++ Quick Start", + "cpp_quick_start", + ); + } } if large_text_button(ui, "Python").clicked() { open_quick_start( @@ -133,7 +138,7 @@ fn onboarding_content_ui( }, ]; - // Shrink images if needed so user can see all of the content buttons + // Shrink images if needed so user can see all the content buttons let max_image_height = ui.available_height() - 300.0; let centering_vspace = (ui.available_height() - 650.0) / 2.0; From 520d2a510ad982ffe9995f390cde86346520c670 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Mon, 16 Oct 2023 15:15:48 +0200 Subject: [PATCH 12/20] Fix lint --- crates/re_viewer/data/quick_start_guides/cpp_native.md | 2 +- crates/re_viewer/data/quick_start_guides/how_does_it_work.md | 2 +- crates/re_viewer/data/quick_start_guides/rust_native.md | 2 +- crates/re_viewer/src/ui/welcome_screen/welcome_page.rs | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/re_viewer/data/quick_start_guides/cpp_native.md b/crates/re_viewer/data/quick_start_guides/cpp_native.md index 9ecf1ce33907..6e96eb5cd031 100644 --- a/crates/re_viewer/data/quick_start_guides/cpp_native.md +++ b/crates/re_viewer/data/quick_start_guides/cpp_native.md @@ -1,3 +1,3 @@ ## C++ Quick Start -TODO(ab): https://github.com/rerun-io/rerun/issues/3870 +TODO(ab): https://github.com/rerun-io/rerun/issues/3870 diff --git a/crates/re_viewer/data/quick_start_guides/how_does_it_work.md b/crates/re_viewer/data/quick_start_guides/how_does_it_work.md index b61c4551efa5..b252be0d1640 100644 --- a/crates/re_viewer/data/quick_start_guides/how_does_it_work.md +++ b/crates/re_viewer/data/quick_start_guides/how_does_it_work.md @@ -6,4 +6,4 @@ Rerun is made of two main building blocks: the SDK and the Viewer. The data prov In the example above, the SDK connects via a TCP socket to the present viewer. -The `log()` function logs _entities_ represented by the "entity path" provided as first argument. Entities are a collection of _components_, which hold the actual data such as position, color, or pixel data. _Archetypes_ such as `Points3D` are builder objects which help creating entities with a consistent set of components that are recognized by the Viewer (they can be entirely bypassed when required by advanced use-cases). You can learn more about Rerun's data model [here](https://www.rerun.io/docs/concepts/entity-component). \ No newline at end of file +The `log()` function logs _entities_ represented by the "entity path" provided as first argument. Entities are a collection of _components_, which hold the actual data such as position, color, or pixel data. _Archetypes_ such as `Points3D` are builder objects which help creating entities with a consistent set of components that are recognized by the Viewer (they can be entirely bypassed when required by advanced use-cases). You can learn more about Rerun's data model [here](https://www.rerun.io/docs/concepts/entity-component). diff --git a/crates/re_viewer/data/quick_start_guides/rust_native.md b/crates/re_viewer/data/quick_start_guides/rust_native.md index c938b6b9e2ee..d5085e2ae020 100644 --- a/crates/re_viewer/data/quick_start_guides/rust_native.md +++ b/crates/re_viewer/data/quick_start_guides/rust_native.md @@ -49,4 +49,4 @@ cargo run Once everything finishes compiling, you will see the points in this viewer: -![Demo recording](https://static.rerun.io/intro_rust_result/cc780eb9bf014d8b1a68fac174b654931f92e14f/768w.png) \ No newline at end of file +![Demo recording](https://static.rerun.io/intro_rust_result/cc780eb9bf014d8b1a68fac174b654931f92e14f/768w.png) diff --git a/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs b/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs index edff128f70b4..74e3c6a0a88c 100644 --- a/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs +++ b/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs @@ -61,6 +61,7 @@ fn onboarding_content_ui( image: &re_ui::icons::WELCOME_SCREEN_LIVE_DATA, add_buttons: Box::new(|ui: &mut egui::Ui| { //TODO(#3870): enable with C++ guides are completed + #[allow(clippy::collapsible_if)] if false { if large_text_button(ui, "C++").clicked() { open_quick_start( From 0a5e841ced1cd16c1f7f32ad8f42782d974640ce Mon Sep 17 00:00:00 2001 From: Antoine Beyeler <49431240+abey79@users.noreply.github.com> Date: Mon, 16 Oct 2023 15:42:47 +0200 Subject: [PATCH 13/20] Update crates/re_viewer/data/quick_start_guides/rust_native.md Co-authored-by: Emil Ernerfeldt --- crates/re_viewer/data/quick_start_guides/rust_native.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/re_viewer/data/quick_start_guides/rust_native.md b/crates/re_viewer/data/quick_start_guides/rust_native.md index d5085e2ae020..66dbba506b38 100644 --- a/crates/re_viewer/data/quick_start_guides/rust_native.md +++ b/crates/re_viewer/data/quick_start_guides/rust_native.md @@ -41,7 +41,7 @@ fn main() -> Result<(), Box> { } ``` -You can now your application: +You can now run your application: ```shell cargo run From 20332231b5c130bf281d1d918bb8d1d9626b1ab6 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Mon, 16 Oct 2023 16:06:44 +0200 Subject: [PATCH 14/20] Moved code examples to runnable, stand-alone files --- .../data/quick_start_guides/python_native.md | 27 +------------------ .../data/quick_start_guides/rust_native.md | 23 +--------------- .../src/ui/welcome_screen/welcome_page.rs | 14 +++++++++- docs/code-examples/Cargo.toml | 8 ++++-- docs/code-examples/quick_start_connect.cpp | 4 +++ docs/code-examples/quick_start_connect.py | 26 ++++++++++++++++++ docs/code-examples/quick_start_connect.rs | 22 +++++++++++++++ 7 files changed, 73 insertions(+), 51 deletions(-) create mode 100644 docs/code-examples/quick_start_connect.cpp create mode 100644 docs/code-examples/quick_start_connect.py create mode 100644 docs/code-examples/quick_start_connect.rs diff --git a/crates/re_viewer/data/quick_start_guides/python_native.md b/crates/re_viewer/data/quick_start_guides/python_native.md index 8e72605cefba..6c33bde8ba82 100644 --- a/crates/re_viewer/data/quick_start_guides/python_native.md +++ b/crates/re_viewer/data/quick_start_guides/python_native.md @@ -29,30 +29,5 @@ This will open a new recording that looks like this: Instead of a pre-packaged demo, you can log your own data. Copy and paste the following snippet in a new Python file and execute it to create a new recording in this viewer: ```python -import rerun as rr -import numpy as np - -# Initialize the SDK and give our recording a unique name -rr.init("rerun_example_data") - -# Connect to a local viewer using the default port -rr.connect() - - -# Create some data -SIZE = 10 - -pos_grid = np.meshgrid(*[np.linspace(-10, 10, SIZE)]*3) -positions = np.vstack([d.reshape(-1) for d in pos_grid]).T - -col_grid = np.meshgrid(*[np.linspace(0, 255, SIZE)]*3) -colors = np.vstack([c.reshape(-1) for c in col_grid]).astype(np.uint8).T - -# Log the data -rr.log( - # name under which this entity is logged (known as "entity path") - "my_points", - # log data as a 3D point cloud archetype - rr.Points3D(positions, colors=colors, radii=0.5) -) +${EXAMPLE_CODE} ``` diff --git a/crates/re_viewer/data/quick_start_guides/rust_native.md b/crates/re_viewer/data/quick_start_guides/rust_native.md index 66dbba506b38..6fc3b86d96a3 100644 --- a/crates/re_viewer/data/quick_start_guides/rust_native.md +++ b/crates/re_viewer/data/quick_start_guides/rust_native.md @@ -17,28 +17,7 @@ Note that the Rerun SDK requires a working installation of Rust 1.72+. Add the following code to your `main.rs` file: ```rust -use rerun::{demo_util::grid, external::glam}; - -fn main() -> Result<(), Box> { - // Create a new `RecordingStream` which sends data over TCP to the viewer process. - let rec = rerun::RecordingStreamBuilder::new("rerun_example_demo_rs") - .connect("127.0.0.1:9876".parse()?, None)?; - - // Create some data using the `grid` utility function. - let points = grid(glam::Vec3::splat(-10.0), glam::Vec3::splat(10.0), 10); - let colors = grid(glam::Vec3::ZERO, glam::Vec3::splat(255.0), 10) - .map(|v| rerun::Color::from_rgb(v.x as u8, v.y as u8, v.z as u8)); - - // Log the "my_points" entity with our data, using the `Points3D` archetype. - rec.log( - "my_points", - &rerun::Points3D::new(points) - .with_colors(colors) - .with_radii([0.5]), - )?; - - Ok(()) -} +${EXAMPLE_CODE} ``` You can now run your application: diff --git a/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs b/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs index 74e3c6a0a88c..61a6d2a9ae24 100644 --- a/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs +++ b/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs @@ -72,6 +72,9 @@ fn onboarding_content_ui( "../../../data/quick_start_guides/how_does_it_work.md" ), ], + include_str!( + "../../../../../docs/code-examples/quick_start_connect.cpp" + ), "C++ Quick Start", "cpp_quick_start", ); @@ -84,6 +87,7 @@ fn onboarding_content_ui( include_str!("../../../data/quick_start_guides/python_native.md"), include_str!("../../../data/quick_start_guides/how_does_it_work.md"), ], + include_str!("../../../../../docs/code-examples/quick_start_connect.py"), "Python Quick Start", "python_quick_start", ); @@ -95,6 +99,7 @@ fn onboarding_content_ui( include_str!("../../../data/quick_start_guides/rust_native.md"), include_str!("../../../data/quick_start_guides/how_does_it_work.md"), ], + include_str!("../../../../../docs/code-examples/quick_start_connect.rs"), "Rust Quick Start", "rust_quick_start", ); @@ -269,13 +274,20 @@ fn image_banner(ui: &mut egui::Ui, icon: &re_ui::Icon, column_width: f32, max_im }); } +/// Open a Quick Start recording +/// +/// The `parts` are joined with newlines to form the markdown, and the spacial tag +/// `"${EXAMPLE_CODE}"` is replaced with the content of th `example_code` variable. fn open_quick_start<'a>( command_sender: &re_viewer_context::CommandSender, parts: impl IntoIterator, + example_code: &str, app_id: &str, entity_path: &str, ) { - let markdown = parts.into_iter().join("\n"); + let mut markdown = parts.into_iter().join("\n"); + markdown = markdown.replace("${EXAMPLE_CODE}", example_code); + let res = open_markdown_recording(command_sender, markdown.as_str(), app_id, entity_path); if let Err(err) = res { re_log::error!("Failed to load quick start: {}", err); diff --git a/docs/code-examples/Cargo.toml b/docs/code-examples/Cargo.toml index a96c166ab052..33a3f2c7b139 100644 --- a/docs/code-examples/Cargo.toml +++ b/docs/code-examples/Cargo.toml @@ -35,6 +35,10 @@ path = "asset3d_simple.rs" name = "asset3d_out_of_tree" path = "asset3d_out_of_tree.rs" +[[bin]] +name = "box2d_simple" +path = "box2d_simple.rs" + [[bin]] name = "box3d_simple" path = "box3d_simple.rs" @@ -132,8 +136,8 @@ name = "point3d_simple" path = "point3d_simple.rs" [[bin]] -name = "box2d_simple" -path = "box2d_simple.rs" +name = "quick_start_connect" +path = "quick_start_connect.rs" [[bin]] name = "scalar_simple" diff --git a/docs/code-examples/quick_start_connect.cpp b/docs/code-examples/quick_start_connect.cpp new file mode 100644 index 000000000000..5d77e68d2592 --- /dev/null +++ b/docs/code-examples/quick_start_connect.cpp @@ -0,0 +1,4 @@ +// TODO(ab): https://github.com/rerun-io/rerun/issues/3870 + +void main() { +} diff --git a/docs/code-examples/quick_start_connect.py b/docs/code-examples/quick_start_connect.py new file mode 100644 index 000000000000..9a5152e9898f --- /dev/null +++ b/docs/code-examples/quick_start_connect.py @@ -0,0 +1,26 @@ +import rerun as rr +import numpy as np + +# Initialize the SDK and give our recording a unique name +rr.init("rerun_example_demo_py") + +# Connect to a local viewer using the default port +rr.connect() + + +# Create some data +SIZE = 10 + +pos_grid = np.meshgrid(*[np.linspace(-10, 10, SIZE)] * 3) +positions = np.vstack([d.reshape(-1) for d in pos_grid]).T + +col_grid = np.meshgrid(*[np.linspace(0, 255, SIZE)] * 3) +colors = np.vstack([c.reshape(-1) for c in col_grid]).astype(np.uint8).T + +# Log the data +rr.log( + # name under which this entity is logged (known as "entity path") + "my_points", + # log data as a 3D point cloud archetype + rr.Points3D(positions, colors=colors, radii=0.5), +) diff --git a/docs/code-examples/quick_start_connect.rs b/docs/code-examples/quick_start_connect.rs new file mode 100644 index 000000000000..4e5e1e937912 --- /dev/null +++ b/docs/code-examples/quick_start_connect.rs @@ -0,0 +1,22 @@ +use rerun::{demo_util::grid, external::glam}; + +fn main() -> Result<(), Box> { + // Create a new `RecordingStream` which sends data over TCP to the viewer process. + let rec = rerun::RecordingStreamBuilder::new("rerun_example_demo_rs") + .connect("127.0.0.1:9876".parse()?, None)?; + + // Create some data using the `grid` utility function. + let points = grid(glam::Vec3::splat(-10.0), glam::Vec3::splat(10.0), 10); + let colors = grid(glam::Vec3::ZERO, glam::Vec3::splat(255.0), 10) + .map(|v| rerun::Color::from_rgb(v.x as u8, v.y as u8, v.z as u8)); + + // Log the "my_points" entity with our data, using the `Points3D` archetype. + rec.log( + "my_points", + &rerun::Points3D::new(points) + .with_colors(colors) + .with_radii([0.5]), + )?; + + Ok(()) +} From 80c590923be54078f240262f8005f87ba9f7c3ff Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Mon, 16 Oct 2023 16:25:49 +0200 Subject: [PATCH 15/20] Symlinked to code example from inside re_viewer/data --- .../data/quick_start_guides/quick_start_connect.cpp | 1 + .../data/quick_start_guides/quick_start_connect.py | 1 + .../data/quick_start_guides/quick_start_connect.rs | 1 + crates/re_viewer/src/ui/welcome_screen/welcome_page.rs | 6 +++--- docs/code-examples/quick_start_connect.py | 2 ++ docs/code-examples/quick_start_connect.rs | 2 ++ 6 files changed, 10 insertions(+), 3 deletions(-) create mode 120000 crates/re_viewer/data/quick_start_guides/quick_start_connect.cpp create mode 120000 crates/re_viewer/data/quick_start_guides/quick_start_connect.py create mode 120000 crates/re_viewer/data/quick_start_guides/quick_start_connect.rs diff --git a/crates/re_viewer/data/quick_start_guides/quick_start_connect.cpp b/crates/re_viewer/data/quick_start_guides/quick_start_connect.cpp new file mode 120000 index 000000000000..2b9e140cfbfc --- /dev/null +++ b/crates/re_viewer/data/quick_start_guides/quick_start_connect.cpp @@ -0,0 +1 @@ +../../../../docs/code-examples/quick_start_connect.cpp \ No newline at end of file diff --git a/crates/re_viewer/data/quick_start_guides/quick_start_connect.py b/crates/re_viewer/data/quick_start_guides/quick_start_connect.py new file mode 120000 index 000000000000..b64a5733fea1 --- /dev/null +++ b/crates/re_viewer/data/quick_start_guides/quick_start_connect.py @@ -0,0 +1 @@ +../../../../docs/code-examples/quick_start_connect.py \ No newline at end of file diff --git a/crates/re_viewer/data/quick_start_guides/quick_start_connect.rs b/crates/re_viewer/data/quick_start_guides/quick_start_connect.rs new file mode 120000 index 000000000000..8458ae676f31 --- /dev/null +++ b/crates/re_viewer/data/quick_start_guides/quick_start_connect.rs @@ -0,0 +1 @@ +../../../../docs/code-examples/quick_start_connect.rs \ No newline at end of file diff --git a/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs b/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs index 61a6d2a9ae24..cdab927e19a1 100644 --- a/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs +++ b/crates/re_viewer/src/ui/welcome_screen/welcome_page.rs @@ -73,7 +73,7 @@ fn onboarding_content_ui( ), ], include_str!( - "../../../../../docs/code-examples/quick_start_connect.cpp" + "../../../data/quick_start_guides/quick_start_connect.cpp" ), "C++ Quick Start", "cpp_quick_start", @@ -87,7 +87,7 @@ fn onboarding_content_ui( include_str!("../../../data/quick_start_guides/python_native.md"), include_str!("../../../data/quick_start_guides/how_does_it_work.md"), ], - include_str!("../../../../../docs/code-examples/quick_start_connect.py"), + include_str!("../../../data/quick_start_guides/quick_start_connect.py"), "Python Quick Start", "python_quick_start", ); @@ -99,7 +99,7 @@ fn onboarding_content_ui( include_str!("../../../data/quick_start_guides/rust_native.md"), include_str!("../../../data/quick_start_guides/how_does_it_work.md"), ], - include_str!("../../../../../docs/code-examples/quick_start_connect.rs"), + include_str!("../../../data/quick_start_guides/quick_start_connect.rs"), "Rust Quick Start", "rust_quick_start", ); diff --git a/docs/code-examples/quick_start_connect.py b/docs/code-examples/quick_start_connect.py index 9a5152e9898f..967d819cebec 100644 --- a/docs/code-examples/quick_start_connect.py +++ b/docs/code-examples/quick_start_connect.py @@ -1,3 +1,5 @@ +"""Connect to the viewer and log some data.""" + import rerun as rr import numpy as np diff --git a/docs/code-examples/quick_start_connect.rs b/docs/code-examples/quick_start_connect.rs index 4e5e1e937912..c8b3ed1cdbe7 100644 --- a/docs/code-examples/quick_start_connect.rs +++ b/docs/code-examples/quick_start_connect.rs @@ -1,3 +1,5 @@ +//! Connect to the viewer and log some data. + use rerun::{demo_util::grid, external::glam}; fn main() -> Result<(), Box> { From 948e12c35e2d272385e558dc1bda0739eaac1a7e Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Mon, 16 Oct 2023 16:47:58 +0200 Subject: [PATCH 16/20] Fixed lint --- docs/code-examples/quick_start_connect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/code-examples/quick_start_connect.py b/docs/code-examples/quick_start_connect.py index 967d819cebec..ba54ac8d24db 100644 --- a/docs/code-examples/quick_start_connect.py +++ b/docs/code-examples/quick_start_connect.py @@ -1,7 +1,7 @@ """Connect to the viewer and log some data.""" -import rerun as rr import numpy as np +import rerun as rr # Initialize the SDK and give our recording a unique name rr.init("rerun_example_demo_py") From d001714eee82afb8764bab41e4b27c1d08a01e14 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Mon, 16 Oct 2023 16:51:23 +0200 Subject: [PATCH 17/20] Fixed cpp lint --- docs/code-examples/quick_start_connect.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/code-examples/quick_start_connect.cpp b/docs/code-examples/quick_start_connect.cpp index 5d77e68d2592..e8c7c8edccd5 100644 --- a/docs/code-examples/quick_start_connect.cpp +++ b/docs/code-examples/quick_start_connect.cpp @@ -1,4 +1,5 @@ // TODO(ab): https://github.com/rerun-io/rerun/issues/3870 -void main() { +int main() { + return 0; } From ec75677264e84a4b911ece03c11489fc8b5d1823 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Mon, 16 Oct 2023 17:07:20 +0200 Subject: [PATCH 18/20] Disabled roundtrips for quick start example code --- docs/code-examples/roundtrips.py | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/code-examples/roundtrips.py b/docs/code-examples/roundtrips.py index f850daff880d..a619226257ba 100755 --- a/docs/code-examples/roundtrips.py +++ b/docs/code-examples/roundtrips.py @@ -36,6 +36,7 @@ "log_line": ["cpp", "rust", "py"], # Not a complete example -- just a single log line "mesh3d_partial_updates": ["cpp"], # TODO(cmc): cannot set recording clock in cpp at the moment "pinhole_simple": ["cpp"], # TODO(#2919): Seg-faults in C++ + "quick_start_connect": [], # These are example scripts not for round-trips "scalar_multiple_plots": ["cpp"], # TODO(#2919): Not yet implemented in C++ "scalar_simple": ["cpp"], # TODO(#2919): Not yet implemented in C++ "segmentation_image_simple": ["cpp"], # TODO(#2919): Not yet implemented in C++ From 788865e74a96f7d8be6abce3805d065df096b78a Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Mon, 16 Oct 2023 17:14:01 +0200 Subject: [PATCH 19/20] Re-enabled quick start for rs and py --- docs/code-examples/quick_start_connect.py | 2 +- docs/code-examples/quick_start_connect.rs | 2 +- docs/code-examples/roundtrips.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/code-examples/quick_start_connect.py b/docs/code-examples/quick_start_connect.py index ba54ac8d24db..543fbc4fe813 100644 --- a/docs/code-examples/quick_start_connect.py +++ b/docs/code-examples/quick_start_connect.py @@ -4,7 +4,7 @@ import rerun as rr # Initialize the SDK and give our recording a unique name -rr.init("rerun_example_demo_py") +rr.init("rerun_example_demo") # Connect to a local viewer using the default port rr.connect() diff --git a/docs/code-examples/quick_start_connect.rs b/docs/code-examples/quick_start_connect.rs index c8b3ed1cdbe7..e5f4665a6609 100644 --- a/docs/code-examples/quick_start_connect.rs +++ b/docs/code-examples/quick_start_connect.rs @@ -4,7 +4,7 @@ use rerun::{demo_util::grid, external::glam}; fn main() -> Result<(), Box> { // Create a new `RecordingStream` which sends data over TCP to the viewer process. - let rec = rerun::RecordingStreamBuilder::new("rerun_example_demo_rs") + let rec = rerun::RecordingStreamBuilder::new("rerun_example_demo") .connect("127.0.0.1:9876".parse()?, None)?; // Create some data using the `grid` utility function. diff --git a/docs/code-examples/roundtrips.py b/docs/code-examples/roundtrips.py index a619226257ba..c7f286914116 100755 --- a/docs/code-examples/roundtrips.py +++ b/docs/code-examples/roundtrips.py @@ -36,7 +36,7 @@ "log_line": ["cpp", "rust", "py"], # Not a complete example -- just a single log line "mesh3d_partial_updates": ["cpp"], # TODO(cmc): cannot set recording clock in cpp at the moment "pinhole_simple": ["cpp"], # TODO(#2919): Seg-faults in C++ - "quick_start_connect": [], # These are example scripts not for round-trips + "quick_start_connect": ["cpp"], # TODO(#3870): Not yet implemented in C++ "scalar_multiple_plots": ["cpp"], # TODO(#2919): Not yet implemented in C++ "scalar_simple": ["cpp"], # TODO(#2919): Not yet implemented in C++ "segmentation_image_simple": ["cpp"], # TODO(#2919): Not yet implemented in C++ From 2bfbd670319ffba52ef2559673855a890d9c359d Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Mon, 16 Oct 2023 17:41:53 +0200 Subject: [PATCH 20/20] Opt-out compare. --- docs/code-examples/roundtrips.py | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/code-examples/roundtrips.py b/docs/code-examples/roundtrips.py index c7f286914116..569d44ec040c 100755 --- a/docs/code-examples/roundtrips.py +++ b/docs/code-examples/roundtrips.py @@ -59,6 +59,7 @@ "pinhole_simple": ["cpp", "py", "rust"], # TODO(#3206): need to align everything to use PCG64 in the same order etc... don't have time for that. "point2d_random": ["cpp", "py", "rust"], # TODO(#3206): need to align everything to use PCG64 in the same order etc... don't have time for that. "point3d_random": ["cpp", "py", "rust"], # TODO(#3206): need to align everything to use PCG64 in the same order etc... don't have time for that. + "quick_start_connect": ["cpp", "py", "rust"], # The implementation can be different as they are just examples for the end user. "tensor_simple": ["cpp", "py", "rust"], # TODO(#3206): need to align everything to use PCG64 in the same order etc... don't have time for that. "transform3d_simple": ["cpp"], # TODO(#2919): Something broken in the C++ SDK }