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

Add rust polars version info #363

Merged
merged 5 commits into from
Aug 12, 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
20 changes: 19 additions & 1 deletion R/info.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# get version of rust-polars version from Cargo.lock at package build time
# from polars 0.31.1 this can be migrated to rust side see
# https://github.com/pola-rs/polars/pull/9660
RUST_POLARS_VERSION = (\() {
Cargo.lock = readLines("./src/rust/Cargo.lock")
etiennebacher marked this conversation as resolved.
Show resolved Hide resolved
polars.idx = which(Cargo.lock == r"{name = "polars"}")[1]
this_line = Cargo.lock[polars.idx + 1]
if (isTRUE(substr(this_line, 1, 7) == "version")) {
return(substr(this_line, 12, nchar(this_line) - 1))
}
warning("failed to find RUST_POLARS_VERSION version")
"unknown"
})()


#' Report information of the package
#'
#' @return A list with information of the package
Expand All @@ -8,6 +23,7 @@ pl$polars_info = function() {
# Similar to arrow::arrow_info()
out = list(
version = utils::packageVersion("polars"),
rust_polars = RUST_POLARS_VERSION,
features = FeatureInfo$new()$to_r()
)

Expand All @@ -27,6 +43,8 @@ print.polars_info = function(x, ...) {
cat("\n")
}

cat("R Polars package version: ", format(x$version), "\n\n", sep = "")
cat("r-polars package version : ", format(x$version), "\n", sep = "")
cat("rust-polars crate version: ", format(x$rust_polars), "\n", sep = "")
cat("\n")
print_key_values("Features", unlist(x$features))
}
8 changes: 4 additions & 4 deletions man/nanoarrow.Rd

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

3 changes: 2 additions & 1 deletion tests/testthat/_snaps/info.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
Code
info
Output
R Polars package version: 999.999.999
r-polars package version : 999.999.999
rust-polars crate version: 999.999.999

Features:
simd FALSE
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-info.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ test_that("print pl$polars_info()", {

# Ensure static version for snapshot test
info$version <- package_version("999.999.999")
info$rust_polars <- package_version("999.999.999")

# Ensure all features are FALSE for snapshot test
for (feature in names(info$features)) {
Expand Down