Skip to content

Commit d2d8995

Browse files
authored
test: Run reticulate integration tests for LazyFrame if R and Python have the same DSL hash (#1624)
1 parent a99dfbd commit d2d8995

File tree

6 files changed

+42
-9
lines changed

6 files changed

+42
-9
lines changed

R/generated-polars-version.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# Generated by dev script: do not edit by hand
22

33
PY_VERSION <- "1.35.1"
4+
5+
DSL_SCHEMA_HASH_PY <- "6286bad7b59c6dffbabcb7eda0d3a1c386cc651ad8b2479b2e4e4686199e04e1"
6+
DSL_SCHEMA_HASH_CURRENT <- "6286bad7b59c6dffbabcb7eda0d3a1c386cc651ad8b2479b2e4e4686199e04e1"

R/polars_info.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ polars_info <- function() {
2525
rust_crate = rust_polars_version()
2626
),
2727
interchange = list(
28+
# TODO: show schema hash related info
2829
py_version = PY_VERSION,
2930
compat_level = list(
3031
newest = pl__CompatLevel$newest

dev/generate-r-files/polars-version/main.R

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,35 @@ SCRIPT_ROOT <- "dev/generate-r-files/polars-version"
44

55
git_rev <- RcppTOML::parseTOML("src/rust/Cargo.toml")$dependencies$`polars-core`$rev
66

7-
target_file <- glue::glue(
7+
py_version <- glue::glue(
88
"https://raw.githubusercontent.com/pola-rs/polars/{git_rev}/py-polars/pyproject.toml"
9-
)
10-
11-
py_version <- readr::read_file(target_file) |>
9+
) |>
10+
readr::read_file() |>
1211
RcppTOML::parseTOML(fromFile = FALSE) |>
1312
_$project$version
1413

15-
# TODO: reverse check? (the py version is released and the rev is the same?)
14+
py_semver <- glue::glue(
15+
"https://raw.githubusercontent.com/pola-rs/polars/{git_rev}/py-polars/runtime/Cargo.toml"
16+
) |>
17+
readr::read_file() |>
18+
RcppTOML::parseTOML(fromFile = FALSE) |>
19+
_$package$version
20+
21+
# nolint start: line_length_linter
22+
dsl_schema_hash_current <- glue::glue(
23+
"https://raw.githubusercontent.com/pola-rs/polars/{git_rev}/crates/polars-plan/dsl-schema-hashes.json"
24+
) |>
25+
readr::read_file() |>
26+
charToRaw() |>
27+
tools::sha256sum(bytes = _)
28+
29+
dsl_schema_hash_py <- glue::glue(
30+
"https://raw.githubusercontent.com/pola-rs/polars/refs/tags/py-{py_semver}/crates/polars-plan/dsl-schema-hashes.json"
31+
) |>
32+
readr::read_file() |>
33+
charToRaw() |>
34+
tools::sha256sum(bytes = _)
35+
# nolint end
1636

1737
template <- readr::read_file(
1838
file.path(SCRIPT_ROOT, "templates", "polars-version.R.txt")
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
PY_VERSION <- "{{py_version}}"
2+
3+
DSL_SCHEMA_HASH_PY <- "{{dsl_schema_hash_py}}"
4+
DSL_SCHEMA_HASH_CURRENT <- "{{dsl_schema_hash_current}}"

tests/testthat/helper-skip.R

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
# https://github.com/r-lib/testthat/issues/2236
2-
skip_on_dev_version <- function() {
1+
skip_on_dev_polars <- function() {
32
version <- asNamespace(testing_package())[[".__NAMESPACE__."]][["spec"]][[
43
"version"
54
]] |>
65
package_version() |>
76
unclass() |>
87
getElement(1L)
98

9+
is_released_dsl_hash <- identical(
10+
DSL_SCHEMA_HASH_CURRENT,
11+
DSL_SCHEMA_HASH_PY
12+
)
13+
1014
# We use larger than `9000` version for the development versions
11-
if (tail(version, 1L) < 9000) {
15+
if (tail(version, 1L) < 9000 || is_released_dsl_hash) {
1216
invisible()
1317
} else {
1418
skip("Skip on development versions.")

tests/testthat/test-integration-reticulate.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ test_that("LazyFrame roundtrip via py-polars", {
3333
skip_if_no_py_polars(version = PY_VERSION)
3434
# In dev version, we may depends on non-released polars,
3535
# so they may have the different DSL versions and are not compatible.
36-
skip_on_dev_version()
36+
skip_on_dev_polars()
37+
# TODO: remove this line after bumping the lib version
38+
skip_on_os("windows")
3739

3840
lf <- as_polars_lf(mtcars)$filter(pl$col("mpg") >= 20)$select("cyl")$sort(cs$all())
3941

0 commit comments

Comments
 (0)