From c7965f92f04832841506fee08ff183cd126c3431 Mon Sep 17 00:00:00 2001 From: simonpcouch Date: Mon, 26 Feb 2024 08:38:21 -0600 Subject: [PATCH 1/7] test parsnip "overhead" --- tests/testthat/test_fit_interfaces.R | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/testthat/test_fit_interfaces.R b/tests/testthat/test_fit_interfaces.R index c49540b76..9c0d442a9 100644 --- a/tests/testthat/test_fit_interfaces.R +++ b/tests/testthat/test_fit_interfaces.R @@ -154,3 +154,20 @@ test_that("fit() can handle attributes on a vector outcome", { ignore_attr = TRUE ) }) + +test_that("overhead of parsnip interface is minimal", { + timing <- function(expr) { + expr <- substitute(expr) + system.time(replicate(100, eval(expr)))[["elapsed"]] + } + + time_engine <- + timing(lm(mpg ~ ., mtcars)) + time_parsnip_form <- + timing(fit(parsnip::linear_reg(), mpg ~ ., mtcars)) + time_parsnip_xy <- + timing(fit_xy(parsnip::linear_reg(), mtcars[2:11], mtcars[1])) + + expect_true(time_parsnip_form / time_engine < 4.5) + expect_true(time_parsnip_xy / time_engine < 6) +}) From ceda225847c9d33c47e9e94b68bc99cf43b4e90d Mon Sep 17 00:00:00 2001 From: simonpcouch Date: Mon, 26 Feb 2024 08:46:26 -0600 Subject: [PATCH 2/7] add `skip_on_cran()` --- tests/testthat/test_fit_interfaces.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/testthat/test_fit_interfaces.R b/tests/testthat/test_fit_interfaces.R index 9c0d442a9..8af853c91 100644 --- a/tests/testthat/test_fit_interfaces.R +++ b/tests/testthat/test_fit_interfaces.R @@ -156,6 +156,8 @@ test_that("fit() can handle attributes on a vector outcome", { }) test_that("overhead of parsnip interface is minimal", { + skip_on_cran() + timing <- function(expr) { expr <- substitute(expr) system.time(replicate(100, eval(expr)))[["elapsed"]] From 206f3edb9ea26d89acd0793a759a5231abef8990 Mon Sep 17 00:00:00 2001 From: simonpcouch Date: Mon, 26 Feb 2024 08:46:39 -0600 Subject: [PATCH 3/7] add PR ref --- tests/testthat/test_fit_interfaces.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test_fit_interfaces.R b/tests/testthat/test_fit_interfaces.R index 8af853c91..7ffd04302 100644 --- a/tests/testthat/test_fit_interfaces.R +++ b/tests/testthat/test_fit_interfaces.R @@ -155,7 +155,7 @@ test_that("fit() can handle attributes on a vector outcome", { ) }) -test_that("overhead of parsnip interface is minimal", { +test_that("overhead of parsnip interface is minimal (#1071)", { skip_on_cran() timing <- function(expr) { From 25e3bda4545a2d54ff5a9233afa45c1772702137 Mon Sep 17 00:00:00 2001 From: simonpcouch Date: Mon, 26 Feb 2024 08:50:28 -0600 Subject: [PATCH 4/7] no need for namespacing --- tests/testthat/test_fit_interfaces.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test_fit_interfaces.R b/tests/testthat/test_fit_interfaces.R index 7ffd04302..d0e759870 100644 --- a/tests/testthat/test_fit_interfaces.R +++ b/tests/testthat/test_fit_interfaces.R @@ -166,9 +166,9 @@ test_that("overhead of parsnip interface is minimal (#1071)", { time_engine <- timing(lm(mpg ~ ., mtcars)) time_parsnip_form <- - timing(fit(parsnip::linear_reg(), mpg ~ ., mtcars)) + timing(fit(linear_reg(), mpg ~ ., mtcars)) time_parsnip_xy <- - timing(fit_xy(parsnip::linear_reg(), mtcars[2:11], mtcars[1])) + timing(fit_xy(linear_reg(), mtcars[2:11], mtcars[1])) expect_true(time_parsnip_form / time_engine < 4.5) expect_true(time_parsnip_xy / time_engine < 6) From 9b549311fc21a8833c016c3b296d7b86a0db4428 Mon Sep 17 00:00:00 2001 From: simonpcouch Date: Mon, 26 Feb 2024 09:58:21 -0600 Subject: [PATCH 5/7] skip on covr --- tests/testthat/test_fit_interfaces.R | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/testthat/test_fit_interfaces.R b/tests/testthat/test_fit_interfaces.R index d0e759870..5968a7333 100644 --- a/tests/testthat/test_fit_interfaces.R +++ b/tests/testthat/test_fit_interfaces.R @@ -157,6 +157,7 @@ test_that("fit() can handle attributes on a vector outcome", { test_that("overhead of parsnip interface is minimal (#1071)", { skip_on_cran() + skip_on_covr() timing <- function(expr) { expr <- substitute(expr) From 0444753b92db7901513f7d1d0bfeb33f0e1d416f Mon Sep 17 00:00:00 2001 From: simonpcouch Date: Tue, 27 Feb 2024 16:20:07 -0600 Subject: [PATCH 6/7] transition to bench, add informative test `label`s --- DESCRIPTION | 1 + tests/testthat/test_fit_interfaces.R | 25 +++++++++++-------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 6e7fd1b4b..0be178cec 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -40,6 +40,7 @@ Imports: withr Suggests: C50, + bench, covr, dials (>= 1.1.0), earth, diff --git a/tests/testthat/test_fit_interfaces.R b/tests/testthat/test_fit_interfaces.R index 5968a7333..a099e9850 100644 --- a/tests/testthat/test_fit_interfaces.R +++ b/tests/testthat/test_fit_interfaces.R @@ -158,19 +158,16 @@ test_that("fit() can handle attributes on a vector outcome", { test_that("overhead of parsnip interface is minimal (#1071)", { skip_on_cran() skip_on_covr() + skip_if_not_installed("bench") + + bm <- bench::mark( + time_engine = lm(mpg ~ ., mtcars), + time_parsnip_form = fit(linear_reg(), mpg ~ ., mtcars), + time_parsnip_xy = fit_xy(linear_reg(), mtcars[2:11], mtcars[1]), + relative = TRUE, + check = FALSE + ) - timing <- function(expr) { - expr <- substitute(expr) - system.time(replicate(100, eval(expr)))[["elapsed"]] - } - - time_engine <- - timing(lm(mpg ~ ., mtcars)) - time_parsnip_form <- - timing(fit(linear_reg(), mpg ~ ., mtcars)) - time_parsnip_xy <- - timing(fit_xy(linear_reg(), mtcars[2:11], mtcars[1])) - - expect_true(time_parsnip_form / time_engine < 4.5) - expect_true(time_parsnip_xy / time_engine < 6) + expect_true(bm$median[2] < 3, label = "parsnip overhead is minimal (formula interface)") + expect_true(bm$median[3] < 3.5, , label = "parsnip overhead is minimal (xy interface)") }) From 20e0680f06ec0d0ad52df5964bdbda967036df2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=98topepo=E2=80=99?= <‘mxkuhn@gmail.com’> Date: Tue, 27 Feb 2024 20:28:15 -0500 Subject: [PATCH 7/7] reticulate -> rstudio/reticulate to fix r-devel issues on ububtu --- .github/workflows/R-CMD-check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index d430549f6..ee86e4be0 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -56,7 +56,7 @@ jobs: needs: check - name: Install dev reticulate - run: pak::pkg_install('reticulate') + run: pak::pkg_install('rstudio/reticulate') shell: Rscript {0} - name: Install Miniconda