business-science / modeltime.gluonts

GluonTS Deep Learning with Modeltime

Home Page:https://business-science.github.io/modeltime.gluonts/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in rlang::env_get(get_model_env(), paste0(cls, "_modes")): argument "default" is missing, with no default

gofford opened this issue · comments

Hey @mdancho84 -- I'm getting a failure for main modeltime.gluonts example. Reprex with error message and sessionInfo() below.

I can't find the precise location of the error but looks like an argument is missing to rlang::env_get... somewhere. Unclear if this is an issue with modeltime.gluonts specifically or in a dependency, but posting here first as this is where I found it.

library(modeltime.gluonts)
#> Loading required package: modeltime
library(tidymodels)
#> ── Attaching packages ────────────────────────────────────── tidymodels 0.1.2 ──
#> ✓ broom     0.7.2      ✓ recipes   0.1.15
#> ✓ dials     0.0.9      ✓ rsample   0.0.8 
#> ✓ dplyr     1.0.2      ✓ tibble    3.0.4 
#> ✓ ggplot2   3.3.2      ✓ tidyr     1.1.2 
#> ✓ infer     0.5.3      ✓ tune      0.1.2 
#> ✓ modeldata 0.1.0      ✓ workflows 0.2.1 
#> ✓ parsnip   0.1.4      ✓ yardstick 0.0.7 
#> ✓ purrr     0.3.4
#> ── Conflicts ───────────────────────────────────────── tidymodels_conflicts() ──
#> x purrr::discard() masks scales::discard()
#> x dplyr::filter()  masks stats::filter()
#> x dplyr::lag()     masks stats::lag()
#> x recipes::step()  masks stats::step()
library(tidyverse)

# Fit a GluonTS DeepAR Model
model_fit_deepar <- deep_ar(
    id                    = "id",
    freq                  = "M",
    prediction_length     = 24,
    lookback_length       = 36,
    epochs                = 10, 
    num_batches_per_epoch = 50,
    learn_rate            = 0.001,
    num_layers            = 2,
    dropout               = 0.10
) %>%
    set_engine("gluonts_deepar") %>%
    fit(value ~ ., training(m750_splits))
#> Error in rlang::env_get(get_model_env(), paste0(cls, "_modes")): argument "default" is missing, with no default

