tidyverts / fabletools

General fable features useful for extension packages
http://fabletools.tidyverts.org/
89 stars 31 forks source link

Parallelization using future does not work with dynamic formula in model #193

Closed KaroRonty closed 4 years ago

KaroRonty commented 4 years ago

I have a model with lots of predictors so it would make sense to define the formula outside the model function, but it's not working using parallelization. The error message is "object 'f' not found".

# Preparing the data
library(fable)
library(tsibble)
library(dplyr)

train <- airquality %>% mutate(
    date = as.Date(paste('2018', Month, Day, sep = '-')), 
    Ozone = round(imputeTS::na.interpolation(Ozone, option = 'stine')),
    Solar.R = round(imputeTS::na.interpolation(Solar.R, option = 'stine'))
) %>% 
    as_tsibble()

# Defining the formula
f <- as.formula('Ozone ~ Wind + Temp + Solar.R')

# Works
fsModel <- train %>% 
    model(ARIMA(Ozone ~ Wind + Temp + Solar.R))

# Works
fsModel <- train %>% 
    model(ARIMA(formula = f))

library(future)

plan(multiprocess)

# Works
fsModel <- train %>% 
    model(ARIMA(Ozone ~ Wind + Temp + Solar.R))

# Does not work
fsModel <- train %>% 
    model(ARIMA(formula = f))
mitchelloharawild commented 4 years ago

Thanks for the bug report. I'll be fixing up reconciliation next month. This is a known issue covered by #146

KaroRonty commented 4 years ago

Great! Sorry for opening a duplicate issue, seems like googling the packages in question doesn't bring all the results from github issues

mitchelloharawild commented 4 years ago

No worries, hopefully others will find this issue then :smile: