-
Notifications
You must be signed in to change notification settings - Fork 92
prompt on unavailable extension packages #732
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
Conversation
addresses "argument is of length zero" failure and accommodates non-standard modes other than `"unknown"`
This reverts commit 3bd57a8.
I think this would make the most sense in an |
Ah, thank you @juliasilge! I agree that Just pushed those changes—they're a bit more invasive now but do result in a better interface. |
still need to use suggested packages conditionally
Wrapping up for the night, though this isn't quite there.🌝🌚 |
drops the dedicated test, as it's failure/success seems to depend on whether rules is currently loaded
fixes: * checking for unstated dependencies in examples WARNING * checking Rd line widths NOTE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A quick self-review to give some context for changes. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be a huge help to give more useful info in this situation! 🙌
I've got a bit of specific feedback and then some questions about the approach.
R/misc.R
Outdated
avail <- | ||
get_from_env(spec_) %>% | ||
dplyr::filter(mode %in% mode_, !!eng_cond) | ||
pars <- | ||
utils::read.delim(system.file("models.tsv", package = "parsnip")) %>% | ||
dplyr::filter(model == spec_, !!eng_cond, mode %in% mode_, is.na(pkg)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this an expensive check to do every time new_model_spec()
is run (which is run a lot, I think)? The env
is just there, but what about reading the file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Certainly more expensive than our other checks. But—
- It’s only run on initiation of new model types (i.e. never at
set_engine
,update
, etc) - It’s possibly negligible compared to fit times:
library(parsnip)
# running the check
system.time(mod <- C5_rules())
#> parsnip could not locate an implementation for `C5_rules` classification model specifications using the `C5.0` engine.
#> ℹ The parsnip extension package rules implements support for this specification.
#> ℹ Please install (if needed) and load to continue.
#> user system elapsed
#> 0.038 0.001 0.039
# doesn't run the check
system.time(mod <- mod %>% set_engine("C5.0"))
#> user system elapsed
#> 0.008 0.000 0.009
# model fit to a lil fella
library(rules)
mtcars$cyl <- as.factor(mtcars$cyl)
system.time(mod %>% fit(cyl ~ ., mtcars))
#> user system elapsed
#> 0.445 0.020 0.467
Created on 2022-05-25 by the reprex package (v2.0.1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fact that it could be common to read this file multiple times seems like something to check and get other feedback on. We could read this file one time at .onLoad
or something? Let's have one more person look at this part of the PR and see what they think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's a good observation. After 9918043, parsnip now assigns the models.tsv
system file as model_info_table
internally so we can skip that load step on checks:
library(parsnip)
# now just assigns models.tsv to internal object:
head(parsnip:::model_info_table)
#> model mode engine pkg
#> 1 bag_mars classification earth baguette
#> 2 bag_mars regression earth baguette
#> 3 bag_tree censored regression rpart censored
#> 4 bag_tree classification C5.0 baguette
#> 5 bag_tree classification rpart baguette
#> 6 bag_tree regression rpart baguette
# running the check. used to be:
#> user system elapsed
#> 0.038 0.001 0.039
system.time(mod <- C5_rules())
#> parsnip could not locate an implementation for `C5_rules` classification model specifications using the `C5.0` engine.
#> ℹ The parsnip extension package rules implements support for this specification.
#> ℹ Please install (if needed) and load to continue.
#> user system elapsed
#> 0.033 0.001 0.033
# doesn't run the check. used to be:
#> user system elapsed
#> 0.008 0.000 0.009
system.time(mod <- mod %>% set_engine("C5.0"))
#> user system elapsed
#> 0.007 0.000 0.007
# model fit to a lil fella, for comparison
library(rules)
mtcars$cyl <- as.factor(mtcars$cyl)
system.time(mod %>% fit(cyl ~ ., mtcars))
#> user system elapsed
#> 0.440 0.025 0.464
Created on 2022-05-27 by the reprex package (v2.0.1)
I opted not to ditch that models.tsv
file entirely as it seems our machinery to keep it updated with the current docs system works well.
delineates the message from the model printer a bit better: ``` > C5_rules() parsnip could not locate an implementation for `C5_rules` classification model specifications using the `C5.0` engine. ℹ The parsnip extension package rules implements support for this specification. ℹ Please install (if needed) and load to continue. C5.0 Model Specification (classification) Computational engine: C5.0 ```
R/misc.R
Outdated
avail <- | ||
get_from_env(spec_) %>% | ||
dplyr::filter(mode %in% mode_, !!eng_cond) | ||
pars <- | ||
utils::read.delim(system.file("models.tsv", package = "parsnip")) %>% | ||
dplyr::filter(model == spec_, !!eng_cond, mode %in% mode_, is.na(pkg)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fact that it could be common to read this file multiple times seems like something to check and get other feedback on. We could read this file one time at .onLoad
or something? Let's have one more person look at this part of the PR and see what they think.
This should be ready for your review, @topepo! One unresolved discussion that we'd especially appreciate your eye on: #732 (comment) |
Note from meeting: thumbs up from Max to merge! |
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. |
Closes #731.
I've had a few moments of confusion as I've familiarized with parsnip where I unknowingly specify a model specification/engine/mode combination that requires an extension package, and only come across failures later on in a modeling pipeline. This seems to be the source of confusion in #544 as well.
This PR refines print methods to nudge users to load an extension package if it's needed.
Created on 2022-05-27 by the reprex package (v2.0.1)
[EDIT: updated reprex and explanation to reflect changes re: Julia's edits]