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

crew_controller_group cannot be saved to a variable and used inside _targets.R, but crew_controller_local can #172

Closed
stemangiola opened this issue Jun 26, 2024 · 1 comment
Assignees

Comments

@stemangiola
Copy link

Prework

  • [ x] Read and agree to the Contributor Code of Conduct and contributing guidelines.
  • [ x] Confirm that your issue is a genuine bug in the crew package itself and not a user error, known limitation, or issue from another package that crew depends on. For example, if you get errors running tar_make_clustermq(), try isolating the problem in a reproducible example that runs clustermq and not crew. And for miscellaneous troubleshooting, please post to discussions instead of issues.
  • [ x] If there is already a relevant issue, whether open or closed, comment on the existing thread instead of posting a new issue.
  • [ x] Post a minimal reproducible example like this one so the maintainer can troubleshoot the problems you identify. A reproducible example is:
    • [ x] Runnable: post enough R code and data so any onlooker can create the error on their own computer.
    • [x ] Minimal: reduce runtime wherever possible and remove complicated details that are irrelevant to the issue at hand.
    • [x ] Readable: format your code according to the tidyverse style guide.

Description

crew_controller_group cannot be saved to a variable and used inside _targets.R, but crew_controller_local can

Please describe the bug.

Reproducible example

This works

library(targets)
library(tarchetypes)
library(crew)
library(crew.cluster)


tar_option_set(memory = "transient", garbage_collection = TRUE, 
               storage = "worker", retrieval = "worker", format = "qs", 
               debug = readRDS("temp_debug_step.rds"), controller = crew_controller_group(
                 
                 crew_controller_local(
                   name = "tier_1",
                   workers = 2,
                   seconds_idle = 10
                 ),
                 crew_controller_local(
                   name = "tier_2",
                   workers = 2,
                   seconds_idle = 10
                 )
               ), 
               packages = c("HPCell"))
list(tar_target(a, 1, resources = tar_resources(crew = tar_resources_crew("tier_1"))))

If I try to save the controller into a variable first, it fails with core dumped

library(targets)
library(tarchetypes)
library(crew)
library(crew.cluster)

crew_controller_group(
  
  crew_controller_local(
    name = "tier_1",
    workers = 2,
    seconds_idle = 10
  ),
  crew_controller_local(
    name = "tier_2",
    workers = 2,
    seconds_idle = 10
  )
) |> saveRDS("~/temp.rds")


tar_option_set(memory = "transient", garbage_collection = TRUE, 
               storage = "worker", retrieval = "worker", format = "qs", 
               debug = readRDS("temp_debug_step.rds"), controller = readRDS("~/temp.rds"), 
               packages = c("HPCell"))
list(tar_target(a, 1, resources = tar_resources(crew = tar_resources_crew("tier_1"))))

But if I try to save a simpler controller, not a group, it works

library(targets)
library(tarchetypes)
library(crew)
library(crew.cluster)

  
  crew_controller_local(
    name = "tier_1",
    workers = 2,
    seconds_idle = 10
  ) |> saveRDS("~/temp.rds")


tar_option_set(memory = "transient", garbage_collection = TRUE, 
               storage = "worker", retrieval = "worker", format = "qs", 
               debug = readRDS("temp_debug_step.rds"), controller = readRDS("~/temp.rds"), 
               packages = c("HPCell"))
list(tar_target(a, 1, resources = tar_resources(crew = tar_resources_crew("tier_1"))))

I would like the second case to work.

Thanks a lot.

@wlandau
Copy link
Owner

wlandau commented Jun 26, 2024

Controllers are designed to operate only within the R session where they are originally created. They are not designed to be saved to disk. If you need to save something to disk to load later, I recommend instead saving the R code you used to generate the controller.

@wlandau wlandau closed this as not planned Won't fix, can't repro, duplicate, stale Jun 26, 2024
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

2 participants