Skip to content

Commit

Permalink
Improve the docs of connect and serve (#1450)
Browse files Browse the repository at this point in the history
* Improve the docs of `connect` and `serve`

* Fix doctest
  • Loading branch information
emilk authored Mar 1, 2023
1 parent 22d2933 commit cb1783b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
1 change: 1 addition & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ doc-valid-idents = [
"sRGB",
"sRGBA",
"WebGL",
"WebSockets",
]
25 changes: 21 additions & 4 deletions crates/re_sdk/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,23 @@ impl Session {
self.recording_source = recording_source;
}

/// Send log data to a remote server.
/// Send log data to a remote viewer/server.
///
/// Usually this is done by running the `rerun` binary (`cargo install rerun`) without arguments,
/// and then connecting to it.
///
/// Send all currently buffered messages.
/// If we are already connected, we will re-connect to this new address.
///
/// This function returns immediately.
/// Disconnect with [`Self::disconnect`].
///
/// ## Example:
///
/// ``` no_run
/// # let mut session = re_sdk::Session::new();
/// session.connect(re_sdk::default_server_addr());
/// ```
pub fn connect(&mut self, addr: SocketAddr) {
if !self.enabled {
re_log::debug!("Rerun disabled - call to connect() ignored");
Expand Down Expand Up @@ -209,10 +220,16 @@ impl Session {
}
}

/// Serve a Rerun web viewer and stream the log messages to it.
/// Serve log-data over WebSockets and serve a Rerun web viewer over HTTP.
///
/// If the `open_browser` argument is `true`, your default browser
/// will be opened with a connected web-viewer.
///
/// If not, you can connect to this server using the `rerun` binary (`cargo install rerun`).
///
/// NOTE: you can not connect one `Session` to another.
///
/// If the `open_browser` argument is set, your default browser
/// will be opened to show the viewer.
/// This function returns immediately.
#[cfg(feature = "web_viewer")]
pub fn serve(&mut self, open_browser: bool) {
if !self.enabled {
Expand Down
2 changes: 1 addition & 1 deletion crates/re_viewer/src/remote_viewer_app.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::App;

/// Connects to a server over `WebSockets`.
/// Connects to a server over WebSockets.
pub struct RemoteViewerApp {
build_info: re_build_info::BuildInfo,
app_env: crate::AppEnvironment,
Expand Down
8 changes: 7 additions & 1 deletion rerun_py/rerun_sdk/rerun/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ def connect(addr: Optional[str] = None) -> None:
Requires that you first start a Rerun Viewer, e.g. with 'python -m rerun'
This function returns immediately.
Parameters
----------
addr
Expand Down Expand Up @@ -287,10 +289,14 @@ def spawn(port: int = 9876, connect: bool = True) -> None:

def serve(open_browser: bool = True) -> None:
"""
Serve a Rerun Web Viewer.
Serve log-data over WebSockets and serve a Rerun web viewer over HTTP.
You can connect to this server using `python -m rerun`.
WARNING: This is an experimental feature.
This function returns immediately.
Parameters
----------
open_browser
Expand Down

1 comment on commit cb1783b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rust Benchmark

Benchmark suite Current: cb1783b Previous: 22d2933 Ratio
datastore/insert/batch/rects/insert 537220 ns/iter (± 19353) 561224 ns/iter (± 3393) 0.96
datastore/latest_at/batch/rects/query 1743 ns/iter (± 25) 1808 ns/iter (± 0) 0.96
datastore/latest_at/missing_components/primary 344 ns/iter (± 4) 355 ns/iter (± 0) 0.97
datastore/latest_at/missing_components/secondaries 408 ns/iter (± 6) 425 ns/iter (± 0) 0.96
datastore/range/batch/rects/query 146707 ns/iter (± 1732) 153509 ns/iter (± 144) 0.96
mono_points_arrow/generate_message_bundles 44698006 ns/iter (± 1165970) 49057592 ns/iter (± 451123) 0.91
mono_points_arrow/generate_messages 132761896 ns/iter (± 1834953) 126258636 ns/iter (± 1110947) 1.05
mono_points_arrow/encode_log_msg 164429504 ns/iter (± 1307931) 160300514 ns/iter (± 1503238) 1.03
mono_points_arrow/encode_total 344972798 ns/iter (± 2488450) 335908634 ns/iter (± 3944654) 1.03
mono_points_arrow/decode_log_msg 180321929 ns/iter (± 1854326) 179111801 ns/iter (± 1724081) 1.01
mono_points_arrow/decode_message_bundles 70036243 ns/iter (± 1475520) 66237559 ns/iter (± 766356) 1.06
mono_points_arrow/decode_total 248830965 ns/iter (± 2955044) 240825550 ns/iter (± 1405790) 1.03
batch_points_arrow/generate_message_bundles 320945 ns/iter (± 4653) 333061 ns/iter (± 854) 0.96
batch_points_arrow/generate_messages 6012 ns/iter (± 88) 6193 ns/iter (± 23) 0.97
batch_points_arrow/encode_log_msg 350148 ns/iter (± 2491) 356587 ns/iter (± 1978) 0.98
batch_points_arrow/encode_total 683589 ns/iter (± 5872) 723416 ns/iter (± 2454) 0.94
batch_points_arrow/decode_log_msg 341917 ns/iter (± 3074) 352234 ns/iter (± 1725) 0.97
batch_points_arrow/decode_message_bundles 2024 ns/iter (± 28) 2079 ns/iter (± 6) 0.97
batch_points_arrow/decode_total 347441 ns/iter (± 3079) 360489 ns/iter (± 2268) 0.96
arrow_mono_points/insert 6744343365 ns/iter (± 18982185) 6159944691 ns/iter (± 21248035) 1.09
arrow_mono_points/query 1678376 ns/iter (± 19327) 1744756 ns/iter (± 21616) 0.96
arrow_batch_points/insert 2546167 ns/iter (± 23141) 2748562 ns/iter (± 39606) 0.93
arrow_batch_points/query 17169 ns/iter (± 395) 17716 ns/iter (± 21) 0.97
tuid/Tuid::random 33 ns/iter (± 0) 36 ns/iter (± 0) 0.92

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.