Skip to content

Commit da96095

Browse files
committed
Move datasets from setup to create_tables in system adapter protocol
1 parent f0bfd69 commit da96095

5 files changed

Lines changed: 22 additions & 23 deletions

File tree

crates/system-adapter-protocol/src/client.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,10 @@ impl Client {
179179
pub async fn setup(
180180
&mut self,
181181
run_id: uuid::Uuid,
182-
datasets: std::collections::HashMap<String, crate::DatasetConfig>,
183182
metadata: std::collections::HashMap<String, serde_json::Value>,
184183
) -> Result<crate::SetupResponse> {
185184
let request = crate::SetupRequest {
186185
run_id,
187-
datasets,
188186
metadata,
189187
};
190188
let rpc_request = JsonRpcRequest::new(1, crate::methods::SETUP, request);
@@ -198,8 +196,9 @@ impl Client {
198196
pub async fn create_tables(
199197
&mut self,
200198
run_id: uuid::Uuid,
199+
datasets: std::collections::HashMap<String, crate::DatasetConfig>,
201200
) -> Result<crate::CreateTablesResponse> {
202-
let request = crate::CreateTablesRequest { run_id };
201+
let request = crate::CreateTablesRequest { run_id, datasets };
203202
let rpc_request = JsonRpcRequest::new(1, crate::methods::CREATE_TABLES, request);
204203
let response = self.call_typed(rpc_request).await?;
205204
response

crates/system-adapter-protocol/src/lib.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ limitations under the License.
4141
//!
4242
//! // Setup a benchmark run
4343
//! let run_id = Uuid::new_v4();
44-
//! let setup_response = client.setup(run_id, HashMap::new(), HashMap::new()).await?;
45-
//! let create_tables_response = client.create_tables(run_id).await?;
44+
//! let setup_response = client.setup(run_id, HashMap::new()).await?;
45+
//! let create_tables_response = client.create_tables(run_id, HashMap::new()).await?;
4646
//!
4747
//! println!("Driver: {:?}", setup_response.driver);
4848
//!
@@ -72,7 +72,6 @@ limitations under the License.
7272
//! async fn setup(
7373
//! &mut self,
7474
//! run_id: Uuid,
75-
//! datasets: HashMap<String, DatasetConfig>,
7675
//! metadata: HashMap<String, serde_json::Value>,
7776
//! ) -> Result<SetupResponse, String> {
7877
//! // Your setup logic here
@@ -83,7 +82,11 @@ limitations under the License.
8382
//! })
8483
//! }
8584
//!
86-
//! async fn create_tables(&mut self, run_id: Uuid) -> Result<CreateTablesResponse, String> {
85+
//! async fn create_tables(
86+
//! &mut self,
87+
//! run_id: Uuid,
88+
//! datasets: HashMap<String, DatasetConfig>,
89+
//! ) -> Result<CreateTablesResponse, String> {
8790
//! Ok(CreateTablesResponse { ok: true })
8891
//! }
8992
//!
@@ -149,8 +152,6 @@ pub struct DatasetConfig {
149152
pub struct SetupRequest {
150153
/// Unique identifier for this benchmark run
151154
pub run_id: Uuid,
152-
/// Map of dataset name to dataset definition
153-
pub datasets: HashMap<String, DatasetConfig>,
154155
/// Arbitrary run metadata propagated from spicebench to adapters
155156
#[serde(default)]
156157
pub metadata: HashMap<String, serde_json::Value>,
@@ -172,6 +173,8 @@ pub struct SetupResponse {
172173
pub struct CreateTablesRequest {
173174
/// Unique identifier for this benchmark run
174175
pub run_id: Uuid,
176+
/// Map of dataset name to dataset definition
177+
pub datasets: HashMap<String, DatasetConfig>,
175178
}
176179

177180
/// Response from create_tables request

crates/system-adapter-protocol/src/server.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ pub trait Handler: Send + Sync {
7575
async fn setup(
7676
&mut self,
7777
run_id: Uuid,
78-
datasets: HashMap<String, DatasetConfig>,
7978
metadata: HashMap<String, serde_json::Value>,
8079
) -> std::result::Result<SetupResponse, String>;
8180

8281
/// Create benchmark tables for a run
8382
async fn create_tables(
8483
&mut self,
8584
run_id: Uuid,
85+
datasets: HashMap<String, DatasetConfig>,
8686
) -> std::result::Result<CreateTablesResponse, String>;
8787

8888
/// Teardown a benchmark run
@@ -244,7 +244,7 @@ impl<H: Handler> Server<H> {
244244
};
245245
Self::handler_response(
246246
self.handler
247-
.setup(req.run_id, req.datasets, req.metadata)
247+
.setup(req.run_id, req.metadata)
248248
.await,
249249
id,
250250
)
@@ -259,7 +259,7 @@ impl<H: Handler> Server<H> {
259259
Ok(r) => r,
260260
Err(e) => return e,
261261
};
262-
Self::handler_response(self.handler.create_tables(req.run_id).await, id)
262+
Self::handler_response(self.handler.create_tables(req.run_id, req.datasets).await, id)
263263
}
264264

265265
async fn handle_teardown(
@@ -304,7 +304,6 @@ mod tests {
304304
async fn setup(
305305
&mut self,
306306
_run_id: Uuid,
307-
_datasets: HashMap<String, DatasetConfig>,
308307
_metadata: HashMap<String, serde_json::Value>,
309308
) -> std::result::Result<SetupResponse, String> {
310309
Ok(SetupResponse {
@@ -316,6 +315,7 @@ mod tests {
316315
async fn create_tables(
317316
&mut self,
318317
_run_id: Uuid,
318+
_datasets: HashMap<String, DatasetConfig>,
319319
) -> std::result::Result<CreateTablesResponse, String> {
320320
Ok(CreateTablesResponse { ok: true })
321321
}
@@ -335,7 +335,7 @@ mod tests {
335335
#[tokio::test]
336336
async fn test_server_setup() {
337337
let mut server = Server::new(TestHandler);
338-
let request = r#"{"jsonrpc":"2.0","id":1,"method":"setup","params":{"run_id":"00000000-0000-0000-0000-000000000000","datasets":{},"metadata":{}}}"#;
338+
let request = r#"{"jsonrpc":"2.0","id":1,"method":"setup","params":{"run_id":"00000000-0000-0000-0000-000000000000","metadata":{}}}"#;
339339
let response = server.handle_request(request).await;
340340

341341
assert!(response.get("result").is_some());

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ async fn main() -> anyhow::Result<()> {
136136
]);
137137

138138
let adbc_driver = match system_adapter_client
139-
.setup(run_id, datasets, setup_metadata)
139+
.setup(run_id, setup_metadata)
140140
.await
141141
{
142142
Ok(response) => response,
@@ -182,7 +182,7 @@ async fn main() -> anyhow::Result<()> {
182182
&mutations,
183183
)?;
184184

185-
if let Err(e) = system_adapter_client.create_tables(run_id).await {
185+
if let Err(e) = system_adapter_client.create_tables(run_id, datasets).await {
186186
pipeline.cancel();
187187
return Err(anyhow::anyhow!(
188188
"Failed to create tables via system adapter: {e}"

system-adapters/databricks/src/main.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ impl TableFormat {
183183

184184
#[derive(Debug, Clone)]
185185
struct RunState {
186-
datasets: HashMap<String, DatasetConfig>,
187186
table_format: TableFormat,
188187
created_tables: Vec<String>,
189188
cluster_id: Option<String>,
@@ -1025,12 +1024,10 @@ impl Handler for DatabricksAdapter {
10251024
async fn setup(
10261025
&mut self,
10271026
run_id: Uuid,
1028-
datasets: HashMap<String, DatasetConfig>,
10291027
metadata: HashMap<String, Value>,
10301028
) -> std::result::Result<SetupResponse, String> {
10311029
eprintln!(
1032-
"[databricks-adapter] setup: run_id={run_id}, datasets={}",
1033-
datasets.len()
1030+
"[databricks-adapter] setup: run_id={run_id}"
10341031
);
10351032

10361033
let (cluster_id, cluster_created_by_adapter) = match &self.config.compute_target {
@@ -1068,7 +1065,6 @@ impl Handler for DatabricksAdapter {
10681065
self.runs.insert(
10691066
run_id,
10701067
RunState {
1071-
datasets,
10721068
table_format,
10731069
created_tables: Vec::new(),
10741070
cluster_id,
@@ -1094,13 +1090,14 @@ impl Handler for DatabricksAdapter {
10941090
async fn create_tables(
10951091
&mut self,
10961092
run_id: Uuid,
1093+
datasets: HashMap<String, DatasetConfig>,
10971094
) -> std::result::Result<CreateTablesResponse, String> {
1098-
let (datasets, table_format) = {
1095+
let table_format = {
10991096
let state = self
11001097
.runs
11011098
.get(&run_id)
11021099
.ok_or_else(|| format!("Unknown run_id: {run_id}"))?;
1103-
(state.datasets.clone(), state.table_format)
1100+
state.table_format
11041101
};
11051102

11061103
let mut created_tables = Vec::with_capacity(datasets.len());

0 commit comments

Comments
 (0)