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

[CHORE] factor io config into common code #1335

Merged
merged 3 commits into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 13 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ inherits = "dev"
[workspace]
members = [
"src/common/error",
"src/common/io-config",
"src/daft-core",
"src/daft-io",
"src/daft-parquet",
Expand Down
14 changes: 14 additions & 0 deletions src/common/io-config/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[dependencies]
common-error = {path = "../error", default-features = false}
pyo3 = {workspace = true, optional = true}
serde = {workspace = true}
serde_json = {workspace = true}

[features]
default = ["python"]
python = ["dep:pyo3", "common-error/python"]

[package]
edition = {workspace = true}
name = "common-io-config"
version = {workspace = true}
25 changes: 25 additions & 0 deletions src/common/io-config/src/azure.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use std::fmt::Display;
use std::fmt::Formatter;

use serde::Deserialize;
use serde::Serialize;

#[derive(Clone, Default, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)]
pub struct AzureConfig {
pub storage_account: Option<String>,
pub access_key: Option<String>,
pub anonymous: bool,
}

impl Display for AzureConfig {
fn fmt(&self, f: &mut Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
write!(
f,
"AzureConfig
storage_account: {:?}
access_key: {:?}
anonymous: {:?}",
self.storage_account, self.access_key, self.anonymous
)
}
}
26 changes: 26 additions & 0 deletions src/common/io-config/src/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use std::fmt::Display;
use std::fmt::Formatter;

use serde::Deserialize;
use serde::Serialize;

use crate::{AzureConfig, GCSConfig, S3Config};
#[derive(Clone, Default, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)]
pub struct IOConfig {
pub s3: S3Config,
pub azure: AzureConfig,
pub gcs: GCSConfig,
}

impl Display for IOConfig {
fn fmt(&self, f: &mut Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
write!(
f,
"IOConfig:
{}
{}
{}",
self.s3, self.azure, self.gcs
)
}
}
23 changes: 23 additions & 0 deletions src/common/io-config/src/gcs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use std::fmt::Display;
use std::fmt::Formatter;

use serde::Deserialize;
use serde::Serialize;

#[derive(Clone, Default, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)]
pub struct GCSConfig {
pub project_id: Option<String>,
pub anonymous: bool,
}

impl Display for GCSConfig {
fn fmt(&self, f: &mut Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
write!(
f,
"GCSConfig
project_id: {:?}
anonymous: {:?}",
self.project_id, self.anonymous
)
}
}
9 changes: 9 additions & 0 deletions src/common/io-config/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#[cfg(feature = "python")]
pub mod python;

mod azure;
mod config;
mod gcs;
mod s3;

pub use crate::{azure::AzureConfig, config::IOConfig, gcs::GCSConfig, s3::S3Config};
Loading
Loading