Skip to content

Commit

Permalink
Update Time zone and Bionic
Browse files Browse the repository at this point in the history
  • Loading branch information
vortexing committed May 7, 2020
1 parent 29ef937 commit e3d322c
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion 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.0.3
Version: 0.1.0
Authors@R:
person(given = "Amy",
family = "Paguirigan",
Expand Down
14 changes: 9 additions & 5 deletions R/cromwellCreate.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' @param pathToParams Full path in our file system to where you have saved the parameters you'd like your Cromwell server to use (e.g. cromwellParams.sh, https://github.com/FredHutch/diy-cromwell-server).
#' @param pathToConfig Full path in our file system to where you have saved the configuration file you'd like your Cromwell server to use (e.g. fh-slurm-cromwell.conf, https://github.com/FredHutch/diy-cromwell-server).
#' @param local Are you running this on your local machine (TRUE) or on the rhino's (FALSE)
#' @param cluster Optional: if present, specify the cluster of the server, either 'gizmo' or other cluster name.
#' @param cluster Optional: default is trusty, and will submit to rhino nodes, while bionic will connect to rhino03 to submit to Bionic nodes.
#' @return Sets your environment variable CROMWELLURL to be that of the Cromwell server you just started and returns the information about the job ID and node you'll need.
#' @author Amy Paguirigan
#' @details
Expand All @@ -26,7 +26,8 @@ cromwellCreate <- function(FredHutchId = NULL, port = "2020",
pathToServerScript = NULL,
pathToParams = NULL,
pathToConfig = NULL,
cluster = "gizmo", local = TRUE) {
cluster = "trusty",
local = TRUE) {
if (is.null(FredHutchId) == T) {
stop("Please supply your Fred Hutch id.")
}
Expand All @@ -42,10 +43,13 @@ cromwellCreate <- function(FredHutchId = NULL, port = "2020",
if (is.null(pathToConfig) == T) {
stop("Please supply the full path to where the configuration file is saved (e.g., fh-slurm-cromwell.conf).")
}
if (cluster == "trusty") { rhino <- "@rhino"
} else if (cluster == "bionic") { rhino <- "@rhino03"
} else { stop("You specified 'cluster' as neither 'trusty' nor 'bionic', so I'm not sure which 'rhino' to submit your request to.")}

if (local == T){
# Make an ssh session to rhino and it will prompt for password
session <- ssh::ssh_connect(paste0(FredHutchId, "@rhino"))
session <- ssh::ssh_connect(paste0(FredHutchId, rhino))
# send the command to gizmo to start your server and save the response
setupServer <- ssh::ssh_exec_internal(session,
command = paste("sbatch", "-o",
Expand All @@ -62,7 +66,7 @@ cromwellCreate <- function(FredHutchId = NULL, port = "2020",
ssh::ssh_disconnect(session)
stop("Slurm Job ID is unset.")
}
nodecommand = paste0('squeue -M ', cluster, ' -o "%R" -j ', slurmJob)
nodecommand = paste0('squeue -o "%R" -j ', slurmJob)
Sys.sleep(2)
getNode <- ssh::ssh_exec_internal(session, command = nodecommand)
nodeName <- sub("^.*)", "", gsub("\n", "", rawToChar(getNode$stdout)))
Expand Down Expand Up @@ -94,7 +98,7 @@ cromwellCreate <- function(FredHutchId = NULL, port = "2020",
if(slurmJob == ""){
stop("Slurm Job ID is unset.")
}
nodecommand = paste0('squeue -M ', cluster, ' -o "%R" -j ', slurmJob)
nodecommand = paste0('squeue -o "%R" -j ', slurmJob)
Sys.sleep(2)
getNode <- system(command = nodecommand, intern = TRUE)
nodeName <- getNode[3]
Expand Down
6 changes: 3 additions & 3 deletions R/cromwellWorkflow.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ cromwellWorkflow <- function(workflow_id) {
}
#resultdf <- dplyr::mutate_all(resultdf, as.character)
resultdf$submission <-
as.character(as.POSIXct(resultdf$submission, tz= "America/Los_Angeles", "%Y-%m-%dT%H:%M:%S") - 7*60*60 )# because PST/hack)
as.character(as.POSIXct(resultdf$submission, tz= "UTC", "%Y-%m-%dT%H:%M:%S") - 8*60*60 )# because PST/hack)
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= "America/Los_Angeles", "%Y-%m-%dT%H:%M:%S") - 7*60*60 # because PST/hack
as.POSIXct(resultdf$start, tz= "UTC", "%Y-%m-%dT%H:%M:%S") - 8*60*60 # because PST/hack
} else {
# if start is NA, then make sure it's set to NA???? Stupid.
resultdf$start <- NA
Expand All @@ -103,7 +103,7 @@ cromwellWorkflow <- function(workflow_id) {
if (is.na(resultdf$end) == F) {
# and it is not NA
resultdf$end <-
as.POSIXct(resultdf$end, tz= "America/Los_Angeles", "%Y-%m-%dT%H:%M:%S") - 7*60*60 # because PST/hack
as.POSIXct(resultdf$end, tz= "UTC", "%Y-%m-%dT%H:%M:%S") - 8*60*60 # because PST/hack
resultdf <-
dplyr::mutate(resultdf, workflowDuration = round(difftime(end, start, units = "mins"), 3))
}
Expand Down
18 changes: 10 additions & 8 deletions R/setCromwellURL.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,29 @@
#' @param jobId The SLURM job id for your Cromwell server
#' @param port The port you specified in your Cromwell config file (`fh-slurm-cromwell.config`), default is "2020" from the template here: https://github.com/FredHutch/diy-cromwell-server.
#' @param local Are you running this on your local machine (TRUE) or on the rhino's (FALSE)
#' @param cluster Optional: if present, specify the location of the server, either 'gizmo' or 'beagle'
#' @param cluster Optional: default is trusty, and will submit to rhino nodes, while bionic will connect to rhino03 to submit to Bionic nodes.
#' @return Sets your environment variable CROMWELLURL to be that of the Cromwell server for the job specified.
#' @author Amy Paguirigan
#' @details
#' Will require your Fred Hutch Id and will prompt you to enter your Fred Hutch password.
#' @export
setCromwellURL <- function(FredHutchId = NULL, jobId = NULL, port = "2020", local = TRUE, cluster = "gizmo") {
setCromwellURL <- function(FredHutchId = NULL, jobId = NULL, port = "2020", local = TRUE, cluster = "trusty") {
if (is.null(FredHutchId) == T) {
stop("Please supply your Fred Hutch id.")
}
if (is.null(jobId) == T) {
stop("Please supply the SLURM jobId of your Cromwell server job.")
}
if (cluster == "gizmo"){
nodecommand = paste0('squeue -M gizmo -o "%R" -j ', jobId)
} else if (cluster == "beagle"){
nodecommand = paste0('squeue -M beagle -o "%R" -j ', jobId)
}

if (cluster == "trusty") { rhino <- "@rhino"
} else if (cluster == "bionic") { rhino <- "@rhino03"
} else { stop("You specified 'cluster' as neither 'trusty' nor 'bionic', so I'm not sure which 'rhino' to submit your request to.")}

nodecommand = paste0('squeue -o "%R" -j ', jobId)

if (local == T){
# Make an ssh session to rhino and it will prompt for password
session <- ssh::ssh_connect(paste0(FredHutchId, "@rhino"))
session <- ssh::ssh_connect(paste0(FredHutchId, rhino))
getNode <- ssh::ssh_exec_internal(session, command = nodecommand)
nodeName <- sub("^.*)", "", gsub("\n", "", rawToChar(getNode$stdout)))
if (nodeName == ""){
Expand Down
4 changes: 2 additions & 2 deletions man/cromwellCreate.Rd

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

4 changes: 2 additions & 2 deletions man/setCromwellURL.Rd

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

0 comments on commit e3d322c

Please sign in to comment.