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

MVP Blueprint APIs for layout and contents #5408

Merged
merged 28 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cf850e7
Initial script to create a trivial blueprint
jleibs Mar 5, 2024
324ede6
No required components for viewport
jleibs Mar 6, 2024
8dcfa6d
codegen
jleibs Mar 6, 2024
a68ba10
Handle space view containers as being optional
jleibs Mar 6, 2024
038fa66
Remove name and streamline containers
jleibs Mar 6, 2024
3acfbde
More fun example
jleibs Mar 6, 2024
6069e93
Fix viewport_blueprint test
jleibs Mar 6, 2024
55fee82
format
jleibs Mar 6, 2024
c914f55
Connect can now take a blueprint
jleibs Mar 7, 2024
79dbd92
Pass blueprint into connect
jleibs Mar 7, 2024
030cae8
Use new connect-based blueprint passing
jleibs Mar 7, 2024
b52f6b1
Support blueprint with init
jleibs Mar 7, 2024
d419df9
Move new helpers into blueprint/api
jleibs Mar 8, 2024
5fac94b
More convenience
jleibs Mar 8, 2024
1768af4
Cleanup and docstrings
jleibs Mar 8, 2024
a141ab0
lint
jleibs Mar 8, 2024
6664cf3
lints
jleibs Mar 8, 2024
a468201
Fix docstring / remove TODO
jleibs Mar 8, 2024
d98c5e4
Fix circular import
jleibs Mar 8, 2024
17fc16f
Add grid to example
jleibs Mar 8, 2024
4f7c992
Support for row/col shares
jleibs Mar 8, 2024
4e1d5be
Fix application_id for blueprint when not using default stream
jleibs Mar 11, 2024
81ba906
Merge branch 'main' into jleibs/blueprint_test
jleibs Mar 12, 2024
aac180e
Clarify the path is in the blueprint tree
jleibs Mar 12, 2024
5c6dcc8
Add TODO for proper extension
jleibs Mar 12, 2024
61917c1
Crosslinks
jleibs Mar 12, 2024
7d3400f
Doc row/col shares
jleibs Mar 12, 2024
9a4aff2
typos
jleibs Mar 12, 2024
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
20 changes: 17 additions & 3 deletions crates/re_sdk/src/recording_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,11 @@ impl RecordingStream {
/// terms of data durability and ordering.
/// See [`Self::set_sink`] for more information.
pub fn connect(&self) {
self.connect_opts(crate::default_server_addr(), crate::default_flush_timeout());
self.connect_opts(
crate::default_server_addr(),
crate::default_flush_timeout(),
None,
);
}

/// Swaps the underlying sink for a [`crate::log_sink::TcpSink`] sink pre-configured to use
Expand All @@ -1539,13 +1543,23 @@ impl RecordingStream {
&self,
addr: std::net::SocketAddr,
flush_timeout: Option<std::time::Duration>,
blueprint: Option<Vec<LogMsg>>,
) {
if forced_sink_path().is_some() {
re_log::debug!("Ignored setting new TcpSink since _RERUN_FORCE_SINK is set");
return;
}

self.set_sink(Box::new(crate::log_sink::TcpSink::new(addr, flush_timeout)));
let sink = crate::log_sink::TcpSink::new(addr, flush_timeout);

// If a blueprint was provided, send it first.
if let Some(blueprint) = blueprint {
for msg in blueprint {
sink.send(msg);
}
}

self.set_sink(Box::new(sink));
}

/// Spawns a new Rerun Viewer process from an executable available in PATH, then swaps the
Expand Down Expand Up @@ -1598,7 +1612,7 @@ impl RecordingStream {

spawn(opts)?;

self.connect_opts(opts.connect_addr(), flush_timeout);
self.connect_opts(opts.connect_addr(), flush_timeout, None);

Ok(())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ table ViewportBlueprint (
) {
// --- Required ---

/// All of the space-views that belong to the viewport.
space_views: [rerun.blueprint.components.IncludedSpaceView] ("attr.rerun.component_required", order: 1000);

// --- Optional ---
/// All of the space-views that belong to the viewport.
space_views: [rerun.blueprint.components.IncludedSpaceView] ("attr.rerun.component_optional", nullable, order: 1000);

/// The layout of the space-views
root_container: rerun.blueprint.components.RootContainer ("attr.rerun.component_optional", nullable, order: 2500);
Expand Down
62 changes: 37 additions & 25 deletions crates/re_viewport/src/blueprint/archetypes/viewport_blueprint.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions crates/re_viewport/src/viewport_blueprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,11 @@ impl ViewportBlueprint {
}
};

let space_view_ids: Vec<SpaceViewId> =
space_views.into_iter().map(|id| id.0.into()).collect();
let space_view_ids: Vec<SpaceViewId> = space_views
.unwrap_or(vec![])
.iter()
.map(|id| id.0.into())
.collect();

let space_views: BTreeMap<SpaceViewId, SpaceViewBlueprint> = space_view_ids
.into_iter()
Expand Down
2 changes: 1 addition & 1 deletion crates/rerun_c/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ fn rr_recording_stream_connect_impl(
} else {
None
};
stream.connect_opts(tcp_addr, flush_timeout);
stream.connect_opts(tcp_addr, flush_timeout, None);

Ok(())
}
Expand Down
5 changes: 1 addition & 4 deletions examples/python/blueprint/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
"""Example of using the blueprint APIs to configure Rerun."""
# TODO(jleibs): Update this example to use the new APIs
from __future__ import annotations

import argparse
Expand All @@ -26,15 +27,11 @@ def main() -> None:
rr.init(
"Blueprint demo",
init_logging=False,
exp_init_blueprint=not args.skip_blueprint,
exp_add_to_app_default_blueprint=args.no_append_default,
spawn=True,
)
else:
rr.init(
"Blueprint demo",
exp_init_blueprint=not args.skip_blueprint,
exp_add_to_app_default_blueprint=args.no_append_default,
spawn=True,
)

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions rerun_cpp/src/rerun/blueprint/archetypes/viewport_blueprint.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 6 additions & 17 deletions rerun_py/rerun_sdk/rerun/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
ViewCoordinates,
)
from .archetypes.boxes2d_ext import Box2DFormat
from .blueprint.api import BlueprintLike
from .components import (
Material,
MediaType,
Expand Down Expand Up @@ -230,6 +231,7 @@ def _init_recording_stream() -> None:
set_time_nanos,
disable_timeline,
reset_time,
log,
]
+ [fn for name, fn in getmembers(sys.modules[__name__], isfunction) if name.startswith("log_")]
)
Expand All @@ -247,8 +249,7 @@ def init(
init_logging: bool = True,
default_enabled: bool = True,
strict: bool = False,
exp_init_blueprint: bool = False,
exp_add_to_app_default_blueprint: bool = True,
blueprint: BlueprintLike | None = None,
) -> None:
"""
Initialize the Rerun SDK with a user-chosen application id (name).
Expand Down Expand Up @@ -316,10 +317,8 @@ def init(
strict
If `True`, an exceptions is raised on use error (wrong parameter types, etc.).
If `False`, errors are logged as warnings instead.
exp_init_blueprint
(Experimental) Should we initialize the blueprint for this application?
exp_add_to_app_default_blueprint
(Experimental) Should the blueprint append to the existing app-default blueprint instead of creating a new one.
blueprint
A blueprint to use for this application. If not provided, a new one will be created.

"""

Expand All @@ -346,21 +345,11 @@ def init(
spawn=False,
default_enabled=default_enabled,
)
if exp_init_blueprint:
experimental.new_blueprint(
application_id=application_id,
blueprint_id=recording_id,
make_default=True,
make_thread_default=False,
spawn=False,
add_to_app_default_blueprint=exp_add_to_app_default_blueprint,
default_enabled=default_enabled,
)

if spawn:
from rerun.sinks import spawn as _spawn

_spawn()
_spawn(blueprint=blueprint)


# TODO(#3793): defaulting recording_id to authkey should be opt-in
Expand Down
3 changes: 3 additions & 0 deletions rerun_py/rerun_sdk/rerun/_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ def log_components(
if None, use the global default from `rerun.strict_mode()`

"""
# Convert to a native recording
recording = RecordingStream.to_native(recording)
Copy link
Member Author

Choose a reason for hiding this comment

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

This was just an error before on this API. Apparently we don't use stream-overrides in any of our other examples.


instanced: dict[str, pa.Array] = {}
splats: dict[str, pa.Array] = {}

Expand Down
15 changes: 14 additions & 1 deletion rerun_py/rerun_sdk/rerun/blueprint/__init__.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading