Skip to content

Commit

Permalink
Fix spawn starting the viewer even if logging is disabled (#5284)
Browse files Browse the repository at this point in the history
### What

* Fixes #5261

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using newly built examples:
[app.rerun.io](https://app.rerun.io/pr/5284/index.html)
* Using examples from latest `main` build:
[app.rerun.io](https://app.rerun.io/pr/5284/index.html?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[app.rerun.io](https://app.rerun.io/pr/5284/index.html?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!

- [PR Build Summary](https://build.rerun.io/pr/5284)
- [Docs
preview](https://rerun.io/preview/c659f5a29d6a439bcf11756099e7e9338561774a/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/c659f5a29d6a439bcf11756099e7e9338561774a/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
  • Loading branch information
Wumpf authored Feb 26, 2024
1 parent e507462 commit 76ded9b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
22 changes: 19 additions & 3 deletions crates/re_sdk/src/recording_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@ impl RecordingStreamBuilder {
opts: &crate::SpawnOptions,
flush_timeout: Option<std::time::Duration>,
) -> RecordingStreamResult<RecordingStream> {
if !self.is_enabled() {
re_log::debug!("Rerun disabled - call to spawn() ignored");
return Ok(RecordingStream::disabled());
}

let connect_addr = opts.connect_addr();

// NOTE: If `_RERUN_TEST_FORCE_SAVE` is set, all recording streams will write to disk no matter
Expand Down Expand Up @@ -517,18 +522,19 @@ impl RecordingStreamBuilder {
/// This can be used to then construct a [`RecordingStream`] manually using
/// [`RecordingStream::new`].
pub fn into_args(self) -> (bool, StoreInfo, DataTableBatcherConfig) {
let enabled = self.is_enabled();

let Self {
application_id,
store_kind,
store_id,
store_source,
default_enabled,
enabled,
default_enabled: _,
enabled: _,
batcher_config,
is_official_example,
} = self;

let enabled = enabled.unwrap_or_else(|| crate::decide_logging_enabled(default_enabled));
let store_id = store_id.unwrap_or(StoreId::random(store_kind));
let store_source = store_source.unwrap_or_else(|| StoreSource::RustSdk {
rustc_version: env!("RE_BUILD_RUSTC_VERSION").into(),
Expand All @@ -555,6 +561,12 @@ impl RecordingStreamBuilder {

(enabled, store_info, batcher_config)
}

/// Internal check for whether or not logging is enabled using explicit/default settings & env var.
fn is_enabled(&self) -> bool {
self.enabled
.unwrap_or_else(|| crate::decide_logging_enabled(self.default_enabled))
}
}

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -1350,6 +1362,10 @@ impl RecordingStream {
opts: &crate::SpawnOptions,
flush_timeout: Option<std::time::Duration>,
) -> RecordingStreamResult<()> {
if !self.is_enabled() {
re_log::debug!("Rerun disabled - call to spawn() ignored");
return Ok(());
}
if forced_sink_path().is_some() {
re_log::debug!("Ignored setting new TcpSink since _RERUN_FORCE_SINK is set");
return Ok(());
Expand Down
4 changes: 4 additions & 0 deletions rerun_py/rerun_sdk/rerun/sinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ def spawn(
"""

if not bindings.is_enabled():
logging.warning("Rerun is disabled - spawn() call ignored.")
return

import os
import subprocess
import sys
Expand Down

0 comments on commit 76ded9b

Please sign in to comment.