Skip to content

Commit

Permalink
time stamps
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Jan 30, 2025
1 parent 76558ca commit 4377268
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# crew.aws.batch 0.0.8

* Deprecate retryable options because `crew` 1.0.0 no longer supports them.
* In the monitor, return `POSIXct` time stamps for `created`, `started`, and `stopped`.

# crew.aws.batch 0.0.7

Expand Down
24 changes: 12 additions & 12 deletions R/crew_monitor_aws_batch.R
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ crew_class_monitor_aws_batch <- R6::R6Class(
arn = character(0L),
status = character(0L),
reason = character(0L),
created = numeric(0L),
started = numeric(0L),
stopped = numeric(0L)
created = as.POSIXct(numeric(0L)),
started = as.POSIXct(numeric(0L)),
stopped = as.POSIXct(numeric(0L))
)
)
}
Expand All @@ -277,9 +277,9 @@ crew_class_monitor_aws_batch <- R6::R6Class(
out$statusReason,
NA_character_
),
created = out$createdAt,
started = if_any(length(out$startedAt), out$startedAt, NA_real_),
stopped = if_any(length(out$stoppedAt), out$stoppedAt, NA_real_)
created = as_timestamp(out$createdAt),
started = as_timestamp(out$startedAt),
stopped = as_timestamp(out$stoppedAt)
)
# nocov end
},
Expand Down Expand Up @@ -420,9 +420,9 @@ crew_class_monitor_aws_batch <- R6::R6Class(
job$statusReason,
NA_character_
),
created = job$createdAt,
started = if_any(length(job$startedAt), job$startedAt, NA_real_),
stopped = if_any(length(job$stoppedAt), job$stoppedAt, NA_real_)
created = as_timestamp(job$createdAt),
started = as_timestamp(job$startedAt),
stopped = as_timestamp(job$stoppedAt)
)
}
}
Expand All @@ -433,9 +433,9 @@ crew_class_monitor_aws_batch <- R6::R6Class(
arn = character(0L),
status = character(0L),
reason = character(0L),
created = numeric(0L),
started = numeric(0L),
stopped = numeric(0L)
created = as.POSIXct(numeric(0L)),
started = as.POSIXct(numeric(0L)),
stopped = as.POSIXct(numeric(0L))
)
}
out <- do.call(what = vctrs::vec_rbind, args = out)
Expand Down
3 changes: 3 additions & 0 deletions R/utils_time.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
as_timestamp <- function(x) {
as.POSIXct(if_any(length(x) > 0L, x / 1000, NA_real_))
}
4 changes: 4 additions & 0 deletions tests/testthat/test-utils_time.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
test_that("as_timestamp()", {
expect_true(anyNA(as_timestamp(numeric(0L))))
expect_s3_class(as_timestamp(1000), "POSIXct")
})

0 comments on commit 4377268

Please sign in to comment.