Skip to content

Commit

Permalink
Console messages when a target is pending
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau-lilly committed Dec 4, 2023
1 parent 384c6b0 commit b7f2788
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 35 deletions.
14 changes: 12 additions & 2 deletions R/class_builder.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,20 @@ target_read_value.tar_builder <- function(target, pipeline = NULL) {
}

#' @export
target_prepare.tar_builder <- function(target, pipeline, scheduler, meta) {
target_prepare.tar_builder <- function(
target,
pipeline,
scheduler,
meta,
pending = FALSE
) {
target_patternview_dispatched(target, pipeline, scheduler)
scheduler$progress$register_dispatched(target)
scheduler$reporter$report_dispatched(target, scheduler$progress)
scheduler$reporter$report_dispatched(
target = target,
progress = scheduler$progress,
pending = pending
)
builder_ensure_deps(target, pipeline, "main")
builder_update_subpipeline(target, pipeline)
builder_marshal_subpipeline(target)
Expand Down
42 changes: 19 additions & 23 deletions R/class_crew.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,29 +157,25 @@ crew_class <- R6::R6Class(
globals <- self$exports$globals
resources <- target$settings$resources$crew
name <- target_get_name(target)
saturated <- self$controller$saturated(controller = resources$controller)
if (saturated) {
# Requires a slow test. Covered in the saturation tests in
# tests/hpc/test-crew_local.R # nolint
# nocov start
self$scheduler$queue$append0(name = name)
self$backoff_requeue$wait()
# nocov end
} else {
target_prepare(target, self$pipeline, self$scheduler, self$meta)
self$sync_meta_time()
self$controller$push(
command = command,
data = data,
globals = globals,
substitute = FALSE,
name = name,
controller = resources$controller,
scale = TRUE,
seconds_timeout = resources$seconds_timeout
)
self$backoff_requeue$reset()
}
target_prepare(
target = target,
pipeline = self$pipeline,

Check warning on line 162 in R/class_crew.R

View workflow job for this annotation

GitHub Actions / lint

file=R/class_crew.R,line=162,col=34,[trailing_whitespace_linter] Trailing whitespace is superfluous.
scheduler = self$scheduler,
meta = self$meta,
pending = self$controller$saturated(controller = resources$controller)
)
self$sync_meta_time()
self$controller$push(
command = command,
data = data,
globals = globals,
substitute = FALSE,
name = name,
controller = resources$controller,
scale = TRUE,
seconds_timeout = resources$seconds_timeout
)
self$backoff_requeue$reset()
},
run_main = function(target) {
target_prepare(target, self$pipeline, self$scheduler, self$meta)
Expand Down
6 changes: 5 additions & 1 deletion R/class_reporter.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ reporter_class <- R6::R6Class(
cli_warned(progress$warned$count)
}
},
report_dispatched = function(target = NULL, progress = NULL) {
report_dispatched = function(
target = NULL,
progress = NULL,
pending = FALSE
) {
},
report_completed = function(target = NULL, progress = NULL) {
},
Expand Down
2 changes: 1 addition & 1 deletion R/class_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ summary_class <- R6::R6Class(
},
report_error = function(error) {
},
report_dispatched = function(target = NULL, progress) {
report_dispatched = function(target = NULL, progress, pending = FALSE) {
self$report_progress(progress)
},
report_completed = function(target = NULL, progress) {
Expand Down
16 changes: 14 additions & 2 deletions R/class_target.R
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,24 @@ target_skip <- function(target, pipeline, scheduler, meta, active) {
UseMethod("target_skip")
}

target_prepare <- function(target, pipeline, scheduler, meta) {
target_prepare <- function(
target,
pipeline,
scheduler,
meta,
pending = FALSE
) {
UseMethod("target_prepare")
}

#' @export
target_prepare.default <- function(target, pipeline, scheduler, meta) {
target_prepare.default <- function(
target,
pipeline,
scheduler,
meta,
pending = FALSE
) {
}

target_should_run <- function(target, meta) {
Expand Down
5 changes: 3 additions & 2 deletions R/class_timestamp.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ timestamp_class <- R6::R6Class(
self$buffer[length(self$buffer) + 1L] <- msg
self$poll()
},
report_dispatched = function(target, progress = NULL) {
report_dispatched = function(target, progress = NULL, pending = FALSE) {
self$buffer_message(
cli_dispatched(
target_get_name(target),
target_get_type_cli(target),
time_stamp = TRUE,
print = FALSE
print = FALSE,
pending = pending
)
)
},
Expand Down
5 changes: 3 additions & 2 deletions R/class_verbose.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ verbose_class <- R6::R6Class(
self$buffer[length(self$buffer) + 1L] <- msg
self$poll()
},
report_dispatched = function(target, progress = NULL) {
report_dispatched = function(target, progress = NULL, pending = FALSE) {
self$buffer_message(
cli_dispatched(
target_get_name(target),
target_get_type_cli(target),
print = FALSE
print = FALSE,
pending = pending
)
)
},
Expand Down
6 changes: 4 additions & 2 deletions R/utils_cli.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ cli_dispatched <- function(
name,
prefix = NULL,
time_stamp = FALSE,
print = TRUE
print = TRUE,
pending = FALSE
) {
time <- if_any(time_stamp, time_stamp(), NULL)
msg <- paste(c(time, "dispatched", prefix, name), collapse = " ")
action <- if_any(pending, "dispatched (pending)", "dispatched")
msg <- paste(c(time, action, prefix, name), collapse = " ")
cli_blue_play(msg, print = print)
}

Expand Down

0 comments on commit b7f2788

Please sign in to comment.