Skip to content

Conversation

@simonpcouch
Copy link
Contributor

Closes #174. :)

# note: do not load required parsnip extension
library(parsnip)
library(workflows)

bt_mod <- bag_tree() %>%
  set_engine("rpart") %>%
  set_mode("regression")

bt_wf <- workflow() %>%
  add_model(bt_mod)
#> ! parsnip could not locate an implementation for `bag_tree` regression model
#>   specifications using the `rpart` engine.
#> ℹ The parsnip extension package baguette implements support for this
#>   specification.
#> ℹ Please install (if needed) and load to continue.

Created on 2022-09-08 by the reprex package (v2.0.1)

This PR requires dev parsnip, so won't make it into 1.1.0.

@simonpcouch
Copy link
Contributor Author

simonpcouch commented Sep 9, 2022

Noting that a side effect of this is we may not need to PR separately to tune. With this PR, we see:

# note: do not load required parsnip extension
library(parsnip)
library(tune)
library(rsample)

bt_mod <- bag_tree() %>%
 set_engine("rpart") %>%
 set_mode("regression")

bt_tune <- 
 fit_resamples(
   bt_mod,
   mpg ~ .,
   resamples = bootstraps(mtcars)
 )
#> ! parsnip could not locate an implementation for `bag_tree` regression model
#>   specifications using the `rpart` engine.
#> ℹ The parsnip extension package baguette implements support for this
#>   specification.
#> ℹ Please install (if needed) and load to continue.
#> 
#> x Bootstrap01: preprocessor 1/1: Error in if (nrow(out) != 1L) : argument is of length zero
#> x Bootstrap02: preprocessor 1/1: Error in if (nrow(out) != 1L) : argument is of length zero
#> x Bootstrap03: preprocessor 1/1: Error in if (nrow(out) != 1L) : argument is of length zero
#> x Bootstrap04: preprocessor 1/1: Error in if (nrow(out) != 1L) : argument is of length zero
#> x Bootstrap05: preprocessor 1/1: Error in if (nrow(out) != 1L) : argument is of length zero
#> x Bootstrap06: preprocessor 1/1: Error in if (nrow(out) != 1L) : argument is of length zero
#> x Bootstrap07: preprocessor 1/1: Error in if (nrow(out) != 1L) : argument is of length zero
#> x Bootstrap08: preprocessor 1/1: Error in if (nrow(out) != 1L) : argument is of length zero
#> x Bootstrap09: preprocessor 1/1: Error in if (nrow(out) != 1L) : argument is of length zero
#> x Bootstrap10: preprocessor 1/1: Error in if (nrow(out) != 1L) : argument is of length zero
#> x Bootstrap11: preprocessor 1/1: Error in if (nrow(out) != 1L) : argument is of length zero
#> x Bootstrap12: preprocessor 1/1: Error in if (nrow(out) != 1L) : argument is of length zero
#> x Bootstrap13: preprocessor 1/1: Error in if (nrow(out) != 1L) : argument is of length zero
#> x Bootstrap14: preprocessor 1/1: Error in if (nrow(out) != 1L) : argument is of length zero
#> x Bootstrap15: preprocessor 1/1: Error in if (nrow(out) != 1L) : argument is of length zero
#> x Bootstrap16: preprocessor 1/1: Error in if (nrow(out) != 1L) : argument is of length zero
#> x Bootstrap17: preprocessor 1/1: Error in if (nrow(out) != 1L) : argument is of length zero
#> x Bootstrap18: preprocessor 1/1: Error in if (nrow(out) != 1L) : argument is of length zero
#> x Bootstrap19: preprocessor 1/1: Error in if (nrow(out) != 1L) : argument is of length zero
#> x Bootstrap20: preprocessor 1/1: Error in if (nrow(out) != 1L) : argument is of length zero
#> x Bootstrap21: preprocessor 1/1: Error in if (nrow(out) != 1L) : argument is of length zero
#> x Bootstrap22: preprocessor 1/1: Error in if (nrow(out) != 1L) : argument is of length zero
#> x Bootstrap23: preprocessor 1/1: Error in if (nrow(out) != 1L) : argument is of length zero
#> x Bootstrap24: preprocessor 1/1: Error in if (nrow(out) != 1L) : argument is of length zero
#> x Bootstrap25: preprocessor 1/1: Error in if (nrow(out) != 1L) : argument is of length zero
#> Warning: All models failed. Run `show_notes(.Last.tune.result)` for more
#> information.

Created on 2022-09-09 by the reprex package (v2.0.1)

This may be an argument for elevating the message at add_model to an error—add_model is not really computationally intensive, so not a lot of time lost when it needs to be run again, and this would prevent the rest of the tune printing in this reprex.

I'd prefer the referenced call in the second snapshot to be `workflow` rather than `add_model`, though this would be a good bit more invasive.
@simonpcouch
Copy link
Contributor Author

Going to go ahead and close this. The thought is that we fail early enough to prevent people from running computationally intensive things before running into issues. In practice, I think parsnip makes this happen most of the time: if a user is tuning a workflow and that workflow uses an engine that isn't loaded, then all models will fail with the parsnip error and that tuning will only take a second or two.

It is true that if a user is tuning a workflowset, and some needed extensions are loaded while others are not, the specs with loaded extensions will tune fully before notifying the user that the others failed. I think I'm okay with this.

This was the last of the places where we would implement the missing extension error, and it's the only one outside of parsnip, so it looks like we actually don't need to export those helpers. Will put in a PR there in the next few days!

@github-actions
Copy link

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 30, 2022
@simonpcouch simonpcouch restored the extension-prompt branch October 28, 2022 20:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

uninformative error without needed parsnip extension

2 participants