Skip to content

Commit

Permalink
time zones are hard.
Browse files Browse the repository at this point in the history
  • Loading branch information
vortexing committed May 8, 2020
1 parent e3d322c commit d8b55c5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: fh.wdlR
Title: Convenience Tools for Managing WDL Workflows via Cromwell
Version: 0.1.0
Version: 0.1.1
Authors@R:
person(given = "Amy",
family = "Paguirigan",
Expand All @@ -16,7 +16,8 @@ Imports:
purrr,
paws,
tidyr,
ssh
ssh,
lubridate
License: GPL-3
Depends: R (>= 3.6.0)
Roxygen: list(markdown = TRUE)
Expand Down
8 changes: 3 additions & 5 deletions R/cromwellCall.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,16 @@ cromwellCall <- function(workflow_id) {
## Big Chunk of dealing with start and end times.
if ("start" %in% colnames(justCalls) == T) {
# if the workflow has started
justCalls$start <-
as.POSIXct(justCalls$start, tz = "UTC", "%Y-%m-%dT%H:%M:%S") - 8*60*60 # because PST/hack
justCalls$start <- lubridate::with_tz(lubridate::ymd_hms(justCalls$start), tzone = "US/Pacific")
if ("end" %in% colnames(justCalls) == T) {
# and if end is present
justCalls$end <-
as.POSIXct(justCalls$end, tz = "UTC", "%Y-%m-%dT%H:%M:%S") - 8*60*60 # because PST/hack
justCalls$end <-lubridate::with_tz(lubridate::ymd_hms(justCalls$end), tzone = "US/Pacific")
justCalls <-
dplyr::mutate(justCalls, callDuration = round(difftime(end, start, units = "mins"), 3))
} else {
# if end doesn't exist or it is already NA (???), make it and workflowDuration but set to NA
justCalls$end <- NA
justCalls$callDuration <- 0
justCalls$callDuration <- round(difftime(lubridate::now(tz = "US/Pacific"), justCalls$start, units = "mins"),3)
}
} else {
# if start doesn't exist, then create it and set it to NA
Expand Down
15 changes: 8 additions & 7 deletions R/cromwellJobs.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,20 @@ cromwellJobs <- function(days = 1) {
cromTable <- dplyr::rename(cromTable, "workflow_id" = "id")
if ("end" %in% colnames(cromTable) == T &
"start" %in% colnames(cromTable) == T) {
cromTable$start <-
as.POSIXct(cromTable$start, "UTC", "%Y-%m-%dT%H:%M:%S") - 8*60*60 # because PST/hack
cromTable$end <-
as.POSIXct(cromTable$end, "UTC", "%Y-%m-%dT%H:%M:%S") - 8*60*60 # because PST/hack
cromTable$submission <-
as.character(as.POSIXct(cromTable$submission, "UTC", "%Y-%m-%dT%H:%M:%S") - 8*60*60 )# because PST/hack)
cromTable$start <-lubridate::with_tz(lubridate::ymd_hms(cromTable$start), tzone = "US/Pacific")
cromTable$end <-lubridate::with_tz(lubridate::ymd_hms(cromTable$end), tzone = "US/Pacific")
cromTable$submission <-lubridate::with_tz(lubridate::ymd_hms(cromTable$submission), tzone = "US/Pacific")
cromTable$workflowDuration <-
round(difftime(cromTable$end, cromTable$start, units = "mins"),
3)
cromTable$workflowDuration <-
as.numeric(cromTable$workflowDuration)
} else if ("start" %in% colnames(cromTable) == T) {
cromTable$start <-lubridate::with_tz(lubridate::ymd_hms(cromTable$start), tzone = "US/Pacific")
# If it hasn't ended yet, then report the amount of time it's been running to that moment.
cromTable$workflowDuration <- round(difftime(Sys.time(), resultdf$start, units = "mins"),3)
} else {
cromTable$workflowDuration <- "NA"
cromTable$workflowDuration <- 0
}
} else {
cromTable <- data.frame("workflow_id" = NA,
Expand Down
14 changes: 7 additions & 7 deletions R/cromwellWorkflow.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,12 @@ cromwellWorkflow <- function(workflow_id) {
purrr::reduce(list(remainder, drag, submit), dplyr::full_join, by = "workflow_id")
}
#resultdf <- dplyr::mutate_all(resultdf, as.character)
resultdf$submission <-
as.character(as.POSIXct(resultdf$submission, tz= "UTC", "%Y-%m-%dT%H:%M:%S") - 8*60*60 )# because PST/hack)
resultdf$submission <- lubridate::with_tz(lubridate::ymd_hms(resultdf$submission), tzone = "US/Pacific")
if ("start" %in% colnames(resultdf) == T) {
# if the workflow has started
if (is.na(resultdf$start) == F) {
# and if the value of start is not NA
resultdf$start <-
as.POSIXct(resultdf$start, tz= "UTC", "%Y-%m-%dT%H:%M:%S") - 8*60*60 # because PST/hack
resultdf$start <- lubridate::with_tz(lubridate::ymd_hms(resultdf$start), tzone = "US/Pacific")
} else {
# if start is NA, then make sure it's set to NA???? Stupid.
resultdf$start <- NA
Expand All @@ -102,15 +100,17 @@ cromwellWorkflow <- function(workflow_id) {
# and if end is present
if (is.na(resultdf$end) == F) {
# and it is not NA
resultdf$end <-
as.POSIXct(resultdf$end, tz= "UTC", "%Y-%m-%dT%H:%M:%S") - 8*60*60 # because PST/hack
resultdf$end <-lubridate::with_tz(lubridate::ymd_hms(resultdf$end), tzone = "US/Pacific")
resultdf <-
dplyr::mutate(resultdf, workflowDuration = round(difftime(end, start, units = "mins"), 3))
}
} else {
# if end doesn't exist or it is already NA (???), make it and workflowDuration but set to NA
resultdf$end <- NA
if (is.na(resultdf$start)==F){resultdf$workflowDuration <- as.POSIXct(Sys.time())- resultdf$start} else {
if (is.na(resultdf$start)==F){
resultdf$workflowDuration <-
round(difftime(Sys.time(), resultdf$start, units = "mins"),3)
} else {
resultdf$workflowDuration <- 0}
}
} else {
Expand Down

0 comments on commit d8b55c5

Please sign in to comment.