remove old structs

This commit is contained in:
Stuart Axelbrooke 2025-07-06 13:17:00 -07:00
parent 28500fb956
commit c379d44d37
2 changed files with 11 additions and 79 deletions

View file

@ -1,6 +1,5 @@
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test", "rust_binary")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_test")
# Simple proto for testing
proto_library(
@ -9,18 +8,17 @@ proto_library(
visibility = ["//visibility:public"],
)
# Prost generator binary for converting proto files to Rust code
rust_binary(
name = "prost_generator",
srcs = ["prost_generator.rs"],
edition = "2021",
deps = [
"@crates//:prost",
"@crates//:prost-build",
"@crates//:tempfile",
"@crates//:serde",
"@crates//:tempfile",
],
edition = "2021",
)
# Generate Rust code for simple proto using prost generator
@ -28,14 +26,13 @@ genrule(
name = "generate_simple_rust",
srcs = ["simple.proto"],
outs = ["simple.rs"],
cmd = "PROTOC=$(location @com_google_protobuf//:protoc) $(location :prost_generator) $(location simple.proto) /dev/null $@",
tools = [
":prost_generator",
"@com_google_protobuf//:protoc",
],
cmd = "PROTOC=$(location @com_google_protobuf//:protoc) $(location :prost_generator) $(location simple.proto) /dev/null $@",
)
# Test the simple generation
rust_test(
name = "simple_test",
@ -43,15 +40,14 @@ rust_test(
"simple_test.rs",
":generate_simple_rust",
],
edition = "2021",
deps = [
"@crates//:prost",
"@crates//:serde",
"@crates//:serde_json",
],
edition = "2021",
)
# Generate Rust code for databuild proto
genrule(
name = "generate_databuild_rust",
@ -59,28 +55,28 @@ genrule(
"databuild.proto",
],
outs = ["databuild.rs"],
cmd = "PROTOC=$(location @com_google_protobuf//:protoc) $(location :prost_generator) $(location databuild.proto) /dev/null $@",
tools = [
":prost_generator",
"@com_google_protobuf//:protoc",
],
cmd = "PROTOC=$(location @com_google_protobuf//:protoc) $(location :prost_generator) $(location databuild.proto) /dev/null $@",
)
# DataBuild library using generated prost code
rust_library(
name = "databuild",
srcs = [
"lib.rs",
# "lib.rs",
":generate_databuild_rust",
"structs.rs",
# "structs.rs",
],
edition = "2021",
visibility = ["//visibility:public"],
deps = [
"@crates//:prost",
"@crates//:prost-types",
"@crates//:serde",
],
edition = "2021",
visibility = ["//visibility:public"],
)
# Test the databuild generation
@ -90,12 +86,12 @@ rust_test(
"databuild_test.rs",
":generate_databuild_rust",
],
edition = "2021",
deps = [
"@crates//:prost",
"@crates//:serde",
"@crates//:serde_json",
],
edition = "2021",
)
# Legacy filegroup for backwards compatibility
@ -104,4 +100,3 @@ filegroup(
srcs = ["databuild.proto"],
visibility = ["//visibility:public"],
)

View file

@ -1,63 +0,0 @@
use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use std::str::FromStr;
// Data structures that follow the protobuf specification exactly
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PartitionRef {
#[serde(rename = "str")]
pub str: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum DepType {
#[serde(rename = "QUERY")]
Query = 0,
#[serde(rename = "MATERIALIZE")]
Materialize = 1,
}
impl FromStr for DepType {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_uppercase().as_str() {
"QUERY" => Ok(DepType::Query),
"MATERIALIZE" => Ok(DepType::Materialize),
_ => Err(format!("Unknown DepType: {}", s)),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DataDep {
pub dep_type: u32, // Protobuf enums are serialized as integers
pub partition_ref: PartitionRef,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct JobConfig {
pub inputs: Vec<DataDep>,
pub outputs: Vec<PartitionRef>,
pub args: Vec<String>,
pub env: HashMap<String, String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct JobConfigureResponse {
pub configs: Vec<JobConfig>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Task {
#[serde(rename = "jobLabel")]
pub job_label: String,
pub config: JobConfig,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct JobGraph {
pub outputs: Vec<String>,
pub nodes: Vec<Task>,
}