Created on 2020-12-08 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 3.6.0 (2019-04-26)
#>  os       Debian GNU/Linux 9 (stretch)
#>  system   x86_64, linux-gnu           
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       Etc/UTC                     
#>  date     2020-12-08                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package           * version    date       lib
#>  assertthat          0.2.1      2019-03-21 [1]
#>  backports           1.2.0      2020-11-02 [1]
#>  broom             * 0.7.2      2020-10-20 [1]
#>  callr               3.5.1      2020-10-13 [1]
#>  cellranger          1.1.0      2016-07-27 [1]
#>  class               7.3-15     2019-01-01 [2]
#>  cli                 2.2.0      2020-11-20 [1]
#>  codetools           0.2-16     2018-12-24 [2]
#>  colorspace          2.0-0      2020-11-11 [1]
#>  crayon              1.3.4      2017-09-16 [1]
#>  DBI                 1.1.0      2019-12-15 [1]
#>  dbplyr              2.0.0      2020-11-03 [1]
#>  desc                1.2.0      2018-05-01 [1]
#>  devtools            2.3.2      2020-09-18 [1]
#>  dials             * 0.0.9      2020-09-16 [1]
#>  DiceDesign          1.8-1      2019-07-31 [1]
#>  digest              0.6.27     2020-10-24 [1]
#>  dplyr             * 1.0.2      2020-08-18 [1]
#>  ellipsis            0.3.1      2020-05-15 [1]
#>  evaluate            0.14       2019-05-28 [1]
#>  fansi               0.4.1      2020-01-08 [1]
#>  forcats           * 0.5.0      2020-03-01 [1]
#>  foreach             1.5.1      2020-10-15 [1]
#>  fs                  1.5.0      2020-07-31 [1]
#>  furrr               0.2.1      2020-10-21 [1]
#>  future              1.20.1     2020-11-03 [1]
#>  generics            0.1.0      2020-10-31 [1]
#>  ggplot2           * 3.3.2      2020-06-19 [1]
#>  globals             0.14.0     2020-11-22 [1]
#>  glue                1.4.2      2020-08-27 [1]
#>  gower               0.2.2      2020-06-23 [1]
#>  GPfit               1.0-8      2019-02-08 [1]
#>  gtable              0.3.0      2019-03-25 [1]
#>  haven               2.3.1      2020-06-01 [1]
#>  highr               0.8        2019-03-20 [1]
#>  hms                 0.5.3      2020-01-08 [1]
#>  htmltools           0.5.0      2020-06-16 [1]
#>  httr                1.4.2      2020-07-20 [1]
#>  infer             * 0.5.3      2020-07-14 [1]
#>  ipred               0.9-9      2019-04-28 [1]
#>  iterators           1.0.13     2020-10-15 [1]
#>  jsonlite            1.7.1      2020-09-07 [1]
#>  knitr               1.30       2020-09-22 [1]
#>  lattice             0.20-38    2018-11-04 [2]
#>  lava                1.6.8.1    2020-11-04 [1]
#>  lhs                 1.1.1      2020-10-05 [1]
#>  lifecycle           0.2.0      2020-03-06 [1]
#>  listenv             0.8.0      2019-12-05 [1]
#>  lubridate           1.7.9.2    2020-11-13 [1]
#>  magrittr            2.0.1      2020-11-17 [1]
#>  MASS                7.3-51.4   2019-03-31 [2]
#>  Matrix              1.2-17     2019-03-22 [2]
#>  memoise             1.1.0      2017-04-21 [1]
#>  modeldata         * 0.1.0      2020-10-22 [1]
#>  modelr              0.1.8      2020-05-19 [1]
#>  modeltime         * 0.4.0.9000 2020-12-03 [1]
#>  modeltime.gluonts * 0.1.0.9000 2020-12-08 [1]
#>  munsell             0.5.0      2018-06-12 [1]
#>  nnet                7.3-12     2016-02-02 [2]
#>  parallelly          1.21.0     2020-10-27 [1]
#>  parsnip           * 0.1.4      2020-10-27 [1]
#>  pillar              1.4.7      2020-11-20 [1]
#>  pkgbuild            1.1.0      2020-07-13 [1]
#>  pkgconfig           2.0.3      2019-09-22 [1]
#>  pkgload             1.1.0      2020-05-29 [1]
#>  plyr                1.8.6      2020-03-03 [1]
#>  prettyunits         1.1.1      2020-01-24 [1]
#>  pROC                1.16.2     2020-03-19 [1]
#>  processx            3.4.5      2020-11-30 [1]
#>  prodlim             2019.11.13 2019-11-17 [1]
#>  ps                  1.5.0      2020-12-05 [1]
#>  purrr             * 0.3.4      2020-04-17 [1]
#>  R6                  2.5.0      2020-10-28 [1]
#>  Rcpp                1.0.5      2020-07-06 [1]
#>  RcppParallel        5.0.2      2020-06-24 [1]
#>  readr             * 1.4.0      2020-10-05 [1]
#>  readxl              1.3.1      2019-03-13 [1]
#>  recipes           * 0.1.15     2020-11-11 [1]
#>  remotes             2.2.0      2020-07-21 [1]
#>  reprex              0.3.0      2019-05-16 [1]
#>  reticulate          1.18       2020-10-25 [1]
#>  rlang               0.4.9      2020-11-26 [1]
#>  rmarkdown           2.5        2020-10-21 [1]
#>  rpart               4.1-15     2019-04-12 [2]
#>  rprojroot           2.0.2      2020-11-15 [1]
#>  rsample           * 0.0.8      2020-09-23 [1]
#>  rstudioapi          0.13       2020-11-12 [1]
#>  rvest               0.3.6      2020-07-25 [1]
#>  scales            * 1.1.1      2020-05-11 [1]
#>  sessioninfo         1.1.1      2018-11-05 [1]
#>  StanHeaders         2.21.0-6   2020-08-16 [1]
#>  stringi             1.5.3      2020-09-09 [1]
#>  stringr           * 1.4.0      2019-02-10 [1]
#>  survival            2.44-1.1   2019-04-01 [2]
#>  testthat            3.0.0      2020-10-31 [1]
#>  tibble            * 3.0.4      2020-10-12 [1]
#>  tidymodels        * 0.1.2      2020-11-22 [1]
#>  tidyr             * 1.1.2      2020-08-27 [1]
#>  tidyselect          1.1.0      2020-05-11 [1]
#>  tidyverse         * 1.3.0      2019-11-21 [1]
#>  timeDate            3043.102   2018-02-21 [1]
#>  tune              * 0.1.2      2020-11-17 [1]
#>  usethis             1.6.3      2020-09-17 [1]
#>  vctrs               0.3.5      2020-11-17 [1]
#>  withr               2.3.0      2020-09-22 [1]
#>  workflows         * 0.2.1      2020-10-08 [1]
#>  xfun                0.19       2020-10-30 [1]
#>  xml2                1.3.2      2020-04-23 [1]
#>  yaml                2.2.1      2020-02-01 [1]
#>  yardstick         * 0.0.7      2020-07-13 [1]
#>  source                                             
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  Github (business-science/modeltime@f126665)        
#>  Github (business-science/modeltime.gluonts@2c95409)
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#> 
#> [1] /usr/local/lib/R/site-library
#> [2] /usr/local/lib/R/library

This looks like it might be a parsnip issue. Try upgrading parsnip to >=0.1.4.

I've updated the modeletime.gluonts package development version. Try restarting your R session and reinstalling using: devetools::install_github('business-science/modeltime.gluonts'). This will force an update of parsnip.

Also, make sure you run modeltime.gluonts::install_gluonts(), which will update your python dependencies.

The issue unfortunately remains after including latest parsnip and modeltime.gluonts versions.

remotes::install_github("tidymodels/parsnip")
#> Skipping install of 'parsnip' from a github remote, the SHA1 (a82ed405) has not changed since last install.
#>   Use `force = TRUE` to force installation
remotes::install_github("business-science/modeltime.gluonts")
#> Skipping install of 'modeltime.gluonts' from a github remote, the SHA1 (86df28d1) has not changed since last install.
#>   Use `force = TRUE` to force installation

Sys.setenv(GLUONTS_PYTHON = "/home/jasongoffordw0/.local/share/r-miniconda/envs/r-gluonts/bin/python")

library(modeltime.gluonts)
#> Loading required package: modeltime
library(tidymodels)
#> ── Attaching packages ────────────────────────────────────── tidymodels 0.1.2 ──
#> ✓ broom     0.7.2          ✓ recipes   0.1.15    
#> ✓ dials     0.0.9          ✓ rsample   0.0.8     
#> ✓ dplyr     1.0.2          ✓ tibble    3.0.4     
#> ✓ ggplot2   3.3.2          ✓ tidyr     1.1.2     
#> ✓ infer     0.5.3          ✓ tune      0.1.2     
#> ✓ modeldata 0.1.0          ✓ workflows 0.2.1     
#> ✓ parsnip   0.1.4.9000     ✓ yardstick 0.0.7     
#> ✓ purrr     0.3.4
#> ── Conflicts ───────────────────────────────────────── tidymodels_conflicts() ──
#> x purrr::discard() masks scales::discard()
#> x dplyr::filter()  masks stats::filter()
#> x dplyr::lag()     masks stats::lag()
#> x recipes::step()  masks stats::step()
library(tidyverse)

# Fit a GluonTS DeepAR Model
model_fit_deepar <- deep_ar(
    id                    = "id",
    freq                  = "M",
    prediction_length     = 24,
    lookback_length       = 36,
    epochs                = 10, 
    num_batches_per_epoch = 50,
    learn_rate            = 0.001,
    num_layers            = 2,
    dropout               = 0.10
) %>%
    set_engine("gluonts_deepar") %>%
    fit(value ~ ., training(m750_splits))
#> Error in rlang::env_get(get_model_env(), paste0(cls, "_modes")): argument "default" is missing, with no default

Created on 2020-12-08 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 3.6.0 (2019-04-26)
#>  os       Debian GNU/Linux 9 (stretch)
#>  system   x86_64, linux-gnu           
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       Etc/UTC                     
#>  date     2020-12-08                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package           * version    date       lib
#>  assertthat          0.2.1      2019-03-21 [1]
#>  backports           1.2.0      2020-11-02 [1]
#>  broom             * 0.7.2      2020-10-20 [1]
#>  callr               3.5.1      2020-10-13 [1]
#>  cellranger          1.1.0      2016-07-27 [1]
#>  class               7.3-15     2019-01-01 [2]
#>  cli                 2.2.0      2020-11-20 [1]
#>  codetools           0.2-16     2018-12-24 [2]
#>  colorspace          2.0-0      2020-11-11 [1]
#>  crayon              1.3.4      2017-09-16 [1]
#>  curl                4.3        2019-12-02 [1]
#>  DBI                 1.1.0      2019-12-15 [1]
#>  dbplyr              2.0.0      2020-11-03 [1]
#>  desc                1.2.0      2018-05-01 [1]
#>  devtools            2.3.2      2020-09-18 [1]
#>  dials             * 0.0.9      2020-09-16 [1]
#>  DiceDesign          1.8-1      2019-07-31 [1]
#>  digest              0.6.27     2020-10-24 [1]
#>  dplyr             * 1.0.2      2020-08-18 [1]
#>  ellipsis            0.3.1      2020-05-15 [1]
#>  evaluate            0.14       2019-05-28 [1]
#>  fansi               0.4.1      2020-01-08 [1]
#>  forcats           * 0.5.0      2020-03-01 [1]
#>  foreach             1.5.1      2020-10-15 [1]
#>  fs                  1.5.0      2020-07-31 [1]
#>  furrr               0.2.1      2020-10-21 [1]
#>  future              1.20.1     2020-11-03 [1]
#>  generics            0.1.0      2020-10-31 [1]
#>  ggplot2           * 3.3.2      2020-06-19 [1]
#>  globals             0.14.0     2020-11-22 [1]
#>  glue                1.4.2      2020-08-27 [1]
#>  gower               0.2.2      2020-06-23 [1]
#>  GPfit               1.0-8      2019-02-08 [1]
#>  gtable              0.3.0      2019-03-25 [1]
#>  haven               2.3.1      2020-06-01 [1]
#>  highr               0.8        2019-03-20 [1]
#>  hms                 0.5.3      2020-01-08 [1]
#>  htmltools           0.5.0      2020-06-16 [1]
#>  httr                1.4.2      2020-07-20 [1]
#>  infer             * 0.5.3      2020-07-14 [1]
#>  ipred               0.9-9      2019-04-28 [1]
#>  iterators           1.0.13     2020-10-15 [1]
#>  jsonlite            1.7.1      2020-09-07 [1]
#>  knitr               1.30       2020-09-22 [1]
#>  lattice             0.20-38    2018-11-04 [2]
#>  lava                1.6.8.1    2020-11-04 [1]
#>  lhs                 1.1.1      2020-10-05 [1]
#>  lifecycle           0.2.0      2020-03-06 [1]
#>  listenv             0.8.0      2019-12-05 [1]
#>  lubridate           1.7.9.2    2020-11-13 [1]
#>  magrittr            2.0.1      2020-11-17 [1]
#>  MASS                7.3-51.4   2019-03-31 [2]
#>  Matrix              1.2-17     2019-03-22 [2]
#>  memoise             1.1.0      2017-04-21 [1]
#>  modeldata         * 0.1.0      2020-10-22 [1]
#>  modelr              0.1.8      2020-05-19 [1]
#>  modeltime         * 0.4.0.9000 2020-12-03 [1]
#>  modeltime.gluonts * 0.1.0.9000 2020-12-08 [1]
#>  munsell             0.5.0      2018-06-12 [1]
#>  nnet                7.3-12     2016-02-02 [2]
#>  parallelly          1.21.0     2020-10-27 [1]
#>  parsnip           * 0.1.4.9000 2020-12-08 [1]
#>  pillar              1.4.7      2020-11-20 [1]
#>  pkgbuild            1.1.0      2020-07-13 [1]
#>  pkgconfig           2.0.3      2019-09-22 [1]
#>  pkgload             1.1.0      2020-05-29 [1]
#>  plyr                1.8.6      2020-03-03 [1]
#>  prettyunits         1.1.1      2020-01-24 [1]
#>  pROC                1.16.2     2020-03-19 [1]
#>  processx            3.4.5      2020-11-30 [1]
#>  prodlim             2019.11.13 2019-11-17 [1]
#>  ps                  1.5.0      2020-12-05 [1]
#>  purrr             * 0.3.4      2020-04-17 [1]
#>  R6                  2.5.0      2020-10-28 [1]
#>  Rcpp                1.0.5      2020-07-06 [1]
#>  RcppParallel        5.0.2      2020-06-24 [1]
#>  readr             * 1.4.0      2020-10-05 [1]
#>  readxl              1.3.1      2019-03-13 [1]
#>  recipes           * 0.1.15     2020-11-11 [1]
#>  remotes             2.2.0      2020-07-21 [1]
#>  reprex              0.3.0      2019-05-16 [1]
#>  reticulate          1.18       2020-10-25 [1]
#>  rlang               0.4.9      2020-11-26 [1]
#>  rmarkdown           2.5        2020-10-21 [1]
#>  rpart               4.1-15     2019-04-12 [2]
#>  rprojroot           2.0.2      2020-11-15 [1]
#>  rsample           * 0.0.8      2020-09-23 [1]
#>  rstudioapi          0.13       2020-11-12 [1]
#>  rvest               0.3.6      2020-07-25 [1]
#>  scales            * 1.1.1      2020-05-11 [1]
#>  sessioninfo         1.1.1      2018-11-05 [1]
#>  StanHeaders         2.21.0-6   2020-08-16 [1]
#>  stringi             1.5.3      2020-09-09 [1]
#>  stringr           * 1.4.0      2019-02-10 [1]
#>  survival            2.44-1.1   2019-04-01 [2]
#>  testthat            3.0.0      2020-10-31 [1]
#>  tibble            * 3.0.4      2020-10-12 [1]
#>  tidymodels        * 0.1.2      2020-11-22 [1]
#>  tidyr             * 1.1.2      2020-08-27 [1]
#>  tidyselect          1.1.0      2020-05-11 [1]
#>  tidyverse         * 1.3.0      2019-11-21 [1]
#>  timeDate            3043.102   2018-02-21 [1]
#>  timetk              2.6.0.9000 2020-12-03 [1]
#>  tune              * 0.1.2      2020-11-17 [1]
#>  usethis             1.6.3      2020-09-17 [1]
#>  vctrs               0.3.5      2020-11-17 [1]
#>  withr               2.3.0      2020-09-22 [1]
#>  workflows         * 0.2.1      2020-10-08 [1]
#>  xfun                0.19       2020-10-30 [1]
#>  xml2                1.3.2      2020-04-23 [1]
#>  xts                 0.12.1     2020-09-09 [1]
#>  yaml                2.2.1      2020-02-01 [1]
#>  yardstick         * 0.0.7      2020-07-13 [1]
#>  zoo                 1.8-8      2020-05-02 [1]
#>  source                                             
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  Github (business-science/modeltime@f126665)        
#>  Github (business-science/modeltime.gluonts@86df28d)
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  Github (tidymodels/parsnip@a82ed40)                
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  Github (business-science/timetk@87831ab)           
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#> 
#> [1] /usr/local/lib/R/site-library
#> [2] /usr/local/lib/R/library

