Skip to content

Commit

Permalink
Fix #161
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau-lilly committed Sep 18, 2020
1 parent 28285f1 commit 8de614e
Show file tree
Hide file tree
Showing 20 changed files with 38 additions and 125 deletions.
10 changes: 1 addition & 9 deletions R/class_clustermq.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ clustermq_init <- function(
reporter = "verbose",
garbage_collection = FALSE,
workers = 1L,
template = list(),
log_worker = FALSE
) {
clustermq_new(
Expand All @@ -17,7 +16,6 @@ clustermq_init <- function(
reporter = reporter,
garbage_collection = garbage_collection,
workers = as.integer(workers),
template = as.list(template),
log_worker = log_worker
)
}
Expand All @@ -31,7 +29,6 @@ clustermq_new <- function(
garbage_collection = NULL,
workers = NULL,
crew = NULL,
template = NULL,
log_worker = NULL
) {
clustermq_class$new(
Expand All @@ -43,7 +40,6 @@ clustermq_new <- function(
garbage_collection = garbage_collection,
workers = workers,
crew = crew,
template = template,
log_worker = log_worker
)
}
Expand All @@ -57,7 +53,6 @@ clustermq_class <- R6::R6Class(
public = list(
workers = NULL,
crew = NULL,
template = NULL,
log_worker = NULL,
initialize = function(
pipeline = NULL,
Expand All @@ -68,7 +63,6 @@ clustermq_class <- R6::R6Class(
garbage_collection = NULL,
workers = NULL,
crew = NULL,
template = NULL,
log_worker = NULL
) {
super$initialize(
Expand All @@ -81,7 +75,6 @@ clustermq_class <- R6::R6Class(
)
self$workers <- workers
self$crew <- crew
self$template <- template
self$log_worker <- log_worker
},
set_common_data = function(envir) {
Expand All @@ -98,7 +91,7 @@ clustermq_class <- R6::R6Class(
create_crew = function() {
crew <- clustermq::workers(
n_jobs = self$workers,
template = self$template,
template = tar_option_get("resources"),
log_worker = self$log_worker
)
self$crew <- crew
Expand Down Expand Up @@ -228,7 +221,6 @@ clustermq_class <- R6::R6Class(
super$validate()
assert_lgl(self$garbage_collection)
assert_int(self$workers)
assert_list(self$template)
}
)
)
4 changes: 1 addition & 3 deletions R/class_cross.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ print.tar_cross <- function(x, ...) {
"\n storage mode:", x$settings$storage,
"\n retrieval mode:", x$settings$retrieval,
"\n deploy to:", x$settings$deployment,
"\n template (clustermq):\n ",
produce_lines(paste_list(x$settings$template)),
"\n resources (future):\n ",
"\n resources:\n ",
produce_lines(paste_list(x$settings$resources)),
"\n cue:\n ",
produce_lines(paste_list(as.list(x$cue))),
Expand Down
4 changes: 1 addition & 3 deletions R/class_map.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ print.tar_map <- function(x, ...) {
"\n storage mode:", x$settings$storage,
"\n retrieval mode:", x$settings$retrieval,
"\n deploy to:", x$settings$deployment,
"\n template (clustermq):\n ",
produce_lines(paste_list(x$settings$template)),
"\n resources (future):\n ",
"\n resources:\n ",
produce_lines(paste_list(x$settings$resources)),
"\n cue:\n ",
produce_lines(paste_list(as.list(x$cue))),
Expand Down
5 changes: 0 additions & 5 deletions R/class_settings.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ settings_init <- function(
deployment = "remote",
priority = 0,
resources = list(),
template = NULL,
storage = "local",
retrieval = storage
) {
Expand All @@ -25,7 +24,6 @@ settings_init <- function(
deployment = deployment,
priority = priority,
resources = resources,
template = template,
storage = storage,
retrieval = retrieval
)
Expand All @@ -42,7 +40,6 @@ settings_new <- function(
deployment = NULL,
priority = NULL,
resources = NULL,
template = NULL,
storage = NULL,
retrieval = NULL
) {
Expand All @@ -56,7 +53,6 @@ settings_new <- function(
force(deployment)
force(priority)
force(resources)
force(template)
force(storage)
force(retrieval)
environment()
Expand All @@ -78,7 +74,6 @@ settings_clone <- function(settings) {
deployment = settings$deployment,
priority = settings$priority,
resources = settings$resources,
template = settings$template,
storage = settings$storage,
retrieval = settings$retrieval
)
Expand Down
4 changes: 1 addition & 3 deletions R/class_stem.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,7 @@ print.tar_stem <- function(x, ...) {
"\n storage mode:", x$settings$storage,
"\n retrieval mode:", x$settings$retrieval,
"\n deploy to:", x$settings$deployment,
"\n template (clustermq):\n ",
produce_lines(paste_list(x$settings$template)),
"\n resources (future):\n ",
"\n resources:\n ",
produce_lines(paste_list(x$settings$resources)),
"\n cue:\n ",
produce_lines(paste_list(as.list(x$cue))),
Expand Down
2 changes: 0 additions & 2 deletions R/class_target.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ target_init <- function(
memory = "persistent",
deployment = "remote",
priority = 0,
template = NULL,
resources = list(),
storage = "local",
retrieval = storage,
Expand All @@ -34,7 +33,6 @@ target_init <- function(
memory = memory,
deployment = deployment,
priority = priority,
template = template,
resources = resources,
storage = storage,
retrieval = retrieval
Expand Down
8 changes: 2 additions & 6 deletions R/tar_make_clustermq.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
#' To read more about configuring `clustermq` for your scheduler, visit
#' <https://mschubert.github.io/clustermq/articles/userguide.html#configuration> # nolint
#' and navigate to the appropriate link under "Setting up the scheduler".
#' Wildcards in the template file are filled in with elements from
#' `tar_option_get("resources")`.
#' @return `NULL` except if `callr_function = callr::r_bg()`, in which case
#' a handle to the `callr` background process is returned. Either way,
#' the value is invisibly returned.
#' @inheritParams tar_make_future
#' @param template Named list of values to insert as fields
#' in the `clustermq` template file, such as computing resource requirements.
#' @param log_worker Logical, whether to write a log file for each worker.
#' Same as the `log_worker` argument of `clustermq::Q()`
#' and `clustermq::workers()`.
Expand All @@ -37,7 +37,6 @@ tar_make_clustermq <- function(
reporter = "verbose",
garbage_collection = FALSE,
workers = 1L,
template = list(),
log_worker = FALSE,
callr_function = callr::r,
callr_arguments = list()
Expand All @@ -52,7 +51,6 @@ tar_make_clustermq <- function(
reporter = reporter,
garbage_collection = garbage_collection,
workers = workers,
template = template,
log_worker = log_worker
)
out <- callr_outer(
Expand All @@ -70,7 +68,6 @@ tar_make_clustermq_inner <- function(
reporter,
garbage_collection,
workers,
template,
log_worker
) {
pipeline_validate_lite(pipeline)
Expand All @@ -82,7 +79,6 @@ tar_make_clustermq_inner <- function(
reporter = reporter,
garbage_collection = garbage_collection,
workers = workers,
template = template,
log_worker = log_worker
)$run()
invisible()
Expand Down
1 change: 0 additions & 1 deletion R/tar_option_get.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ tar_option_default <- function(option) {
deployment = "remote",
priority = 0,
resources = list(),
template = NULL,
storage = "local",
retrieval = "local",
cue = targets::tar_cue(),
Expand Down
8 changes: 0 additions & 8 deletions R/tar_option_set.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ tar_option_set <- function(
deployment = NULL,
priority = NULL,
resources = NULL,
template = NULL,
storage = NULL,
retrieval = NULL,
cue = NULL,
Expand All @@ -57,7 +56,6 @@ tar_option_set <- function(
tar_option_set_deployment(deployment)
tar_option_set_priority(priority)
tar_option_set_resources(resources)
tar_option_set_template(template)
tar_option_set_storage(storage)
tar_option_set_retrieval(retrieval)
tar_option_set_cue(cue)
Expand Down Expand Up @@ -138,12 +136,6 @@ tar_option_set_resources <- function(resources) {
assign("resources", resources, envir = tar_envir_options)
}

tar_option_set_template <- function(template) {
template <- template %||% tar_option_get("template")
warn_template(template)
assign("template", template, envir = tar_envir_options)
}

tar_option_set_storage <- function(storage) {
storage <- storage %||% tar_option_get("storage")
storage <- match.arg(storage, c("local", "remote"))
Expand Down
18 changes: 6 additions & 12 deletions R/tar_target.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,12 @@
#' @param priority Numeric of length 1 between 0 and 1. Controls which
#' targets get deployed first when multiple competing targets are ready
#' simultaneously. Targets with priorities closer to 1 get built earlier.
#' @param template Relevant to [tar_make_clustermq()] only.
#' Named list of values to fill in the `clustermq` template file.
#' Unsupported for now. May be supported in the future if
#' `clustermq` ever supports heterogeneous workers with varying
#' resource requirements. In the meantime, use the `template`
#' argument of [tar_make_clustermq()].
#' @param resources Relevant to [tar_make_future()] only.
#' A named list of resources passed to `future::future()` when
#' defining a new worker.
#' @param resources A named list of computing resources
#' for high-performance computing. Elements in this list are passed
#' to `future::future()` in [tar_make_future()] and
#' to `clustermq::workers()` in [tar_make_clustermq()]
#' to fill in the patterns in cluster computing
#' template files with user-defined values.
#' @param storage Character of length 1, only relevant to
#' [tar_make_clustermq()] and [tar_make_future()].
#' If `"local"`, the target's return value is sent back to the
Expand Down Expand Up @@ -137,7 +134,6 @@ tar_target <- function(
memory = targets::tar_option_get("memory"),
deployment = targets::tar_option_get("deployment"),
priority = targets::tar_option_get("priority"),
template = targets::tar_option_get("template"),
resources = targets::tar_option_get("resources"),
storage = targets::tar_option_get("storage"),
retrieval = targets::tar_option_get("retrieval"),
Expand All @@ -160,7 +156,6 @@ tar_target <- function(
assert_scalar(priority)
assert_ge(priority, 0)
assert_le(priority, 1)
warn_template(template)
assert_list(resources, "resources in tar_target() must be a named list.")
storage <- match.arg(storage, c("local", "remote"))
retrieval <- match.arg(retrieval, c("local", "remote"))
Expand All @@ -183,7 +178,6 @@ tar_target <- function(
memory = memory,
deployment = deployment,
priority = priority,
template = template,
resources = resources,
storage = storage,
retrieval = retrieval,
Expand Down
3 changes: 0 additions & 3 deletions R/tar_target_raw.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ tar_target_raw <- function(
memory = targets::tar_option_get("memory"),
deployment = targets::tar_option_get("deployment"),
priority = targets::tar_option_get("priority"),
template = targets::tar_option_get("template"),
resources = targets::tar_option_get("resources"),
storage = targets::tar_option_get("storage"),
retrieval = targets::tar_option_get("retrieval"),
Expand All @@ -76,7 +75,6 @@ tar_target_raw <- function(
assert_scalar(priority)
assert_ge(priority, 0)
assert_le(priority, 1)
warn_template(template)
assert_list(
resources,
"resources in tar_target_raw() must be a named list."
Expand All @@ -99,7 +97,6 @@ tar_target_raw <- function(
memory = memory,
deployment = deployment,
priority = priority,
template = template,
resources = resources,
storage = storage,
retrieval = retrieval,
Expand Down
12 changes: 0 additions & 12 deletions R/utils_assert.R
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,3 @@ warn_output <- function(name, path) {
)
}
}

warn_template <- function(template) {
if (!is.null(template)) {
warn_validate(
"Functions tar_option_set(), tar_target(), and tar_target_raw() ",
"currently ignore the template argument. It will only be supported if ",
"clustermq ever supports heterogeneous workers with varying resource ",
"configurations. In the meantime, use the template argument of ",
"tar_make_clustermq()."
)
}
}
6 changes: 2 additions & 4 deletions man/tar_make_clustermq.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 6 additions & 11 deletions man/tar_option_set.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8de614e

Please sign in to comment.