R/recall.R

Defines functions recall recallable

Documented in recall recallable

#' @title Function \code{recall}
#' @description Loads an object/target from the cache.
#' Use the \code{\link{help_parallelRemake}} function to get more help.
#' @details Use the \code{\link{help_parallelRemake}} function to get more help.
#' @seealso \code{\link{help_parallelRemake}}
#' @export
#' @return A loaded object
#' @param ... Characters, names of objects to load from cache
#' @param cache Character vector, path to \code{storr} cache to load from.
recall = function(..., cache = file.path(".remake", "objects")){
  if(!file.exists(cache)) stop(paste0("Remake cache \"", cache, "\" does not exist."))
  args = as.character(unlist(list(...)))
  st = storr_rds(cache)
  out = lapply(args, st$get)
  names(out) = args
  if(length(out) < 2) out = out[[1]]
  out
}

#' @title Function \code{recallable}
#' @description Lists the objects/targets available to laod from the cache.
#' Use the \code{\link{help_parallelRemake}} function to get more help.
#' @details Use the \code{\link{help_parallelRemake}} function to get more help.
#' @seealso \code{\link{help_parallelRemake}}
#' @export
#' @return A character vector of objects/targets available to laod from the cache.
#' @param cache Character vector, path to \code{storr} cache to load from.
recallable = function(cache = file.path(".remake", "objects")){
  if(!file.exists(cache)) return(character(0))
  st = storr_rds(cache)
  st$list()
}
wlandau/parallelRemake documentation built on May 4, 2019, 8:44 a.m.