Traceback suggests that it is parsnip related, but unclear what the resolution is. Every other modeltime package works perfectly, so it's just this one where the issue is arising.

Error in rlang::env_get(get_model_env(), paste0(cls, "_modes")) : argument "default" is missing, with no default
6. rlang::env_get(get_model_env(), paste0(cls, "_modes"))
5. parsnip::new_model_spec("deep_ar", args = args, eng_args = NULL, mode = mode, method = NULL, engine = NULL)
4. deep_ar(id = "id", freq = "M", prediction_length = 24, lookback_length = 36, epochs = 10, num_batches_per_epoch = 50, learn_rate = 0.001, num_layers = 2, dropout = 0.1)
3. set_engine(., "gluonts_deepar")
2. fit(., value ~ ., training(m750_splits))
1. deep_ar(id = "id", freq = "M", prediction_length = 24, lookback_length = 36, epochs = 10, num_batches_per_epoch = 50, learn_rate = 0.001, num_layers = 2, dropout = 0.1) %>% set_engine("gluonts_deepar") %>% fit(value ~ ., training(m750_splits))

@topepos Are you aware of this? It looks like an issue with rlang::env_get() wanting a default environment set. Tough to tell because I'm not able to reproduce it.

Did you install GluonTS with install_gluonts()?

