metrumresearchgroup / bbr

R interface for model and project management
https://metrumresearchgroup.github.io/bbr/
Other
23 stars 2 forks source link

build_path_from_model: add name argument? #618

Open kyleam opened 10 months ago

kyleam commented 10 months ago

Or more generally: reconcile with bbr.bayes::chain_paths() behavior?

This is a follow-up to https://github.com/metrumresearchgroup/bbr.bayes/pull/104#pullrequestreview-1710663242.

Commit d3e400 says

Note that conceptually this is similar to the
bbr::build_path_from_model() generic.  Perhaps this functionality
should even be exposed as an nmbayes method for that.

However, 1) that would mean build_path_from_model() would return a
non-scalar, which may be okay but probably needs more thought and 2)
at least currently, build_path_from_model() doesn't have support for
specifying a name to use in place of the model ID (which chain_paths()
will gain in the next commit).  So, for now at least, expose a
tailored function.

@seth127 said:

I'm not sure when we would prioritize it, but I do like the idea of unifying these, and of adding the name argument to bbr::build_path_from_model().


https://github.com/metrumresearchgroup/bbr.bayes/blob/3637c35931063bde312bd2a9a3d76f9d7ef89b9c/R/nmbayes-helpers.R#L40-L53

#' Return output file from each chain subdirectory
#'
#' Starting with the top-level NOMEM Bayes model, construct the paths to the
#' specified per-chain output files.
#'
#' @param .mod A `bbi_nmbayes_model` object.
#' @param name Name of file, without leading path or extension. If unspecified,
#'   defaults to "{id}-{chain}".
#' @param extension File extension.
#' @return Absolute file paths, one for each chain.
#' @seealso [bbr_nmbayes] for a high-level description of how NONMEM Bayes
#'   models are structured
#' @export
chain_paths <- function(.mod, name = NULL, extension = "") {

https://github.com/metrumresearchgroup/bbr/blob/ac4293a28e001ce0977d76ff75c1f003ab85ca34/R/get-path-from-object.R#L200-L221

So the path forward could be something like

Then on the bbr.bayes side: