Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkzinzow committed Sep 12, 2023
1 parent abd66fe commit 72f820a
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 62 deletions.
1 change: 0 additions & 1 deletion daft/table/schema_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def from_parquet(
assert isinstance(
file, (str, pathlib.Path)
), "Native downloader only works on string inputs to read_parquet"
assert isinstance(file, (str, pathlib.Path))
io_config = config.io_config
return Schema.from_parquet(str(file), io_config=io_config)

Expand Down
122 changes: 61 additions & 61 deletions src/daft-plan/src/source_info/storage_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,67 +17,6 @@ use {
std::hash::{Hash, Hasher},
};

#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(transparent)]
#[cfg_attr(
feature = "python",
pyclass(module = "daft.daft", name = "StorageConfig")
)]
pub struct PyStorageConfig(Arc<StorageConfig>);

#[cfg(feature = "python")]
#[pymethods]
impl PyStorageConfig {
#[new]
#[pyo3(signature = (*args))]
pub fn new(args: &PyTuple) -> PyResult<Self> {
match args.len() {
// Create dummy inner StorageConfig, to be overridden by __setstate__.
0 => Ok(Arc::new(StorageConfig::Native(
NativeStorageConfig::new_internal(None).into(),
))
.into()),
_ => Err(PyValueError::new_err(format!(
"expected no arguments to make new PyStorageConfig, got : {}",
args.len()
))),
}
}
#[staticmethod]
fn native(config: NativeStorageConfig) -> Self {
Self(Arc::new(StorageConfig::Native(config.into())))
}

#[staticmethod]
fn python(config: PythonStorageConfig) -> Self {
Self(Arc::new(StorageConfig::Python(config)))
}

#[getter]
fn get_config(&self, py: Python) -> PyObject {
use StorageConfig::*;

match self.0.as_ref() {
Native(config) => config.as_ref().clone().into_py(py),
Python(config) => config.clone().into_py(py),
}
}
}

impl_bincode_py_state_serialization!(PyStorageConfig);

impl From<PyStorageConfig> for Arc<StorageConfig> {
fn from(value: PyStorageConfig) -> Self {
value.0
}
}

impl From<Arc<StorageConfig>> for PyStorageConfig {
fn from(value: Arc<StorageConfig>) -> Self {
Self(value)
}
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Hash)]
pub enum StorageConfig {
Native(Arc<NativeStorageConfig>),
Expand Down Expand Up @@ -162,3 +101,64 @@ impl Hash for PythonStorageConfig {
}
}
}

#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(transparent)]
#[cfg_attr(
feature = "python",
pyclass(module = "daft.daft", name = "StorageConfig")
)]
pub struct PyStorageConfig(Arc<StorageConfig>);

#[cfg(feature = "python")]
#[pymethods]
impl PyStorageConfig {
#[new]
#[pyo3(signature = (*args))]
pub fn new(args: &PyTuple) -> PyResult<Self> {
match args.len() {
// Create dummy inner StorageConfig, to be overridden by __setstate__.
0 => Ok(Arc::new(StorageConfig::Native(
NativeStorageConfig::new_internal(None).into(),
))
.into()),
_ => Err(PyValueError::new_err(format!(
"expected no arguments to make new PyStorageConfig, got : {}",
args.len()
))),
}
}
#[staticmethod]
fn native(config: NativeStorageConfig) -> Self {
Self(Arc::new(StorageConfig::Native(config.into())))
}

#[staticmethod]
fn python(config: PythonStorageConfig) -> Self {
Self(Arc::new(StorageConfig::Python(config)))
}

#[getter]
fn get_config(&self, py: Python) -> PyObject {
use StorageConfig::*;

match self.0.as_ref() {
Native(config) => config.as_ref().clone().into_py(py),
Python(config) => config.clone().into_py(py),
}
}
}

impl_bincode_py_state_serialization!(PyStorageConfig);

impl From<PyStorageConfig> for Arc<StorageConfig> {
fn from(value: PyStorageConfig) -> Self {
value.0
}
}

impl From<Arc<StorageConfig>> for PyStorageConfig {
fn from(value: Arc<StorageConfig>) -> Self {
Self(value)
}
}

0 comments on commit 72f820a

Please sign in to comment.