Skip to content

Commit 2ae53f4

Browse files
authored
[CHORE] Change IOConfig to be serialized into binary instead of JSON (Eventual-Inc#3400)
1 parent 68248a9 commit 2ae53f4

File tree

5 files changed

+8
-41
lines changed

5 files changed

+8
-41
lines changed

Cargo.lock

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

daft/daft/__init__.pyi

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -638,13 +638,6 @@ class IOConfig:
638638
gcs: GCSConfig | None = None,
639639
http: HTTPConfig | None = None,
640640
): ...
641-
@staticmethod
642-
def from_json(input: str) -> IOConfig:
643-
"""
644-
Recreate an IOConfig from a JSON string.
645-
"""
646-
...
647-
648641
def replace(
649642
self,
650643
s3: S3Config | None = None,

daft/io/config.py

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/common/io-config/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
[dependencies]
22
aws-credential-types = {version = "0.55.3"}
33
chrono = {workspace = true}
4-
common-error = {path = "../error", default-features = false}
54
common-py-serde = {path = "../py-serde", default-features = false}
65
derive_more = {workspace = true}
76
pyo3 = {workspace = true, optional = true}
87
secrecy = {version = "0.8.0", features = ["alloc"], default-features = false}
98
serde = {workspace = true}
10-
serde_json = {workspace = true}
119
typetag = {workspace = true}
1210

1311
[features]
14-
python = ["dep:pyo3", "common-error/python", "common-py-serde/python"]
12+
python = ["dep:pyo3", "common-py-serde/python"]
1513

1614
[lints]
1715
workspace = true

src/common/io-config/src/python.rs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ use aws_credential_types::{
88
provider::{error::CredentialsError, ProvideCredentials},
99
Credentials,
1010
};
11-
use common_error::DaftError;
12-
use common_py_serde::{deserialize_py_object, serialize_py_object};
11+
use common_py_serde::{
12+
deserialize_py_object, impl_bincode_py_state_serialization, serialize_py_object,
13+
};
1314
use pyo3::prelude::*;
1415
use serde::{Deserialize, Serialize};
1516

@@ -131,8 +132,8 @@ pub struct GCSConfig {
131132
/// Example:
132133
/// >>> io_config = IOConfig(s3=S3Config(key_id="xxx", access_key="xxx", num_tries=10), azure=AzureConfig(anonymous=True), gcs=GCSConfig(...))
133134
/// >>> daft.read_parquet(["s3://some-path", "az://some-other-path", "gs://path3"], io_config=io_config)
134-
#[derive(Clone, Default)]
135-
#[pyclass]
135+
#[derive(Clone, Default, Serialize, Deserialize)]
136+
#[pyclass(module = "daft.daft")]
136137
pub struct IOConfig {
137138
pub config: config::IOConfig,
138139
}
@@ -234,23 +235,6 @@ impl IOConfig {
234235
})
235236
}
236237

237-
#[staticmethod]
238-
pub fn from_json(input: &str) -> PyResult<Self> {
239-
let config: config::IOConfig = serde_json::from_str(input).map_err(DaftError::from)?;
240-
Ok(config.into())
241-
}
242-
243-
pub fn __reduce__(&self, py: Python) -> PyResult<(PyObject, (String,))> {
244-
let io_config_module = py.import_bound(pyo3::intern!(py, "daft.io.config"))?;
245-
let json_string = serde_json::to_string(&self.config).map_err(DaftError::from)?;
246-
Ok((
247-
io_config_module
248-
.getattr(pyo3::intern!(py, "_io_config_from_json"))?
249-
.into(),
250-
(json_string,),
251-
))
252-
}
253-
254238
pub fn __hash__(&self) -> PyResult<u64> {
255239
use std::{collections::hash_map::DefaultHasher, hash::Hash};
256240

@@ -260,6 +244,8 @@ impl IOConfig {
260244
}
261245
}
262246

247+
impl_bincode_py_state_serialization!(IOConfig);
248+
263249
#[pymethods]
264250
impl S3Config {
265251
#[allow(clippy::too_many_arguments)]

0 commit comments

Comments
 (0)