Skip to content
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
4 changes: 2 additions & 2 deletions R/tune.R → R/generics.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# @export - lazily and conditionally registered in .onLoad()
required_pkgs_workflow <- function(x, infra = TRUE, ...) {
# Lazily registered in .onLoad()
required_pkgs.workflow <- function(x, infra = TRUE, ...) {
out <- character()

if (has_spec(x)) {
Expand Down
15 changes: 1 addition & 14 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,7 @@
vctrs::s3_register("butcher::axe_env", "workflow")
vctrs::s3_register("butcher::axe_fitted", "workflow")

# Can't use `rlang::is_installed()` at all, as that doesn't work when
# called from `.onLoad()` for some reason. Instead, rely on `packageVersion()`
# erroring when the package isn't installed.
has_at_least_version <- function(pkg, version) {
tryCatch(
expr = utils::packageVersion(pkg) >= version,
error = function(cnd) FALSE
)
}

if (has_at_least_version("tune", "0.1.3.9001")) {
# `required_pkgs.workflow()` moved from tune to workflows
vctrs::s3_register("generics::required_pkgs", "workflow", required_pkgs_workflow)
}
vctrs::s3_register("generics::required_pkgs", "workflow")
}

# nocov end
3 changes: 0 additions & 3 deletions tests/testthat/test-tune.R → tests/testthat/test-generics.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
test_that("can compute required packages of a workflow - formula", {
skip_if_not_installed("tune")

mod <- parsnip::linear_reg()
mod <- parsnip::set_engine(mod, "lm")

Expand All @@ -12,7 +10,6 @@ test_that("can compute required packages of a workflow - formula", {
})

test_that("can compute required packages of a workflow - recipes", {
skip_if_not_installed("tune")
skip_if_not_installed("recipes")

mod <- parsnip::linear_reg()
Expand Down