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

refactor: Deduplicate POLARS_FORCE_ASYNC env var parsing #14909

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
6 changes: 6 additions & 0 deletions crates/polars-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,9 @@ pub fn get_rg_prefetch_size() -> usize {
// Set it to something big, but not unlimited.
.unwrap_or_else(|_| std::cmp::max(get_file_prefetch_size(), 128))
}

pub fn env_force_async() -> bool {
std::env::var("POLARS_FORCE_ASYNC")
.map(|value| value == "1")
.unwrap_or_default()
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::path::PathBuf;

use polars_core::config::env_force_async;
#[cfg(feature = "cloud")]
use polars_core::config::{get_file_prefetch_size, verbose};
use polars_core::utils::accumulate_dataframes_vertical;
Expand Down Expand Up @@ -334,7 +335,7 @@ impl ParquetExec {
));
},
};
let force_async = std::env::var("POLARS_FORCE_ASYNC").as_deref().unwrap_or("") == "1";
let force_async = env_force_async();

let out = if is_cloud || force_async {
#[cfg(not(feature = "cloud"))]
Expand Down
5 changes: 2 additions & 3 deletions crates/polars-pipe/src/executors/sources/parquet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::path::PathBuf;
use std::sync::Arc;

use arrow::datatypes::ArrowSchemaRef;
use polars_core::config::get_file_prefetch_size;
use polars_core::config::{env_force_async, get_file_prefetch_size};
use polars_core::error::*;
use polars_core::prelude::Series;
use polars_core::POOL;
Expand Down Expand Up @@ -204,8 +204,7 @@ impl ParquetSource {
if verbose {
eprintln!("POLARS PREFETCH_SIZE: {}", prefetch_size)
}
let run_async = paths.first().map(is_cloud_url).unwrap_or(false)
|| std::env::var("POLARS_FORCE_ASYNC").as_deref().unwrap_or("") == "1";
let run_async = paths.first().map(is_cloud_url).unwrap_or(false) || env_force_async();

let mut source = ParquetSource {
batched_readers: VecDeque::new(),
Expand Down
Loading