From dc3347cdb19a55f0f2012cf0cdd1bade8c4e4f31 Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 5 Sep 2024 15:27:51 +0000 Subject: [PATCH] added project_name and project_path to default provided values to template. --- R/submit-model.R | 25 ++++++++++++++++++++--- vignettes/model/nonmem/slurm-job-nmm.tmpl | 3 +++ vignettes/slack-alerts.Rmd | 3 ++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/R/submit-model.R b/R/submit-model.R index 8f87df3..6405220 100644 --- a/R/submit-model.R +++ b/R/submit-model.R @@ -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, diff --git a/vignettes/model/nonmem/slurm-job-nmm.tmpl b/vignettes/model/nonmem/slurm-job-nmm.tmpl index c94afb5..8a64c5b 100644 --- a/vignettes/model/nonmem/slurm-job-nmm.tmpl +++ b/vignettes/model/nonmem/slurm-job-nmm.tmpl @@ -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 diff --git a/vignettes/slack-alerts.Rmd b/vignettes/slack-alerts.Rmd index f78bdca..88f0a53 100644 --- a/vignettes/slack-alerts.Rmd +++ b/vignettes/slack-alerts.Rmd @@ -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