@mdancho84 yup, that was the first thing I ran. Seemed like it worked with all Python deps installed successfully.

If you're unable to reproduce (but it has been reproduced by others), is there anything else I can check my side?

Do me a favor. In a fresh session, run:

library(modeltime.gluonts)

reticulate::py_discover_config()

Let me know what the output is.

I've also just updated the .onLoad() to have the models load even if you cannot activate python. I'm thinking there is a hangup activating the Python 'r-gluonts' environment.

.onLoad <- function(libname, pkgname) {

    activate_gluonts()

    if (pkg.env$activated && check_python_dependencies()) {

        # LOAD PYTHON LIBRARIES ----
        pkg.env$gluonts <- reticulate::import("gluonts", delay_load = TRUE, convert = FALSE)
        pkg.env$pathlib <- reticulate::import("pathlib", delay_load = TRUE, convert = FALSE)
        pkg.env$np      <- reticulate::import("numpy", delay_load = TRUE, convert = FALSE)
        pkg.env$pd      <- reticulate::import("pandas", delay_load = TRUE, convert = FALSE)


    } else {
        # if (interactive()) {
        #     msg_no_gluonts()
        # }
        msg_no_gluonts()
    }

    # LOAD MODELS ----

    make_deep_ar()
    make_nbeats()
}

Hey @mdancho84 here's the requested output:

library(modeltime.gluonts)
#> Loading required package: modeltime
#> Warning: Python '/home/jasongoffordw0/.local/share/r-miniconda/envs/r-gluonts/
#> bin/python' was requested but '/opt/virtualenvs/r-workspace/bin/python' was
#> loaded instead (see reticulate::py_config() for more information)

reticulate::py_discover_config()
#> python:         /opt/virtualenvs/r-workspace/bin/python
#> libpython:      /usr/lib/python3.5/config-3.5m-x86_64-linux-gnu/libpython3.5.so
#> pythonhome:     /opt/virtualenvs/r-workspace:/opt/virtualenvs/r-workspace
#> version:        3.5.3 (default, Sep 27 2018, 17:25:39)  [GCC 6.3.0 20170516]
#> numpy:           [NOT FOUND]
#> 
#> NOTE: Python version was forced by RETICULATE_PYTHON_ENV

Created on 2020-12-10 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 3.6.0 (2019-04-26)
#>  os       Debian GNU/Linux 9 (stretch)
#>  system   x86_64, linux-gnu           
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       Etc/UTC                     
#>  date     2020-12-10                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package           * version    date       lib
#>  assertthat          0.2.1      2019-03-21 [1]
#>  callr               3.5.1      2020-10-13 [1]
#>  cli                 2.2.0      2020-11-20 [1]
#>  colorspace          2.0-0      2020-11-11 [1]
#>  crayon              1.3.4      2017-09-16 [1]
#>  desc                1.2.0      2018-05-01 [1]
#>  devtools            2.3.2      2020-09-18 [1]
#>  digest              0.6.27     2020-10-24 [1]
#>  dplyr               1.0.2      2020-08-18 [1]
#>  ellipsis            0.3.1      2020-05-15 [1]
#>  evaluate            0.14       2019-05-28 [1]
#>  fansi               0.4.1      2020-01-08 [1]
#>  fs                  1.5.0      2020-07-31 [1]
#>  generics            0.1.0      2020-10-31 [1]
#>  glue                1.4.2      2020-08-27 [1]
#>  highr               0.8        2019-03-20 [1]
#>  htmltools           0.5.0      2020-06-16 [1]
#>  jsonlite            1.7.1      2020-09-07 [1]
#>  knitr               1.30       2020-09-22 [1]
#>  lattice             0.20-38    2018-11-04 [2]
#>  lifecycle           0.2.0      2020-03-06 [1]
#>  magrittr            2.0.1      2020-11-17 [1]
#>  Matrix              1.2-17     2019-03-22 [2]
#>  memoise             1.1.0      2017-04-21 [1]
#>  modeltime         * 0.4.0.9000 2020-12-03 [1]
#>  modeltime.gluonts * 0.1.0.9000 2020-12-08 [1]
#>  munsell             0.5.0      2018-06-12 [1]
#>  parsnip             0.1.4.9000 2020-12-08 [1]
#>  pillar              1.4.7      2020-11-20 [1]
#>  pkgbuild            1.1.0      2020-07-13 [1]
#>  pkgconfig           2.0.3      2019-09-22 [1]
#>  pkgload             1.1.0      2020-05-29 [1]
#>  plyr                1.8.6      2020-03-03 [1]
#>  prettyunits         1.1.1      2020-01-24 [1]
#>  pROC                1.16.2     2020-03-19 [1]
#>  processx            3.4.5      2020-11-30 [1]
#>  ps                  1.5.0      2020-12-05 [1]
#>  purrr               0.3.4      2020-04-17 [1]
#>  R6                  2.5.0      2020-10-28 [1]
#>  rappdirs            0.3.1      2016-03-28 [1]
#>  Rcpp                1.0.5      2020-07-06 [1]
#>  RcppParallel        5.0.2      2020-06-24 [1]
#>  remotes             2.2.0      2020-07-21 [1]
#>  reticulate          1.18       2020-10-25 [1]
#>  rlang               0.4.9      2020-11-26 [1]
#>  rmarkdown           2.5        2020-10-21 [1]
#>  rprojroot           2.0.2      2020-11-15 [1]
#>  scales              1.1.1      2020-05-11 [1]
#>  sessioninfo         1.1.1      2018-11-05 [1]
#>  StanHeaders         2.21.0-6   2020-08-16 [1]
#>  stringi             1.5.3      2020-09-09 [1]
#>  stringr             1.4.0      2019-02-10 [1]
#>  testthat            3.0.0      2020-10-31 [1]
#>  tibble              3.0.4      2020-10-12 [1]
#>  tidyr               1.1.2      2020-08-27 [1]
#>  tidyselect          1.1.0      2020-05-11 [1]
#>  usethis             1.6.3      2020-09-17 [1]
#>  vctrs               0.3.5      2020-11-17 [1]
#>  withr               2.3.0      2020-09-22 [1]
#>  xfun                0.19       2020-10-30 [1]
#>  yaml                2.2.1      2020-02-01 [1]
#>  yardstick           0.0.7      2020-07-13 [1]
#>  source                                             
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  Github (business-science/modeltime@f126665)        
#>  Github (business-science/modeltime.gluonts@86df28d)
#>  CRAN (R 3.6.0)                                     
#>  Github (tidymodels/parsnip@a82ed40)                
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#>  CRAN (R 3.6.0)                                     
#> 
#> [1] /usr/local/lib/R/site-library
#> [2] /usr/local/lib/R/library

