Skip to content

Commit

Permalink
Merge pull request #8 from A2-ai/proj_name
Browse files Browse the repository at this point in the history
added project_name and path to default template list. Updated vignette.
  • Loading branch information
mduncans authored Sep 5, 2024
2 parents dc3347c + 1821877 commit a9eae76
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
9 changes: 2 additions & 7 deletions R/submit-model.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,13 @@ submit_nonmem_model <-
bbi_exe_path <- slurm_template_opts$bbi_exe_path
}


if (is.null(slurm_template_opts$project_path)) {
project_path <- rstudioapi::getActiveProject()
project_path <- here::here()
} 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$")
)
project_name <- here::here() %>% basename()
} else {
project_name <- slurm_template_opts$project_name
}
Expand Down
9 changes: 7 additions & 2 deletions vignettes/Running-nonmem.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ This function uses the inputs to populate a template Bash shell script that subm
By default these values are provided to the slurm template file:

``` r
list(
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 = Sys.which("bbi"),
bbi_config_path = bbi_config_path,
model_path = .mod$absolute_model_path,
Expand Down Expand Up @@ -99,6 +101,7 @@ Here is an example of a template file that will call `bbi`:
#SBATCH --ntasks=1
#SBATCH --cpus-per-task={{ncpu}}
#SBATCH --partition={{partition}}
#SBATCH --account={{project_name}}
# submit_nonmem_model uses the whisker package to populate template files
# https://github.com/edwindj/whisker
Expand Down Expand Up @@ -154,7 +157,7 @@ submission <- slurmtools::submit_nonmem_model(
submission
```

Notice we get a Warning about a config.toml file not being found. I'll expand on that later, but for now we see a `status` with an exit code of 0 suggesting a successful command, and the `stdout` gives us the batch job number. We can use `slurmtools::get_slurm_jobs()` to monitor the status of the job. Here, we can supply the user = "matthews" argument to filter to just the jobs I've submitted.
We see a `status` with an exit code of 0 suggesting a successful command, and the `stdout` gives us the batch job number. We can use `slurmtools::get_slurm_jobs()` to monitor the status of the job. Here, we can supply the user = "matthews" argument to filter to just the jobs I've submitted.

```{r}
slurmtools::get_slurm_jobs(user = 'matthews')
Expand All @@ -181,6 +184,7 @@ Here is a modified template file that adds a `JOBID=$SLURM_JOBID` and some ntfy
#SBATCH --ntasks=1
#SBATCH --cpus-per-task={{ncpu}}
#SBATCH --partition={{partition}}
#SBATCH --account={{project_name}}
JOBID=$SLURM_JOBID
Expand Down Expand Up @@ -231,6 +235,7 @@ Note that the run number will match the run specified in `submission$stdout`. We
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH --partition=cpu2mem4gb
#SBATCH --account=slurmtools

JOBID=$SLURM_JOBID

Expand Down
3 changes: 1 addition & 2 deletions vignettes/custom-alerts.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ not give you the path to the nmm binary if it is on your path or not. We
can inject the `nmm_exe_path` like we did with `bbi_exe_path` and assume
it's not on our path.

Remember that error about the `config.toml` file not existing? Well this
is the reason. This file controls what `nmm` will monitor and where to
The `config.toml` file controls what `nmm` will monitor and where to
look for files and how to alert you. We'll use `generate_nmm_config()`
to create this file. First we can look at the documentation to see what
type of information we should pass to this function.![documentation for
Expand Down
1 change: 1 addition & 0 deletions vignettes/model/nonmem/slurm-job-bbi-ntfy.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#SBATCH --ntasks=1
#SBATCH --cpus-per-task={{ncpu}}
#SBATCH --partition={{partition}}
#SBATCH --account={{project_name}}

JOBID=$SLURM_JOBID

Expand Down
3 changes: 2 additions & 1 deletion vignettes/model/nonmem/slurm-job-bbi.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#SBATCH --ntasks=1
#SBATCH --cpus-per-task={{ncpu}}
#SBATCH --partition={{partition}}

#SBATCH --account={{project_name}}
#{{project_path}}
unset SLURM_NODELIST
unset SLURM_JOB_NODELIST
unset SLURM_JOB_USER
Expand Down

0 comments on commit a9eae76

Please sign in to comment.