Builds the full path to a file that is stored as part of a bbi_... S3 object. Note that calling get_path_from_object() directly is not recommended for most users because it requires knowing about the internal structure of the model object. Instead we recommend using the friendlier helpers get_model_path(), get_yaml_path(), get_output_dir() when possible.

get_path_from_object(.bbi_object, .key, .check_exists = TRUE)

# S3 method for default
get_path_from_object(.bbi_object, .key, .check_exists = TRUE)

# S3 method for character
get_path_from_object(.bbi_object, .key, .check_exists = TRUE)

# S3 method for bbi_run_log_df
get_path_from_object(.bbi_object, .key, .check_exists = TRUE)

get_model_path(.bbi_object, .check_exists = TRUE)

get_output_dir(.bbi_object, .check_exists = TRUE)

get_yaml_path(.bbi_object, .check_exists = TRUE)

Arguments

.bbi_object

The model object to query. Could be a bbi_{.model_type}_model object, a file path to a model, a tibble of class bbi_run_log_df, or some other custom object containing model data.

.key

The key that contains the relative path.

.check_exists

If TRUE, the default, function will check if a file exists at the returned path and error if it does not. If FALSE, will return the path without checking.

Details

All helper functions mentioned above call get_path_from_object() under the hood and will dispatch via S3 in the same way that it would.

Note that 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 requested relative path. As long as the YAML has not moved since it was read into memory, this will work.

Methods (by class)

  • default: The default method attempts to extract the path from any object passed to it, but is designed for a list of class bbi_{.model_type}_model or something similar.

  • character: Takes a file path to a model that can be loaded with read_model(.bbi_object)

  • bbi_run_log_df: Takes a tibble of class bbi_run_log_df and returns a character vector of one path per row in the tibble.