Skip to content
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

consider warning if specific axe_* methods are not available #214

Open
dpprdan opened this issue Feb 25, 2022 · 2 comments
Open

consider warning if specific axe_* methods are not available #214

dpprdan opened this issue Feb 25, 2022 · 2 comments
Labels
feature a feature request or enhancement

Comments

@dpprdan
Copy link
Contributor

dpprdan commented Feb 25, 2022

Please consider adding a warning to axe_*.default() methods that the package, which created the object (and might contain more specific axe_* methods) is not loaded.

I ran into this while trying to butcher() a workflow after loading it back in. (I am not butcher()ing before saving, due to #147)

The xgb_mod.rds is the workflow used in tidymodels/workflows#138

library(butcher)
xgb_mod <- readRDS("xgb_mod.rds")

## No message or warning without `verbose = TRUE` even though nothing is happening
xgb_btchrd <- butcher(xgb_mod)
all.equal(xgb_btchrd, xgb_mod)
#> [1] TRUE

## Cannot butcher if method is not available (but `verbose` message does not say that)
xgb_btchrd <- butcher(xgb_mod, TRUE)
#> x No memory released. Do not butcher.

library(workflows)

## Now we're talking
xgb_btchrd <- butcher(xgb_mod, TRUE)
#> Warning in as.function.default(c(formals(x), body(x)), env = rlang::base_env()):
#> partial argument match of 'env' to 'envir'
#> v Memory released: '943,080 B'

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

Session info
sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value
#>  version  R version 4.1.2 (2021-11-01)
#>  os       Windows 10 x64 (build 19043)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language en
#>  collate  German_Germany.1252
#>  ctype    German_Germany.1252
#>  tz       Europe/Berlin
#>  date     2022-02-25
#>  pandoc   2.17.1.1 @ C:/Program Files/RStudio/bin/quarto/bin/ (via rmarkdown)
#> 
#> - Packages -------------------------------------------------------------------
#>  package      * version    date (UTC) lib source
#>  assertthat     0.2.1      2019-03-21 [1] CRAN (R 4.1.0)
#>  backports      1.4.1      2021-12-13 [1] CRAN (R 4.1.2)
#>  butcher      * 0.1.5.9000 2022-02-25 [1] Github (tidymodels/butcher@d7ed75f)
#>  class          7.3-19     2021-05-03 [2] CRAN (R 4.1.2)
#>  cli            3.2.0      2022-02-14 [1] CRAN (R 4.1.2)
#>  codetools      0.2-18     2020-11-04 [2] CRAN (R 4.1.2)
#>  colorspace     2.0-3      2022-02-21 [1] CRAN (R 4.1.2)
#>  crayon         1.5.0      2022-02-14 [1] CRAN (R 4.1.2)
#>  data.table     1.14.2     2021-09-27 [1] CRAN (R 4.1.1)
#>  DBI            1.1.2      2021-12-20 [1] CRAN (R 4.1.2)
#>  digest         0.6.29     2021-12-01 [1] CRAN (R 4.1.2)
#>  dplyr          1.0.8      2022-02-08 [1] CRAN (R 4.1.2)
#>  ellipsis       0.3.2      2021-04-29 [1] CRAN (R 4.1.0)
#>  evaluate       0.15       2022-02-18 [1] CRAN (R 4.1.2)
#>  fansi          1.0.2      2022-01-14 [1] CRAN (R 4.1.2)
#>  fastmap        1.1.0      2021-01-25 [1] CRAN (R 4.1.0)
#>  fs             1.5.2.9000 2022-02-03 [1] Github (r-lib/fs@6d1182f)
#>  future         1.24.0     2022-02-19 [1] CRAN (R 4.1.2)
#>  future.apply   1.8.1      2021-08-10 [1] CRAN (R 4.1.1)
#>  generics       0.1.2      2022-01-31 [1] CRAN (R 4.1.2)
#>  ggplot2        3.3.5      2021-06-25 [1] CRAN (R 4.1.0)
#>  globals        0.14.0     2020-11-22 [1] CRAN (R 4.1.0)
#>  glue           1.6.2      2022-02-24 [1] CRAN (R 4.1.2)
#>  gower          1.0.0      2022-02-03 [1] CRAN (R 4.1.2)
#>  gtable         0.3.0      2019-03-25 [1] CRAN (R 4.1.0)
#>  hardhat        0.2.0      2022-01-24 [1] CRAN (R 4.1.2)
#>  highr          0.9        2021-04-16 [1] CRAN (R 4.1.0)
#>  htmltools      0.5.2      2021-08-25 [1] CRAN (R 4.1.1)
#>  ipred          0.9-12     2021-09-15 [1] CRAN (R 4.1.1)
#>  jsonlite       1.8.0      2022-02-22 [1] CRAN (R 4.1.2)
#>  knitr          1.37       2021-12-16 [1] CRAN (R 4.1.2)
#>  lattice        0.20-45    2021-09-22 [2] CRAN (R 4.1.2)
#>  lava           1.6.10     2021-09-02 [1] CRAN (R 4.1.1)
#>  lifecycle      1.0.1      2021-09-24 [1] CRAN (R 4.1.1)
#>  listenv        0.8.0      2019-12-05 [1] CRAN (R 4.1.0)
#>  lobstr         1.1.1      2019-07-02 [1] CRAN (R 4.1.1)
#>  lubridate      1.8.0      2021-10-07 [1] CRAN (R 4.1.1)
#>  magrittr       2.0.2      2022-01-26 [1] CRAN (R 4.1.2)
#>  MASS           7.3-54     2021-05-03 [2] CRAN (R 4.1.2)
#>  Matrix         1.3-4      2021-06-01 [2] CRAN (R 4.1.2)
#>  munsell        0.5.0      2018-06-12 [1] CRAN (R 4.1.0)
#>  nnet           7.3-16     2021-05-03 [2] CRAN (R 4.1.2)
#>  parallelly     1.30.0     2021-12-17 [1] CRAN (R 4.1.2)
#>  parsnip        0.1.7.9006 2022-02-25 [1] Github (tidymodels/parsnip@3e2447c)
#>  pillar         1.7.0      2022-02-01 [1] CRAN (R 4.1.2)
#>  pkgconfig      2.0.3      2019-09-22 [1] CRAN (R 4.1.0)
#>  prodlim        2019.11.13 2019-11-17 [1] CRAN (R 4.1.1)
#>  purrr          0.3.4      2020-04-17 [1] CRAN (R 4.1.0)
#>  R.cache        0.15.0     2021-04-30 [1] CRAN (R 4.1.0)
#>  R.methodsS3    1.8.1      2020-08-26 [1] CRAN (R 4.1.0)
#>  R.oo           1.24.0     2020-08-26 [1] CRAN (R 4.1.0)
#>  R.utils        2.11.0     2021-09-26 [1] CRAN (R 4.1.1)
#>  R6             2.5.1      2021-08-19 [1] CRAN (R 4.1.1)
#>  Rcpp           1.0.8      2022-01-13 [1] CRAN (R 4.1.2)
#>  recipes        0.2.0      2022-02-18 [1] CRAN (R 4.1.2)
#>  reprex         2.0.1      2021-08-05 [1] CRAN (R 4.1.0)
#>  rlang          1.0.1      2022-02-03 [1] CRAN (R 4.1.2)
#>  rmarkdown      2.11       2021-09-14 [1] CRAN (R 4.1.1)
#>  rpart          4.1-15     2019-04-12 [2] CRAN (R 4.1.2)
#>  rstudioapi     0.13       2020-11-12 [1] CRAN (R 4.1.0)
#>  scales         1.1.1      2020-05-11 [1] CRAN (R 4.1.0)
#>  sessioninfo    1.2.2      2021-12-06 [1] CRAN (R 4.1.2)
#>  stringi        1.7.6      2021-11-29 [1] CRAN (R 4.1.2)
#>  stringr        1.4.0      2019-02-10 [1] CRAN (R 4.1.0)
#>  styler         1.6.2      2021-09-23 [1] CRAN (R 4.1.1)
#>  survival       3.2-13     2021-08-24 [2] CRAN (R 4.1.2)
#>  tibble         3.1.6      2021-11-07 [1] CRAN (R 4.1.2)
#>  tidyr          1.2.0      2022-02-01 [1] CRAN (R 4.1.2)
#>  tidyselect     1.1.2      2022-02-21 [1] CRAN (R 4.1.2)
#>  timeDate       3043.102   2018-02-21 [1] CRAN (R 4.1.1)
#>  usethis        2.1.5      2021-12-09 [1] CRAN (R 4.1.2)
#>  utf8           1.2.2      2021-07-24 [1] CRAN (R 4.1.0)
#>  vctrs          0.3.8      2021-04-29 [1] CRAN (R 4.1.0)
#>  withr          2.4.3      2021-11-30 [1] CRAN (R 4.1.2)
#>  workflows    * 0.2.4.9002 2022-02-25 [1] Github (tidymodels/workflows@4e348f8)
#>  xfun           0.29       2021-12-14 [1] CRAN (R 4.1.2)
#>  xgboost        1.5.2.1    2022-02-21 [1] CRAN (R 4.1.2)
#>  yaml           2.3.5      2022-02-21 [1] CRAN (R 4.1.2)
#> 
#>  [1] C:/Users/Daniel.AK-HAMBURG/Documents/R/win-library/4.1
#>  [2] C:/Program Files/R/R-4.1.2/library
#> 
#> ------------------------------------------------------------------------------
@amazongodman

This comment was marked as off-topic.

@dpprdan
Copy link
Contributor Author

dpprdan commented Apr 20, 2022

@amazongodman from looking at your example, I am not entirely sure whether it applies to this issue here (or the one reported over at parsnip for that matter), because you must have loaded {workflows}, so workflow's axe_*() methods must be available?
Anyway, my initial example is not a very good one, because one shouldn't use saveRDS()/readRDS() directly on {xgboost} models. That doesn't change the issue I reported here, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants