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

Move prost codegen to outdir #545

Merged
merged 5 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
8 changes: 1 addition & 7 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,10 @@ docs-rebuild = { depends_on = ["docs-clean", "docs-build"] }
docs-serve = { cmd = "python -m http.server --directory docs/build/html 8000" }
docs-publish = { cmd = "./sync_docs.sh", depends_on = ["docs-rebuild"], cwd = "docs" }

# Note: the `--no-verify` flag below for `vegafusion-core` is due to this cargo publish error:
#
# Source directory was modified by build.rs during cargo publish. Build scripts should not modify anything outside of OUT_DIR.
#
# We currently write the prost files to src (mostly to make it easier for IDEs to locate them). This should be safe in our case
# as these aren't modified unless the .proto files change, but we should revisit where these files are written in the future.
[tasks.publish-rs]
cmd = """
cargo publish -p vegafusion-common &&
cargo publish -p vegafusion-core --no-verify &&
cargo publish -p vegafusion-core &&
cargo publish -p vegafusion-dataframe &&
cargo publish -p vegafusion-datafusion-udfs &&
cargo publish -p vegafusion-sql &&
Expand Down
4 changes: 1 addition & 3 deletions vegafusion-common/src/data/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,7 @@ impl VegaFusionTable {
}

pub fn get_hash(&self) -> u64 {
let mut hasher = RandomState::with_seed(123).build_hasher();
self.hash(&mut hasher);
hasher.finish()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

also ran clippy --fix

RandomState::with_seed(123).hash_one(self)
}
}

Expand Down
6 changes: 0 additions & 6 deletions vegafusion-core/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ fn main() {
std::env::set_var("PROTOC", protobuf_src::protoc());

let mut prost_config = prost_build::Config::new();
let outdir = concat!(env!("CARGO_MANIFEST_DIR"), "/src/proto/prost_gen");
println!("outdir: {outdir}");
let prost_config = prost_config.out_dir(outdir);

prost_config
.protoc_arg("--experimental_allow_proto3_optional")
Expand All @@ -32,9 +29,6 @@ fn main() {
#[cfg(feature = "tonic_support")]
fn gen_tonic() {
let builder = tonic_build::configure();
let outdir = concat!(env!("CARGO_MANIFEST_DIR"), "/src/proto/tonic_gen");
println!("outdir: {outdir}");
let builder = builder.out_dir(outdir);

let mut config = prost_build::Config::new();
config.protoc_arg("--experimental_allow_proto3_optional");
Expand Down
9 changes: 4 additions & 5 deletions vegafusion-core/src/chart_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl ChartState {
plan.comm_plan
.server_to_client
.iter()
.map(|scoped_var| task_graph_mapping.get(scoped_var).unwrap().clone())
.map(|scoped_var| *task_graph_mapping.get(scoped_var).unwrap())
.collect(),
);

Expand All @@ -91,7 +91,7 @@ impl ChartState {
.comm_plan
.server_to_client
.iter()
.map(|var| task_graph_mapping.get(var).unwrap().clone())
.map(|var| *task_graph_mapping.get(var).unwrap())
.collect();

let response_task_values = runtime
Expand Down Expand Up @@ -144,11 +144,10 @@ impl ChartState {
ExportUpdateNamespace::Data => Variable::new_data(&export_update.name),
};
let scoped_var: ScopedVariable = (var, export_update.scope.clone());
let node_value_index = self
let node_value_index = *self
.task_graph_mapping
.get(&scoped_var)
.with_context(|| format!("No task graph node found for {scoped_var:?}"))?
.clone();
.with_context(|| format!("No task graph node found for {scoped_var:?}"))?;

let value = match export_update.namespace {
ExportUpdateNamespace::Signal => {
Expand Down
2 changes: 1 addition & 1 deletion vegafusion-core/src/data/dataset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl VegaFusionDataset {

pub fn from_table_ipc_bytes(ipc_bytes: &[u8]) -> Result<Self> {
// Hash ipc bytes
let hash = ahash::RandomState::with_seed(123).hash_one(&ipc_bytes);
let hash = ahash::RandomState::with_seed(123).hash_one(ipc_bytes);
let table = VegaFusionTable::from_ipc_bytes(ipc_bytes)?;
Ok(Self::Table { table, hash })
}
Expand Down
10 changes: 5 additions & 5 deletions vegafusion-core/src/expression/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ pub fn parse_unary(
let rhs = perform_parse(tokens, unary_bp, full_expr)?;
let new_span = Span {
start: start as i32,
end: rhs.span.clone().unwrap().end,
end: rhs.span.unwrap().end,
};
let expr = Expr::from(UnaryExpression::new(&op, rhs));
Ok(Expression::new(expr, Some(new_span)))
Expand Down Expand Up @@ -229,7 +229,7 @@ pub fn parse_binary(
// Update lhs
let new_span = Span {
start: start as i32,
end: rhs.span.clone().unwrap().end,
end: rhs.span.unwrap().end,
};
let expr = Expr::from(BinaryExpression::new(lhs.clone(), &op, rhs));
Ok(Expression::new(expr, Some(new_span)))
Expand Down Expand Up @@ -259,7 +259,7 @@ pub fn parse_logical(
// Update lhs
let new_span = Span {
start: start as i32,
end: rhs.span.clone().unwrap().end,
end: rhs.span.unwrap().end,
};
let expr = Expr::from(LogicalExpression::new(lhs.clone(), &op, rhs));
Ok(Expression::new(expr, Some(new_span)))
Expand Down Expand Up @@ -375,7 +375,7 @@ pub fn parse_static_member(
// Update span
let new_span = Span {
start: start as i32,
end: property.span.clone().unwrap().end,
end: property.span.unwrap().end,
};

let expr = match MemberExpression::new_static(lhs.clone(), property) {
Expand Down Expand Up @@ -427,7 +427,7 @@ pub fn parse_ternary(
// Update span
let new_span = Span {
start: start as i32,
end: alternate.span.clone().unwrap().end,
end: alternate.span.unwrap().end,
};

let expr = Expr::from(ConditionalExpression::new(
Expand Down
24 changes: 24 additions & 0 deletions vegafusion-core/src/proto/gen.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Create separate modules for each proto component
pub mod errors {
include!(concat!(env!("OUT_DIR"), "/errors.rs"));
}

pub mod expression {
include!(concat!(env!("OUT_DIR"), "/expression.rs"));
}

pub mod pretransform {
include!(concat!(env!("OUT_DIR"), "/pretransform.rs"));
}

pub mod services {
include!(concat!(env!("OUT_DIR"), "/services.rs"));
}

pub mod tasks {
include!(concat!(env!("OUT_DIR"), "/tasks.rs"));
}

pub mod transforms {
include!(concat!(env!("OUT_DIR"), "/transforms.rs"));
}
10 changes: 1 addition & 9 deletions vegafusion-core/src/proto/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
#[cfg(not(feature = "tonic_support"))]
pub mod prost_gen;
#[cfg(not(feature = "tonic_support"))]
pub use prost_gen as gen;

#[cfg(feature = "tonic_support")]
pub mod tonic_gen;
#[cfg(feature = "tonic_support")]
pub use tonic_gen as gen;
pub mod gen;
19 changes: 0 additions & 19 deletions vegafusion-core/src/proto/prost_gen/errors.rs

This file was deleted.

Loading
Loading