Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function to run NMTRAN on a model #705

Merged
merged 31 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
40edc91
new run_nmtran function for checking tha validity of a model submission
barrettk Jun 25, 2024
2fbd57a
new print method for nmtran_process
barrettk Jun 25, 2024
aa78cbb
document and add tests
barrettk Jun 25, 2024
9f933ce
remove check for minimum version of nmrec
barrettk Jun 25, 2024
51273bb
add run_nmtran to pkgdown site
barrettk Jun 28, 2024
c211059
fix: status value handling
barrettk Jul 10, 2024
7c3b2eb
add new `nm_fdata` function for returning `FDATA` via `NM-TRAN`
barrettk Jul 10, 2024
2abd55c
add print method and error catching for fdata
barrettk Jul 10, 2024
d23855e
remove `nm_fdata` from this PR
barrettk Jul 15, 2024
1b1681f
revert `nm_file_impl` change used in `nm_fdata`
barrettk Jul 15, 2024
d93af1f
remove mod_path from args
barrettk Jul 16, 2024
afe8540
added support for passing specific `bbi_args` to `NM-TRAN` call
barrettk Jul 18, 2024
7b245c8
add details to .bbi_args options
barrettk Jul 19, 2024
fbe1344
Minor updates from KyleM's feedback
barrettk Jul 23, 2024
fea7424
refactor setup and formatting of .bbi_args
barrettk Jul 23, 2024
315f4cc
adjust directory handling in execute_nmtran
barrettk Jul 23, 2024
7a5a762
adjust .config_path abort message when invalid path is specified
barrettk Jul 23, 2024
85969c9
documentation and tempdir adjustments
barrettk Jul 24, 2024
e0c0281
refactor setup of NM-TRAN executable
barrettk Jul 24, 2024
f1e9c7d
run nmtran_presort before `NM-TRAN`
barrettk Jul 24, 2024
bfa71e1
refactored nmtran_presort and updated documentation/tests
barrettk Jul 25, 2024
d52d123
convert process$new() calls to run() calls
barrettk Jul 25, 2024
ed5d19f
refactors and updates from feedback
barrettk Jul 30, 2024
1bfc3f4
add handling for NULL nonmem versions in bbi.yaml
barrettk Jul 30, 2024
6f18560
update parse_nmtran_args to mimic submit_model handling of .bbi_args
barrettk Jul 31, 2024
6333a00
test fix: adjust error message
barrettk Jul 31, 2024
ebe3f13
add additional test for parse_nmtran_args changes
barrettk Jul 31, 2024
1234612
address minor feedback and add dedicated parse_nmtran_args tests
barrettk Aug 1, 2024
dd8bc6e
documentation and test adjustments from feedback
barrettk Aug 2, 2024
29995f7
Add support for Windows
barrettk Aug 2, 2024
784c3c2
tweak comment about NM-TRAN and nmtran_presort on Windows
barrettk Aug 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ S3method(print,bbi_nmboot_summary)
S3method(print,bbi_nonmem_summary)
S3method(print,bbi_process)
S3method(print,model_tree_static)
S3method(print,nmtran_process)
S3method(print_model_files,default)
S3method(submit_model,bbi_base_model)
S3method(submit_model,bbi_nmboot_model)
Expand Down Expand Up @@ -194,6 +195,7 @@ export(replace_model_field)
export(replace_note)
export(replace_tag)
export(run_log)
export(run_nmtran)
export(setup_bootstrap_run)
export(submit_model)
export(submit_models)
Expand Down
3 changes: 2 additions & 1 deletion R/aaa.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ BBI_ARGS = list(
delay = list(
type = "numeric",
flag = "--delay",
description = "Selects a random number of seconds between 1 and this value to stagger / jitter job execution. Assists in dealing with large volumes of work dealing with the same data set. May avoid NMTRAN issues about not being able read / close files"
description = "Selects a random number of seconds between 1 and this value to stagger / jitter job execution. Assists in dealing with large volumes of work dealing with the same data set. May avoid NM-TRAN issues about not being able read / close files"
),
ext_file = list(
type = "character",
Expand Down Expand Up @@ -209,6 +209,7 @@ RUN_LOG_CLASS <- "bbi_run_log_df"
CONF_LOG_CLASS <- "bbi_config_log_df"
SUM_LOG_CLASS <- "bbi_summary_log_df"
LOG_DF_CLASS <- "bbi_log_df"
NMTRAN_PROCESS_CLASS <- "nmtran_process"

# YAML keys that are hard-coded
YAML_YAML_MD5 <- "yaml_md5"
Expand Down
2 changes: 1 addition & 1 deletion R/get-path-from-object.R
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ get_data_path_nonmem <- function(

if(isTRUE(.check_exists)){
if(!fs::file_exists(data_path)){
# The first error message line is what NMTRAN would return in this situation
# The first error message line is what NM-TRAN would return in this situation
rlang::abort(
c(
"x" = "Input data file does not exist or cannot be opened",
Expand Down
53 changes: 52 additions & 1 deletion R/print.R
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,58 @@ print.bbi_nmboot_summary <- function(x, .digits = 3, .nrow = 10, ...) {
}
}


#' @describeIn print_bbi Prints the `NM-TRAN` evaluation of a `bbi_nonmem_model`
#' object
#' @export
print.nmtran_process <- function(x, ...){

is_valid_print <- function(.x) {
if (!is.null(.x)) {
length(.x) != 0
} else {
FALSE
}
barrettk marked this conversation as resolved.
Show resolved Hide resolved
}

heading <- cli_h1
subheading <- cli_h2
bullet_list <- cat_bullet

status <- x[["status"]]
if (x[["status_val"]] == 0) {
status <- col_green(status)
} else {
status <- col_red(status)
}

heading(cli::col_magenta("NM-TRAN Status"))
subheading(status)

heading("Absolute Model Path")
bullet_list(x[[ABS_MOD_PATH]])

heading("NM-TRAN Specifications")
cli::cli_bullets(
c(
"*" = "NONMEM Version: {.val {x[['nonmem_version']]}}",
"*" = "NM-TRAN Executable: {.path {x[['nmtran_exe']]}}",
"*" = "nmtran_presort: {cli::col_cyan(!is.null(x[['nmtran_presort_exe']]))}"
)
)

# Print run directory if it still exists (clean = FALSE)
if(fs::dir_exists(x[['run_dir']])){
cli::cli_bullets(c("*" = "Run Directory: {.path {x[['run_dir']]}}"))
}

if (is_valid_print(x[["output"]])) {
heading('Output')
cat_line(x[["output"]])
}
}


#' @describeIn print_bbi Draw model tree as a static plot
#' @param x plot to display
#' @param newpage Logical (T/F). If `TRUE`, draw new (empty) page first.
Expand Down Expand Up @@ -471,7 +523,6 @@ print.model_tree_static <- function(x, newpage = is.null(vp), vp = NULL, ...){
return(invisible(x))
}


#####################
# INTERNAL HELPERS
#####################
Expand Down
Loading