Skip to content

Commit

Permalink
Add a new 'wallclock_time' column to the output of 'job_report()'; ch…
Browse files Browse the repository at this point in the history
…ange 'elapsed_time' to 'wallclock_time' for 'job_info()' for consistency
  • Loading branch information
Nick-Eagles committed Oct 27, 2023
1 parent 6f583f7 commit 06f755c
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion R/job_info.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
9 changes: 6 additions & 3 deletions R/job_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
#'
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
Binary file modified data/job_info_df.rda
Binary file not shown.
2 changes: 1 addition & 1 deletion man/job_info_df.Rd

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

4 changes: 2 additions & 2 deletions tests/testthat/test-job_info.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)])

Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/test-job_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)])

Expand Down

0 comments on commit 06f755c

Please sign in to comment.