Returns character vector (or list of character vectors) of the absolute paths to all models stored in the based_on field of a bbi_... object.
Usage
get_based_on(.bbi_object, .check_exists = FALSE)
# Default S3 method
get_based_on(.bbi_object, .check_exists = FALSE)
# S3 method for class 'character'
get_based_on(.bbi_object, .check_exists = FALSE)
# S3 method for class 'bbi_run_log_df'
get_based_on(.bbi_object, .check_exists = FALSE)
get_model_ancestry(.bbi_object)
# Default S3 method
get_model_ancestry(.bbi_object)
# S3 method for class 'character'
get_model_ancestry(.bbi_object)
# S3 method for class 'bbi_run_log_df'
get_model_ancestry(.bbi_object)Arguments
- .bbi_object
The model object to query. Could be a
bbi_{.model_type}_modelobject, a file path to a model, a tibble of classbbi_run_log_df, or some other custom object containing model data.- .check_exists
If
FALSE, the default, function will return all paths inbased_onregardless of whether they point to an existing file. IfTRUE, function will check if a file exists at each path inbased_onand error if one does not.
Details
get_model_ancestry() extracts paths to all models that this model is based on (iterating over get_based_on() function),
and all models that those models are based on, recursively.
It returns a sorted unique character vector for the default and character method, and a list of such vectors for the bbi_run_log_df method.
Some notes on get_model_ancestry():
.check_exists = TRUEis set for this iterative search because each model found will subsequently be loaded.get_model_ancestry()has all the same S3 methods asget_based_on()
For both get_based_on() and get_model_ancestry(), all paths saved in the object or accompanying YAML will be relative to the location of that YAML
When the object is loaded into memory, the absolute path to the YAML is stored in the object.
These functions simply stitch together that path with the relative paths from the based_on field.
As long as the YAML has not moved since it was read into memory, these paths will be both absolute and correct.
Methods (by class)
get_based_on(default): The default method attempts to extract the path from any object passed to it, but is designed for a list of classbbi_{.model_type}_modelor something similar.get_based_on(character): Takes a character scalar of a path to a model that can be loaded withread_model(.bbi_object).get_based_on(bbi_run_log_df): Takes a tibble of classbbi_run_log_dfand returns a list containing one character vector of paths for each row of the tibble.
