Skip to content

Commit

Permalink
Untangle re_protos dependencies (rerun-io#8381)
Browse files Browse the repository at this point in the history
  • Loading branch information
jprochazk authored Dec 10, 2024
1 parent 671b510 commit e67b84a
Show file tree
Hide file tree
Showing 31 changed files with 1,124 additions and 780 deletions.
10 changes: 7 additions & 3 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5659,6 +5659,7 @@ dependencies = [
"re_log",
"re_log_encoding",
"re_log_types",
"re_protos",
"re_tracing",
"re_types",
"re_types_core",
Expand Down Expand Up @@ -5927,6 +5928,7 @@ dependencies = [
"re_chunk",
"re_error",
"re_log",
"re_log_encoding",
"re_log_types",
"re_protos",
"re_smart_channel",
Expand Down Expand Up @@ -5973,10 +5975,12 @@ dependencies = [
"lz4_flex",
"mimalloc",
"parking_lot",
"re_arrow2",
"re_build_info",
"re_chunk",
"re_log",
"re_log_types",
"re_protos",
"re_smart_channel",
"re_tracing",
"re_types",
Expand Down Expand Up @@ -6012,6 +6016,7 @@ dependencies = [
"re_build_info",
"re_format",
"re_log",
"re_protos",
"re_string_interner",
"re_tracing",
"re_tuid",
Expand Down Expand Up @@ -6077,9 +6082,6 @@ name = "re_protos"
version = "0.21.0-alpha.1+dev"
dependencies = [
"prost",
"re_arrow2",
"re_dataframe",
"re_log_types",
"thiserror",
"tonic",
"tonic-web-wasm-client",
Expand Down Expand Up @@ -6613,6 +6615,7 @@ dependencies = [
"document-features",
"getrandom",
"once_cell",
"re_protos",
"serde",
"web-time",
]
Expand Down Expand Up @@ -7271,6 +7274,7 @@ dependencies = [
"re_chunk_store",
"re_dataframe",
"re_log",
"re_log_encoding",
"re_log_types",
"re_memory",
"re_protos",
Expand Down
2 changes: 1 addition & 1 deletion crates/build/re_protos_builder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Part of the [`rerun`](https://github.com/rerun-io/rerun) family of crates.

Code generation for Rerun's Protobuf and gRPC definitions.

You can generate the code with `pixi run codegen-rstore`.
You can generate the code with `pixi run codegen-protos`.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! This binary runs the remote store gRPC service codegen manually.
//!
//! It is easiest to call this using `pixi run codegen-rstore`,
//! It is easiest to call this using `pixi run codegen-protos`,
//! which will set up the necessary tools.
#![allow(clippy::unwrap_used)]
Expand Down
18 changes: 14 additions & 4 deletions crates/build/re_protos_builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,34 @@
//! definitions in the same file.
//!
#![allow(clippy::unwrap_used)]
#![allow(clippy::unwrap_used, clippy::exit)]

use std::path::Path;

/// Generate rust from protobuf definitions. We rely on `tonic_build` to do the heavy lifting.
/// `tonic_build` relies on `prost` which itself relies on `protoc`.
///
/// Note: make sure to invoke this via `pixi run codegen-rstore` in order to use the right `protoc` version.
/// Note: make sure to invoke this via `pixi run codegen-protos` in order to use the right `protoc` version.
pub fn generate_rust_code(
definitions_dir: impl AsRef<Path>,
proto_paths: &[impl AsRef<Path>],
output_dir: impl AsRef<Path>,
) {
tonic_build::configure()
if let Err(err) = tonic_build::configure()
.out_dir(output_dir.as_ref())
.build_client(true)
.build_server(true)
.build_transport(false) // Small convenience, but doesn't work on web
.compile_protos(proto_paths, &[definitions_dir])
.unwrap();
{
match err.kind() {
std::io::ErrorKind::Other => {
eprintln!("Failed to generate protobuf types:\n{err}");
std::process::exit(1);
}
_ => {
panic!("{err:?}");
}
}
}
}
3 changes: 2 additions & 1 deletion crates/store/re_chunk_store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@ default = []
## Enables `parking_lot`'s deadlock detection background thread.
deadlock_detection = ["parking_lot/deadlock_detection"]


[dependencies]
# Rerun dependencies:
re_chunk.workspace = true
re_format.workspace = true
re_log = { workspace = true, features = ["setup"] }
re_log_encoding = { workspace = true, features = ["decoder"] }
re_log_types.workspace = true
re_protos.workspace = true
re_tracing.workspace = true
re_types_core.workspace = true


# External dependencies:
ahash.workspace = true
anyhow.workspace = true
Expand Down
39 changes: 35 additions & 4 deletions crates/store/re_chunk_store/src/dataframe.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//! All the APIs used specifically for `re_dataframe`.
use std::collections::{BTreeMap, BTreeSet};
use std::ops::Deref;
use std::ops::DerefMut;

use arrow2::{
array::ListArray as ArrowListArray,
Expand All @@ -10,9 +12,7 @@ use itertools::Itertools;

use re_chunk::TimelineName;
use re_log_types::{ComponentPath, EntityPath, ResolvedTimeRange, TimeInt, Timeline};
use re_types_core::{
ArchetypeFieldName, ArchetypeName, ComponentDescriptor, ComponentName, ComponentNameSet,
};
use re_types_core::{ArchetypeFieldName, ArchetypeName, ComponentDescriptor, ComponentName};

use crate::{ChunkStore, ColumnMetadata};

Expand Down Expand Up @@ -493,7 +493,38 @@ impl std::fmt::Display for SparseFillStrategy {
///
// TODO(cmc): we need to be able to build that easily in a command-line context, otherwise it's just
// very annoying. E.g. `--with /world/points:[rr.Position3D, rr.Radius] --with /cam:[rr.Pinhole]`.
pub type ViewContentsSelector = BTreeMap<EntityPath, Option<ComponentNameSet>>;
#[derive(Default, Debug, Clone, PartialEq, Eq, Hash)]
pub struct ViewContentsSelector(pub BTreeMap<EntityPath, Option<BTreeSet<ComponentName>>>);

impl ViewContentsSelector {
pub fn into_inner(self) -> BTreeMap<EntityPath, Option<BTreeSet<ComponentName>>> {
self.0
}
}

impl Deref for ViewContentsSelector {
type Target = BTreeMap<EntityPath, Option<BTreeSet<ComponentName>>>;

#[inline]
fn deref(&self) -> &Self::Target {
&self.0
}
}

impl DerefMut for ViewContentsSelector {
#[inline]
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}

impl FromIterator<(EntityPath, Option<BTreeSet<ComponentName>>)> for ViewContentsSelector {
fn from_iter<T: IntoIterator<Item = (EntityPath, Option<BTreeSet<ComponentName>>)>>(
iter: T,
) -> Self {
Self(iter.into_iter().collect())
}
}

// TODO(cmc): Ultimately, this shouldn't be hardcoded to `Timeline`, but to a generic `I: Index`.
// `Index` in this case should also be implemented on tuples (`(I1, I2, ...)`).
Expand Down
2 changes: 2 additions & 0 deletions crates/store/re_chunk_store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ mod store;
mod subscribers;
mod writes;

mod protobuf_conversions;

pub use self::dataframe::{
ColumnDescriptor, ColumnSelector, ComponentColumnDescriptor, ComponentColumnSelector, Index,
IndexRange, IndexValue, QueryExpression, SparseFillStrategy, TimeColumnDescriptor,
Expand Down
Loading

0 comments on commit e67b84a

Please sign in to comment.