Skip to content

Commit

Permalink
start working on #1311
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Sep 9, 2024
1 parent 0a6c23b commit 4ef51fa
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
1 change: 1 addition & 0 deletions R/class_builder.R
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ builder_handle_error <- function(target, pipeline, scheduler, meta) {
target$settings$error,
continue = builder_error_continue(target, scheduler),
abridge = scheduler$abridge(target),
trim = scheduler$trim(target),
stop = builder_error_exit(target, pipeline, scheduler, meta),
null = builder_error_null(target, pipeline, scheduler, meta),
workspace = builder_error_exit(target, pipeline, scheduler, meta)
Expand Down
2 changes: 1 addition & 1 deletion R/class_options.R
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ options_class <- R6::R6Class(
deprecate_error_workspace(error)
tar_assert_flag(
error,
c("stop", "continue", "abridge", "workspace", "null")
c("stop", "continue", "null", "abridge", "trim", "workspace")
)
},
validate_memory = function(memory) {
Expand Down
20 changes: 16 additions & 4 deletions R/class_scheduler.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ scheduler_init <- function(
)
reporter <- reporter_init(reporter, seconds_interval = seconds_reporter)
backoff <- tar_options$get_backoff()
canceled <- counter_init()
scheduler_new(
graph = graph,
queue = queue,
progress = progress,
reporter = reporter,
backoff = backoff
backoff = backoff,
canceled <- canceled
)
}

Expand All @@ -52,9 +54,10 @@ scheduler_new <- function(
queue = NULL,
progress = NULL,
reporter = NULL,
backoff = NULL
backoff = NULL,
canceled = NULL
) {
scheduler_class$new(graph, queue, progress, reporter, backoff)
scheduler_class$new(graph, queue, progress, reporter, backoff, canceled)
}

scheduler_class <- R6::R6Class(
Expand All @@ -68,18 +71,21 @@ scheduler_class <- R6::R6Class(
progress = NULL,
reporter = NULL,
backoff = NULL,
canceled = NULL,
initialize = function(
graph = NULL,
queue = NULL,
progress = NULL,
reporter = NULL,
backoff = NULL
backoff = NULL,
canceled = NULL
) {
self$graph <- graph
self$queue <- queue
self$progress <- progress
self$reporter <- reporter
self$backoff <- backoff
self$canceled <- canceled
},
count_unfinished_deps = function(name) {
deps <- self$graph$produce_upstream(name)
Expand All @@ -98,12 +104,18 @@ scheduler_class <- R6::R6Class(
self$progress$abridge()
self$queue$abridge()
},
trim = function(target) {

browser()

},
validate = function() {
self$graph$validate()
self$queue$validate()
self$progress$validate()
self$reporter$validate()
self$backoff$validate()
counter_validate(self$canceled)
}
)
)
10 changes: 7 additions & 3 deletions R/tar_target.R
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,17 @@
#' stops and throws an error. Options:
#' * `"stop"`: the whole pipeline stops and throws an error.
#' * `"continue"`: the whole pipeline keeps going.
#' * `"null"`: The errored target continues and returns `NULL`.
#' The data hash is deliberately wrong so the target is not
#' up to date for the next run of the pipeline.
#' * `"abridge"`: any currently running targets keep running,
#' but no new targets launch after that.
#' * `"trim"`: any currently running targets keep running,
#' and everything downstream of the error is canceled.
#' In addition, if the error happens in a dynamic branch,
#' then all not-yet-dispatched sibling branches are canceled.
#' (Visit <https://books.ropensci.org/targets/debugging.html>
#' to learn how to debug targets using saved workspaces.)
#' * `"null"`: The errored target continues and returns `NULL`.
#' The data hash is deliberately wrong so the target is not
#' up to date for the next run of the pipeline.
#' @param memory Character of length 1, memory strategy.
#' If `"persistent"`, the target stays in memory
#' until the end of the pipeline (unless `storage` is `"worker"`,
Expand Down
2 changes: 1 addition & 1 deletion R/tar_target_raw.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ tar_target_raw <- function(
tar_assert_flag(iteration, c("vector", "list", "group"))
tar_assert_flag(
error,
c("stop", "continue", "abridge", "workspace", "null")
c("stop", "continue", "null", "abridge", "trim", "workspace")
)
deprecate_error_workspace(error)
tar_assert_flag(memory, c("persistent", "transient"))
Expand Down

0 comments on commit 4ef51fa

Please sign in to comment.