Skip to content

Commit

Permalink
updated get_slurm_jobs to prevent error filtering when no jobs are in…
Browse files Browse the repository at this point in the history
… squeue.
  • Loading branch information
mduncans committed Sep 9, 2024
1 parent 458ca13 commit 1159134
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 52 deletions.
13 changes: 11 additions & 2 deletions R/get-jobs.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,16 @@ get_slurm_jobs <- function(user = NULL){
res_df$submit_time <- as.POSIXct(res_df$submit_time, origin = "1970-01-01")
res_df$start_time <- as.POSIXct(res_df$start_time, origin = "1970-01-01")
if (!is.null(user)) {
return(dplyr::filter(res_df, user_name == user))
df <- tryCatch(
{
dplyr::filter(res_df, user_name == user)
},
error = function(e) {
res_df
}
)
} else {
df <- res_df
}
res_df
return(df)
}
32 changes: 16 additions & 16 deletions vignettes/Running-nonmem.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -250,20 +250,20 @@ To reiterate, this template file is run as a bash shell script so anything you c

```{r, include = FALSE}
#cancelling any running nonmem jobs
state <- slurmtools::get_slurm_jobs(user = "matthews")
if (any(state$job_state %in% c("RUNNING", "CONFIGURING"))) {
for (job_id in state %>% dplyr::filter(job_state == "RUNNING") %>% dplyr::pull("job_id")) {
processx::run("scancel", args = paste0(job_id))
}
}
#removing generated files from running this vignette
nonmem <- file.path("model", "nonmem")
unlink(file.path(nonmem, "1001"), recursive = TRUE)
unlink(file.path(nonmem, "1001.yaml"))
unlink(file.path(nonmem, "1001.toml"))
unlink(file.path(nonmem, "submission-log"), recursive = TRUE)
unlink(file.path(nonmem, "in_progress"), recursive = TRUE)
# state <- slurmtools::get_slurm_jobs(user = "matthews")
#
# if (any(state$job_state %in% c("RUNNING", "CONFIGURING"))) {
# for (job_id in state %>% dplyr::filter(job_state == "RUNNING") %>% dplyr::pull("job_id")) {
# processx::run("scancel", args = paste0(job_id))
# }
# }
#
# #removing generated files from running this vignette
# nonmem <- file.path("model", "nonmem")
#
# unlink(file.path(nonmem, "1001"), recursive = TRUE)
# unlink(file.path(nonmem, "1001.yaml"))
# unlink(file.path(nonmem, "1001.toml"))
# unlink(file.path(nonmem, "submission-log"), recursive = TRUE)
# unlink(file.path(nonmem, "in_progress"), recursive = TRUE)
```
34 changes: 17 additions & 17 deletions vignettes/custom-alerts.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -247,21 +247,21 @@ This gives us the notifications in a much more digestible format
![nmm ntfy.sh alerts](data/images/nmm_ntfy_alerts.png)

```{r, include = FALSE}
#cancelling any running nonmem jobs
state <- slurmtools::get_slurm_jobs(user = "matthews")
if (any(state$job_state %in% c("RUNNING", "CONFIGURING"))) {
for (job_id in state %>% dplyr::filter(job_state == "RUNNING") %>% dplyr::pull("job_id")) {
processx::run("scancel", args = paste0(job_id))
}
}
#removing generated files from running this vignette
nonmem <- file.path("model", "nonmem")
unlink(file.path(nonmem, "1001"), recursive = TRUE)
unlink(file.path(nonmem, "1001.yaml"))
unlink(file.path(nonmem, "1001.toml"))
unlink(file.path(nonmem, "submission-log"), recursive = TRUE)
unlink(file.path(nonmem, "in_progress"), recursive = TRUE)
# #cancelling any running nonmem jobs
# state <- slurmtools::get_slurm_jobs(user = "matthews")
#
# if (any(state$job_state %in% c("RUNNING", "CONFIGURING"))) {
# for (job_id in state %>% dplyr::filter(job_state == "RUNNING") %>% dplyr::pull("job_id")) {
# processx::run("scancel", args = paste0(job_id))
# }
# }
#
# #removing generated files from running this vignette
# nonmem <- file.path("model", "nonmem")
#
# unlink(file.path(nonmem, "1001"), recursive = TRUE)
# unlink(file.path(nonmem, "1001.yaml"))
# unlink(file.path(nonmem, "1001.toml"))
# unlink(file.path(nonmem, "submission-log"), recursive = TRUE)
# unlink(file.path(nonmem, "in_progress"), recursive = TRUE)
```
34 changes: 17 additions & 17 deletions vignettes/slack-alerts.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -125,21 +125,21 @@ slurmtools::get_slurm_jobs()
![nmm slack alerts](data/images/nmm_slack_notifications.png)

```{r, include = FALSE}
#cancelling any running nonmem jobs
state <- slurmtools::get_slurm_jobs(user = "matthews")
if (any(state$job_state %in% c("RUNNING", "CONFIGURING"))) {
for (job_id in state %>% dplyr::filter(job_state == "RUNNING") %>% dplyr::pull("job_id")) {
processx::run("scancel", args = paste0(job_id))
}
}
#removing generated files from running this vignette
nonmem <- file.path("model", "nonmem")
unlink(file.path(nonmem, "1001"), recursive = TRUE)
unlink(file.path(nonmem, "1001.yaml"))
unlink(file.path(nonmem, "1001.toml"))
unlink(file.path(nonmem, "submission-log"), recursive = TRUE)
unlink(file.path(nonmem, "in_progress"), recursive = TRUE)
# #cancelling any running nonmem jobs
# state <- slurmtools::get_slurm_jobs(user = "matthews")
#
# if (any(state$job_state %in% c("RUNNING", "CONFIGURING"))) {
# for (job_id in state %>% dplyr::filter(job_state == "RUNNING") %>% dplyr::pull("job_id")) {
# processx::run("scancel", args = paste0(job_id))
# }
# }
#
# #removing generated files from running this vignette
# nonmem <- file.path("model", "nonmem")
#
# unlink(file.path(nonmem, "1001"), recursive = TRUE)
# unlink(file.path(nonmem, "1001.yaml"))
# unlink(file.path(nonmem, "1001.toml"))
# unlink(file.path(nonmem, "submission-log"), recursive = TRUE)
# unlink(file.path(nonmem, "in_progress"), recursive = TRUE)
```

0 comments on commit 1159134

Please sign in to comment.