Skip to content

Commit

Permalink
added project_name and project_path to default provided values to tem…
Browse files Browse the repository at this point in the history
…plate.
  • Loading branch information
mduncans committed Sep 5, 2024
1 parent a4bd234 commit dc3347c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
25 changes: 22 additions & 3 deletions R/submit-model.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,45 @@ submit_nonmem_model <-
}

config_toml_path <- paste0(.mod$absolute_model_path, ".toml")
if (!fs::file_exists(config_toml_path)) {
rlang::warn(sprintf("config.toml file not found, if submitting the job with nmm this is required. Please run generate_nmm_config()"))
}
#if (!fs::file_exists(config_toml_path)) {
# rlang::warn(sprintf("config.toml file not found, if submitting the job with nmm this is required. Please run generate_nmm_config()"))
#}

if (is.null(slurm_template_opts$nmm_exe_path)) {
nmm_exe_path <- Sys.which("nmm")
} else {
nmm_exe_path <- slurm_template_opts$nmm_exe_path
}

if (is.null(slurm_template_opts$bbi_exe_path)) {
bbi_exe_path <- Sys.which("bbi")
} else {
bbi_exe_path <- slurm_template_opts$bbi_exe_path
}


if (is.null(slurm_template_opts$project_path)) {
project_path <- rstudioapi::getActiveProject()
} else {
project_path <- slurm_template_opts$project_path
}
if (is.null(slurm_template_opts$project_name)) {
project_name <- tools::file_path_sans_ext(
list.files(
path = project_path,
pattern = ".Rproj$")
)
} else {
project_name <- slurm_template_opts$project_name
}

default_template_list = list(
partition = partition,
parallel = parallel,
ncpu = ncpu,
job_name = sprintf("%s-nonmem-run", basename(.mod$absolute_model_path)),
project_path = project_path,
project_name = project_name,
bbi_exe_path = bbi_exe_path,
bbi_config_path = bbi_config_path,
model_path = .mod$absolute_model_path,
Expand Down
3 changes: 3 additions & 0 deletions vignettes/model/nonmem/slurm-job-nmm.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#SBATCH --ntasks=1
#SBATCH --cpus-per-task={{ncpu}}
#SBATCH --partition={{partition}}
#SBATCH --account={{project_name}}

#{{project_path}}

unset SLURM_NODELIST
unset SLURM_JOB_NODELIST
Expand Down
3 changes: 2 additions & 1 deletion vignettes/slack-alerts.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ submission_nmm <- slurmtools::submit_nonmem_model(
overwrite = TRUE,
slurm_job_template_path = file.path(nonmem, "slurm-job-nmm.tmpl"),
slurm_template_opts = list(
nmm_exe_path = normalizePath("~/.local/bin/nmm"))
nmm_exe_path = normalizePath("~/.local/bin/nmm")
)
)
submission_nmm
Expand Down

0 comments on commit dc3347c

Please sign in to comment.