-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
Previous PR: #652 |
45b4a7f
to
9f933ce
Compare
- In testing this feature out in more scenarios surrounding data setup, I noticed a status value of 8 was possible, and pointed to a particular error type. Rather than attempting to categorize each error type, just report a failure for anything other than an exit status of `0`
- organize documentation and add additional details
- print method shows how many records have dropped - noticed issue with current implementation. The setting of column names will not work if columns were dropped. May also consider take renaming into account (eg., `$INPUT DV=CP`).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few comments prior to main review
- opting to separate this into a separate, more focused PR
- see previous commit message
- taken from #705 (some additional changes) - known issues: - Need to remove column "C" from columns retrieved from the control stream file. FDATA seems to always start with 'ID'. Will include additional details in a later commit when this behavior is more understood - Need to support alternate formats (WIDE, etc) - Need to check for additional $INPUT options and add handling for them (unclear which ones at the moment)
- I had noticed some weird interaction here in the past when removing this, but seems fine now
- still need to add more details to the documentation
- make NM-TRAN label consistent across all functions and documentation - store NM-TRAN standard error in the same file as standard output. Adjust print method
- now always returns a character vector signifiying the values of `prdefault`, `tprdefault`, and `maxlim` respectively (i.e. '0' '0' '2' as the default) - Unsure if this is set up correctly, as im now receiving different NM-TRAN output messages. Might be a different order than the one highlighted above.
- doc fixes
- nmtran_presort detection now happens in nmtran_setup() - Print whether nmtran_presort was run ahead of `NM-TRAN` - Add documentation about nmtran_presort, and make `run_dir` an argument (defaulting to temporary directory). An example illustrates the benefit of changing this to your working directory
@kyleam just requested another review. I wasn't able to notice any difference when passing I hooked up As an aside, let me know what you think about the |
I haven't taken a close look at what was addressed or the new changes, but one thing I do feel strongly about is the switch to |
- update print method to only print the run directory if it still exists
Sounds good just implemented in latest commit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates. Another round of code review. Hopefully after this we can focus on a final phase of interactive testing (especially on our Windows instance).
- Documentation updates - Move tests to their own file and update based on refactors
- update error messages to use cli::cli_abort with better formatting
- add documentation for added clarity
- add parse_nmtran_args tests instead of documentation to help clarify expected results
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few minor comments I think would be good to address before merging, but nothing that's a blocker. Holding off on approving until I have a chance to do some interactive testing on Windows.
follow-up on do2test discussion
Quick recap:
- starting with NONMEM 7.5 nmfe has two calls to NM-TRAN
- the first call passes a fourth
do2test
argument - bbi doesn't expose nmfe's
-do2test
argument, so in the bbi/bbr context this call always passes "0" to NM-TRAN for thedo2test
value - if that first call exits with a status of 9, nmfe does a follow-up call that drops the fourth argument (do2test)
The main question is whether passing 0 for do2test is equivalent to not passing a fourth argument. If it is, then the current run_nmtran
approach is functionally equivalent to what nmfe does. If not, then there is divergence (though it's hard to say for which cases, if any, it matters).
The only way to definitively answer that question would be to analyze the NM-TRAN code.
To follow nmfe here, we could
-
determine if the NONMEM version passes do2test (e.g., by some version check or a grep of nmfe script)
-
follow its logic (i.e. two calls, check status of first)
But at this point, I think we can leave that be, especially given run_nmtran
is a standalone helper. We should revisit the idea if submit_model
starts using it as a default preflight check.
I would like if there was a code comment about this. Something like:
# Note: run_nmtran considers only the first three NM-TRAN arguments (prdefault,
# tprdefault, and maxlim), but, starting with NONMEM 7.5, nmfe passes a fourth
# argument (do2test) to NM-TRAN. See discussion at
# https://github.com/metrumresearchgroup/bbr/pull/705
I wasn't able to notice any difference when passing
do2test
withnm75
. That's not to say it isn't doing anything, but I haven't detected any differences with the models i've tested (one real one outside ofbbr
). I wasnt able to find any documentation either, [...] Im not convinced it's necessary from that.
Thanks for testing. The details get tricky here, so, if you still have it around, for posterity it'd be nice to document what specifically you tested.
The first run with diff --git a/R/run-nmtran.R b/R/run-nmtran.R
index 45ece442..6869357b 100644
--- a/R/run-nmtran.R
+++ b/R/run-nmtran.R
@@ -178,6 +178,9 @@ nmtran_setup <- function(
# Check if nmtran_presort exists
nmtran_presort_exe <- file.path(nm_path, "util", "nmtran_presort")
+ if (ON_WINDOWS) {
+ nmtran_presort_exe <- paste0(nmtran_presort_exe, ".exe")
+ }
run_presort <- unname(fs::file_exists(nmtran_presort_exe))
return( But then the presort subprocess produces empty output for the control stream. Looking at
If I call it from bash, it doesn't produce empty output:
Not sure yet what's going on here, but I won't have more time to look at it today. @barrettk, this is under the shared Windows VM, if you want to take a look. |
- add details about additional `do2test` argument for NONMEM 7.5 and later - adjust test to not look for a specific status value on failure. Any non-zero value is a failure, so we dont need to check the specific value
- This is not an ideal solution, though it has worked in practice. On Windows the output ends up being saved to a `fort.6` file instead of the intended stdout location. stdout instead gets created with no contents. - This approach copies the `nmtran_presort` results from `fort.6` to stdout, and reads in the `NM-TRAN` results from `fort.6` instead of stdout
@barrettk Thanks for looking into the Windows issue and proposing a fix. Capturing some links and info from our internal discussion:
I'm still fuzzy on what's going on our end. Why do these FORTRAN executables work in some environment (terminals mentioned above and, given lst output of success test models, shell scripts executed bbi)? But the above info about stdout in the FORTRAN world, including an interaction with R, is enough to make me comfortable with the workaround you propose. I don't think we need to hold up this PR to do a deeper dive into this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a minor suggestion for the Windows comment, but this is ready to go in my view. Thanks.
- taken from #705 (some additional changes) - known issues: - Need to remove column "C" from columns retrieved from the control stream file. FDATA seems to always start with 'ID'. Will include additional details in a later commit when this behavior is more understood - Need to support alternate formats (WIDE, etc) - Need to check for additional $INPUT options and add handling for them (unclear which ones at the moment)
Args
Example
closes #650