Skip to content

Commit

Permalink
retry message
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Nov 13, 2024
1 parent 9611a67 commit 0aa3e30
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 3 deletions.
10 changes: 10 additions & 0 deletions R/crew_launcher_aws_batch.R
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,16 @@ crew_class_launcher_aws_batch <- R6::R6Class(
)
},
.args_submit = function(call, name, attempt) {
if (private$.options_aws_batch$verbose) {
crew_message(
"Launching worker ",
name,
" attempt ",
attempt,
" of ",
private$.crashes_error
)
}
options <- crew_options_slice(private$.options_aws_batch, attempt)
container_overrides <- as.list(options$container_overrides)
container_overrides$command <- list("Rscript", "-e", call)
Expand Down
13 changes: 11 additions & 2 deletions R/crew_options_aws_batch.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@
#' For more details, visit
#' <https://www.paws-r-sdk.com/docs/batch_submit_job/> and the
#' "AWS arguments" sections of this help file.
#' @param verbose `TRUE` to print informative console messages, `FALSE`
#' otherwise.
crew_options_aws_batch <- function(
job_definition = "example",
job_queue = "example",
Expand All @@ -128,7 +130,8 @@ crew_options_aws_batch <- function(
propagate_tags = NULL,
timeout = NULL,
tags = NULL,
eks_properties_override = NULL
eks_properties_override = NULL,
verbose = FALSE
) {
crew::crew_assert(
job_definition,
Expand Down Expand Up @@ -179,6 +182,11 @@ crew_options_aws_batch <- function(
. >= 0,
message = "memory must be NULL or a numeric vector"
)
crew::crew_assert(
verbose,
isTRUE(.) || isFALSE(.),
message = "verbose must be TRUE or FALSE"
)
container_overrides <- container_overrides %|||% make_container_overrides(
cpus = cpus,
gpus = gpus,
Expand All @@ -202,7 +210,8 @@ crew_options_aws_batch <- function(
propagate_tags = propagate_tags,
timeout = timeout,
tags = tags,
eks_properties_override = eks_properties_override
eks_properties_override = eks_properties_override,
verbose = verbose
),
class = c("crew_options_aws_batch", "crew_options")
)
Expand Down
11 changes: 11 additions & 0 deletions R/utils_assert.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
crew_message <- function(..., frequency = "always", id = NULL) {
old <- getOption("rlang_backtrace_on_error")
on.exit(options(rlang_backtrace_on_error = old))
options(rlang_backtrace_on_error = "none")
rlang::inform(
message = paste0(...),
class = c("crew_message", "crew"),
.frequency = frequency,
.frequency_id = id
)
}
6 changes: 5 additions & 1 deletion man/crew_options_aws_batch.Rd

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

18 changes: 18 additions & 0 deletions tests/testthat/test-crew_launcher_aws_batch.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ test_that("AWS batch launcher", {
)
})

test_that("AWS batch launcher retry launch message", {
options <- crew_options_aws_batch(
job_definition = "crew-definition",
job_queue = "crew-queue",
cpus = 2.5,
gpus = 3,
memory = 1234,
memory_units = "mebibytes",
verbose = TRUE
)
x <- crew_launcher_aws_batch(options_aws_batch = options)
private <- crew_private(x)
expect_message(
private$.args_submit(call = "run", name = "x", attempt = 1L),
class = "crew_message"
)
})

test_that("crew_aws_batch_job_name() long string", {
long <- paste(c("_", rep("x", 200L)), collapse = "")
out <- crew_aws_batch_job_name(long)
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-utils_assert.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test_that("crew_message()", {
expect_message(crew_message("a", "b"), class = "crew_message")
})

0 comments on commit 0aa3e30

Please sign in to comment.