-
Notifications
You must be signed in to change notification settings - Fork 128
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
Specify resources within target #942
Labels
Comments
Actually, this is already possible. You can define any custom column with library(drake)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(purrr)
plan <- drake_plan(
data = target(
download_data(),
resources = list(cores = 1, gpus = 0)
),
model = target(
big_machine_learning_model(data),
resources = list(cores = 4, gpus = 1)
)
)
plan
#> # A tibble: 2 x 3
#> target command resources
#> <chr> <expr> <expr>
#> 1 data download_data() list(cores = 1, gpus = 0)
#> 2 model big_machine_learning_model(data) list(cores = 4, gpus = 1)
plan <- plan %>%
mutate(resources = map(resources, eval))
plan
#> # A tibble: 2 x 3
#> target command resources
#> <chr> <expr> <list>
#> 1 data download_data() <named list [2]>
#> 2 model big_machine_learning_model(data) <named list [2]>
plan$resources
#> [[1]]
#> [[1]]$cores
#> [1] 1
#>
#> [[1]]$gpus
#> [1] 0
#>
#>
#> [[2]]
#> [[2]]$cores
#> [1] 4
#>
#> [[2]]$gpus
#> [1] 1 Created on 2019-07-14 by the reprex package (v0.3.0) I should probably update the manual too. |
4 tasks
Thanks for bringing up this use case. #943 should make it easier to define custom resources. |
wlandau
pushed a commit
to ropensci-books/drake
that referenced
this issue
Jul 14, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prework
drake
's code of conduct.Description
I am following the drake manual section '9.7.5 The resources column for transient workers' to run my plan on a cluster specifying memory and run times, etc. for targets. The example in the manual shows adding a
resources
column to the drake plan as a list. However, this is unwieldy and error-prone in the case of a large plan. I would like to be able to specify resources (as a named list) as a custom column withtarget()
, with reasonable defaults instead of NA values (e.g., requesting only a small amount of memory).This is what the manual shows (note that
plan$resources
is a list-column):Here is an example of what I would like to be able to do:
In this case,
plan$resources
is again a list-column, butresources
for the target that I tried to specify resources for is alanguage
object, not a named list.I tried to get this to work anyways by filling the rest of the NAs in
plan$resources
with a loop:When I tried to run this with
future.batchtools
, I got the following error:Indeed, running
names()
onplan$resources
shows this:For now I'm probably just going to manually tweak the
resources
column after creating the entire plan, since there aren't that many targets that need special treatment. But I think being able to specify it on-the-fly withintarget()
would be nice.Created on 2019-07-14 by the reprex package (v0.2.1)
The text was updated successfully, but these errors were encountered: