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

Choose the caching method for each target? #988

Closed
2 tasks done
wlandau opened this issue Aug 18, 2019 · 0 comments
Closed
2 tasks done

Choose the caching method for each target? #988

wlandau opened this issue Aug 18, 2019 · 0 comments

Comments

@wlandau
Copy link
Member

wlandau commented Aug 18, 2019

Prework

Description

A Keras model can only be saved using the same R session that fit the model. So if you have a plan with target(keras_model, format = "keras") and you make() it with HPC, you must set caching = "worker". Worker caching is almost always slower than master caching, especially for a large number of targets, so maybe it would be nice to set different caching methods for different targets. As with other custom columns such as "trigger", a "caching" column would override the corresponding argument to make().

library(drake)
drake_plan(
    x = target(fit_model(1), caching = "master"),
    y = target(fit_model(1), caching = "worker")
)
#> # A tibble: 2 x 3
#>   target command      caching
#>   <chr>  <expr>       <chr>  
#> 1 x      fit_model(1) master 
#> 2 y      fit_model(1) worker

Created on 2019-08-18 by the reprex package (v0.3.0)

Hesitation

I am not sure about this feature because

  1. Worker caching is almost always slower, so it might be nice to find workarounds instead of developing it seriously as a feature.
  2. For Keras models specifically, the workaround is easy: instead of using target(format = "keras"), simply call serialize_model() before you return the fitted model. Then, the model will still be valid even if you send it to a different R process.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant