-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe1ef97
commit cb70c0b
Showing
9 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#' @export | ||
polars_info <- function() { | ||
# Similar to arrow::arrow_info() | ||
out <- list( | ||
versions = list( | ||
r_package = as.character(utils::packageVersion("polars")), | ||
rust_crate = rust_polars_version() | ||
), | ||
thread_pool_size = thread_pool_size() | ||
# TODO-REWRITE: enable those | ||
# features = cargo_rpolars_feature_info(), | ||
# code_completion = .polars_autocompletion$mode %||% "deactivated" | ||
) | ||
structure(out, class = "polars_info") | ||
} | ||
|
||
#' @noRd | ||
#' @export | ||
print.polars_info <- function(x, ...) { | ||
# Copied from the arrow package | ||
# https://github.com/apache/arrow/blob/6f3bd2524c2abe3a4a278fc1c62fc5c49b56cab3/r/R/arrow-info.R#L149-L157 | ||
print_key_values <- function(title, vals, ...) { | ||
df <- data.frame(vals, ...) | ||
names(df) <- "" | ||
|
||
cat(title, ":", sep = "") | ||
print(df) | ||
cat("\n") | ||
} | ||
|
||
cat("Polars R package version : ", format(x$versions$r_package), "\n", sep = "") | ||
cat("Rust Polars crate version: ", format(x$versions$rust_crate), "\n", sep = "") | ||
cat("\n") | ||
cat("Thread pool size:", x$thread_pool_size, "\n") | ||
# cat("\n") | ||
# print_key_values("Features", unlist(x$features)) | ||
# cat("Code completion:", x$code_completion, "\n") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use savvy::{savvy, Result, Sexp}; | ||
|
||
#[savvy] | ||
fn rust_polars_version() -> Result<Sexp> { | ||
polars::VERSION.try_into() | ||
} | ||
|
||
#[savvy] | ||
fn thread_pool_size() -> Result<Sexp> { | ||
(polars_core::POOL.current_num_threads() as i32).try_into() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ mod datatypes; | |
mod error; | ||
mod expr; | ||
mod functions; | ||
mod info; | ||
mod lazyframe; | ||
mod lazygroupby; | ||
mod map; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# print polars_info() | ||
|
||
Code | ||
info | ||
Output | ||
Polars R package version : 999.999.999 | ||
Rust Polars crate version: 999.999.999 | ||
Thread pool size: 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
patrick::with_parameters_test_that("polars_info() features are logical", | ||
{ | ||
expect_type(feature, "logical") | ||
expect_length(feature, 1) | ||
}, | ||
feature = polars_info()$features | ||
) | ||
|
||
test_that("print polars_info()", { | ||
info <- polars_info() | ||
|
||
expect_type(info$versions$r_package, "character") | ||
expect_type(info$versions$rust_crate, "character") | ||
|
||
# Ensure static version for snapshot test | ||
info$versions$r_package <- "999.999.999" | ||
info$versions$rust_crate <- "999.999.999" | ||
|
||
# Ensure the thread_pool_size is 1 for snapshot test | ||
info$thread_pool_size <- 1 | ||
|
||
# Ensure all features are FALSE for snapshot test | ||
for (feature in names(info$features)) { | ||
info$features[[feature]] <- FALSE | ||
} | ||
|
||
# Ensure code_completion is deactivated for snapshot test | ||
info$code_completion <- "deactivated" | ||
|
||
expect_snapshot(info) | ||
}) |