diff --git a/R/job_info.R b/R/job_info.R index 5aa0b4c..74b5c6e 100644 --- a/R/job_info.R +++ b/R/job_info.R @@ -55,7 +55,7 @@ job_info <- function(user = Sys.getenv("USER"), partition = "shared") { PARTITION = as.factor(PARTITION), STATUS = as.factor(ST), JOB_ID = as.integer(JOBID), - ELAPSED_TIME = parse_slurm_time(TIME) + WALLCLOCK_TIME = parse_slurm_time(TIME) ) |> rename(REQUESTED_MEM_GB = MIN_MEMORY) |> select(-c(ST, JOBID, TIME)) diff --git a/R/job_report.R b/R/job_report.R index c59821d..5ab876a 100644 --- a/R/job_report.R +++ b/R/job_report.R @@ -8,7 +8,7 @@ #' @return A tibble with information about the requested job. #' @export #' @author Nicholas J. Eagles -#' @import dplyr stringr utils +#' @import dplyr stringr utils lubridate #' #' @family monitoring and informational functions #' @@ -25,7 +25,7 @@ job_report <- function(job_id) { job_df <- read.csv( text = system( sprintf( - 'sacct -j %s -P -o "JobID,JobIDRaw,User,JobName,Partition,AllocCPUS,ReqMem,State,MaxRSS,MaxVMSize,ExitCode" --units=G', + 'sacct -j %s -P -o "JobID,JobIDRaw,User,JobName,Partition,AllocCPUS,ReqMem,State,MaxRSS,MaxVMSize,ExitCode,ElapsedRaw" --units=G', job_id ), intern = TRUE @@ -161,6 +161,9 @@ job_report <- function(job_id) { exit_code = as.integer( str_extract(ExitCode, "^([0-9]+):", group = 1) ), + wallclock_time = ElapsedRaw |> + seconds() |> + as.difftime(), # Some character columns should be factors Partition = as.factor(Partition), status = as.factor(State) @@ -174,7 +177,7 @@ job_report <- function(job_id) { max_vmem_gb = MaxVMSize, max_rss_gb = MaxRSS, ) |> - select(-c(State, job_step, JobIDRaw, ExitCode)) + select(-c(State, job_step, JobIDRaw, ExitCode, ElapsedRaw)) colnames(job_df) <- tolower(colnames(job_df)) # Given a character vector containing an amount of memory (containing diff --git a/data/job_info_df.rda b/data/job_info_df.rda index 0fd64d2..77f358e 100644 Binary files a/data/job_info_df.rda and b/data/job_info_df.rda differ diff --git a/man/job_info_df.Rd b/man/job_info_df.Rd index b58242d..27d9e49 100644 --- a/man/job_info_df.Rd +++ b/man/job_info_df.Rd @@ -5,7 +5,7 @@ \alias{job_info_df} \title{Example output from \code{job_info(user = NULL, partition = "shared")}} \format{ -An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 100 rows and 10 columns. +An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 100 rows and 11 columns. } \usage{ job_info_df diff --git a/tests/testthat/test-job_info.R b/tests/testthat/test-job_info.R index b629899..dd9a17d 100644 --- a/tests/testthat/test-job_info.R +++ b/tests/testthat/test-job_info.R @@ -21,7 +21,7 @@ test_that( any_other_na <- job_df |> select( job_id, user, name, partition, cpus, requested_mem_gb, status, - elapsed_time + wallclock_time ) |> is.na() |> any() @@ -48,7 +48,7 @@ test_that( user = "character", array_task_id = "integer", name = "character", partition = "factor", cpus = "integer", requested_mem_gb = "numeric", status = "factor", - elapsed_time = "difftime" + wallclock_time = "difftime" ) expected_types <- unname(expected_types[colnames(job_df)]) diff --git a/tests/testthat/test-job_report.R b/tests/testthat/test-job_report.R index 0c2c3ac..39308d3 100644 --- a/tests/testthat/test-job_report.R +++ b/tests/testthat/test-job_report.R @@ -19,7 +19,8 @@ test_that( cpus = "integer", requested_mem_gb = "numeric", max_rss_gb = "numeric", max_vmem_gb = "numeric", partition = "factor", array_task_id = "integer", - exit_code = "integer", status = "factor" + exit_code = "integer", status = "factor", + wallclock_time = "difftime" ) expected_types <- unname(expected_types[colnames(job_df)])