mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 13:06:08 +02:00
starting to work on s3 support
This commit is contained in:
@ -44,6 +44,11 @@ uuid = { version = "1.11", features = ["v4", "serde"] }
|
||||
# Do to a compile error with polars, this included to force the raw dependency
|
||||
hashbrown = { version = "0.14", features = ["rayon", "ahash", "serde", "raw"] }
|
||||
|
||||
# Cloud support
|
||||
aws-config = { version = "1.5", features = ["sso"] }
|
||||
aws-credential-types = "1.2"
|
||||
tokio = { version = "1.41.1", features = ["full"] }
|
||||
|
||||
[dependencies.polars]
|
||||
features = [
|
||||
"arg_where",
|
||||
|
38
crates/nu_plugin_polars/src/dataframe/cloud/aws.rs
Normal file
38
crates/nu_plugin_polars/src/dataframe/cloud/aws.rs
Normal file
@ -0,0 +1,38 @@
|
||||
use std::error::Error;
|
||||
|
||||
use aws_config::{BehaviorVersion, SdkConfig};
|
||||
use aws_credential_types::{provider::ProvideCredentials, Credentials};
|
||||
use nu_protocol::ShellError;
|
||||
use polars_io::cloud::CloudOptions;
|
||||
|
||||
async fn aws_load_config() -> SdkConfig {
|
||||
aws_config::load_defaults(BehaviorVersion::latest()).await
|
||||
}
|
||||
|
||||
async fn aws_creds(aws_config: &SdkConfig) -> Result<Option<Credentials>, ShellError> {
|
||||
if let Some(provider) = aws_config.credentials_provider() {
|
||||
Ok(Some(provider.provide_credentials().await.map_err(|e| {
|
||||
ShellError::GenericError {
|
||||
error: format!(
|
||||
"Could not fetch AWS credentials: {} - {}",
|
||||
e,
|
||||
e.source()
|
||||
.map(|e| format!("{}", e))
|
||||
.unwrap_or("".to_string())
|
||||
),
|
||||
msg: "".into(),
|
||||
span: None,
|
||||
help: None,
|
||||
inner: vec![],
|
||||
}
|
||||
})?))
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async fn aws_cloud_options() ->CloudOptions {
|
||||
|
||||
}
|
||||
|
1
crates/nu_plugin_polars/src/dataframe/cloud/mod.rs
Normal file
1
crates/nu_plugin_polars/src/dataframe/cloud/mod.rs
Normal file
@ -0,0 +1 @@
|
||||
mod aws;
|
@ -3,6 +3,7 @@ use nu_protocol::{ShellError, Span};
|
||||
pub mod command;
|
||||
mod utils;
|
||||
pub mod values;
|
||||
mod cloud;
|
||||
|
||||
pub fn missing_flag_error(flag: &str, span: Span) -> ShellError {
|
||||
ShellError::GenericError {
|
||||
|
@ -17,6 +17,7 @@ mod cache;
|
||||
pub mod dataframe;
|
||||
pub use dataframe::*;
|
||||
use nu_protocol::{ast::Operator, CustomValue, LabeledError, ShellError, Span, Spanned, Value};
|
||||
use tokio::runtime::Runtime;
|
||||
use values::CustomValueType;
|
||||
|
||||
use crate::values::PolarsPluginCustomValue;
|
||||
@ -52,11 +53,27 @@ impl EngineWrapper for &EngineInterface {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct PolarsPlugin {
|
||||
pub(crate) cache: Cache,
|
||||
/// For testing purposes only
|
||||
pub(crate) disable_cache_drop: bool,
|
||||
pub(crate) runtime: Runtime,
|
||||
}
|
||||
|
||||
impl PolarsPlugin {
|
||||
pub fn new() -> Result<Self, ShellError> {
|
||||
Ok(Self {
|
||||
cache: Cache::default(),
|
||||
disable_cache_drop: false,
|
||||
runtime: Runtime::new().map_err(|e| ShellError::GenericError {
|
||||
error: format!("Could not instantiate tokio: {e}"),
|
||||
msg: "".into(),
|
||||
span: None,
|
||||
help: None,
|
||||
inner: vec![],
|
||||
})?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Plugin for PolarsPlugin {
|
||||
|
@ -6,5 +6,12 @@ static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
|
||||
|
||||
fn main() {
|
||||
env_logger::init();
|
||||
serve_plugin(&PolarsPlugin::default(), MsgPackSerializer {})
|
||||
|
||||
match PolarsPlugin::new() {
|
||||
Ok(ref plugin) => serve_plugin(plugin, MsgPackSerializer {}),
|
||||
Err(e) => {
|
||||
eprintln!("{}", e);
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user