By default it's pointing at a different environment than the one where install_gluonts() installs content. I noticed this, and tried to account for it by setting GLUONTS_PYTHON.

I can get everything to work on a completely clean instance of rstudio-server with no prior install of reticulated Python. Suggests that it's a Python environment issue rather than with the modeltime.gluonts itself. Unclear what the actual issue is, but I'm happy to close this one out if you are?

OK, this is progress. We've identified the source of the problem and an interim solution:

Problem

The r-gluonts environment is not being found automatically. We can see this by using reticulate::py_discover_config().

#> Error in rlang::env_get(get_model_env(), paste0(cls, "_modes")): argument "default" is missing, with no default

Solution

First - Checks:

  • Make sure you have the latest version of R (4.0+)
  • Make sure you have the DEVELOPMENT version of modeltime.gluonts

Second - Manually point to the Python Environment containing GluonTS:

Point to the python executable inside the r-gluonts python environment that was created by install_gluonts(). In a fresh r-session (restart R):

Sys.setenv(GLUONTS_PYTHON = 'path/to/r-gluonts/bin/python')
library(modeltime.gluonts)

I still think that's ODD that the environment was not automatically loaded. I also see that you have a note indicating that something else forced the python environment. This may be something inside my package, but I will need to investigate.

#> NOTE: Python version was forced by RETICULATE_PYTHON_ENV

I added an environment variable with a path to the r-gluonts folder and still when trying to run the sample code, the same error is returned
image

What version of R packages are you running? If they are old maybe update them?

Also use dev version of modeltime.gluonts. I don't have 0.2.0 on CRAN yet

I was using old R version, now on 4.03 everything works as it should. Thanks for your reply

Awesome to hear. I will add that to the solution instructions.

OK - I updated the solution. Please give it a 👍 to point ppl to it.

Hi @mdancho84 ,
sorry for asking into this closed issue and sorry for not creating a reprex.
I found something (maybe) strange, so I wanted to know whether you found something similar.

I had the problems listed up here working with RStudio on Linux (Ubuntu).
Basic session info:
R version 4.1.1 (2021-08-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS

I went through all the steps you suggested in the vignette related to the Installation and I noticed this:

  • everything works perfectly when I am not working into an RStudio Project (even if loading modeltime.gluonts does not automatically pick up the r-gluonts python env, but setting manually the GLUONTS_PYTHON variable before loading modeltime.gluonts works smoothly).

  • if I work into an RStudio project, instead, loading modeltime.gluonts or setting the GLUONTS_PYTHON variable manually pointing to the r-gluonts env simply does not work. The Python env is always forced by reticulate to be the default reticulate env.

`python: /usr/bin/python3
libpython: /usr/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.so
pythonhome: //usr://usr
version: 3.8.10 (default, Sep 28 2021, 16:10:42) [GCC 9.3.0]
numpy: [NOT FOUND]

NOTE: Python version was forced by RETICULATE_PYTHON`

Possibly, a problem may also be this Global Option that does not switch off
image

It does not matter what RStudio Project is, I tested with many different new projects and the error always appears.
This maybe is something to investigate on.
Thank you for your time.