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

Paginate logs from the monitor #5

Closed
wlandau opened this issue Dec 12, 2023 · 0 comments
Closed

Paginate logs from the monitor #5

wlandau opened this issue Dec 12, 2023 · 0 comments

Comments

@wlandau
Copy link
Owner

wlandau commented Dec 12, 2023

Because of paws-r/paws#721, the log() method of the monitor currently does not use pagination. When that issue is fixed, I will replace this:

pages <- list( # TODO: paws.common::paginate() # nolint
client$get_log_events(
logGroupName = private$.log_group,
logStreamName = log_stream_name,
startFromHead = start_from_head
)
)

with this:

pages <- paws.common::paginate(
  client$get_log_events(
    logGroupName = private$.log_group,
    logStreamName = log_stream_name,
    startFromHead = start_from_head
  )
)

and test it with this:

test_that("job logs", {
x <- crew_aws_batch_monitor(
job_definition = "crew-aws-batch-test",
job_queue = "crew-aws-batch-job-queue",
region = "us-east-2"
)
x$register(
image = "alpine:latest",
platform_capabilities = "EC2",
memory_units = "gigabytes",
memory = 1,
cpus = 1,
seconds_timeout = 600,
tags = c("crew_aws_batch_1", "crew_aws_batch_2"),
propagate_tags = TRUE
)
on.exit(x$deregister())
job <- x$submit(
command = c("echo", "done with container\ndone with job"),
memory_units = "mebibytes",
memory = 128,
cpus = 1
)
attempts <- 0L
done <- c("succeeded", "failed")
while (!((status <- x$status(id = job$id)$status) %in% done)) {
message(
paste(
"job status:",
status,
sample(c("-", "\\", "|", "/"), size = 1L)
)
)
attempts <- attempts + 1L
if (attempts > 60L) {
stop("job did not finish")
}
Sys.sleep(5)
}
log <- x$log(id = job$id)
expect_true(tibble::is_tibble(log))
expect_equal(log$message, c("done with container", "done with job"))
})

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

1 participant