Download a workspace file from the cloud
so it can be loaded with tar_workspace().
Usage
tar_workspace_download(
name,
script = targets::tar_config_get("script"),
store = targets::tar_config_get("store"),
verbose = TRUE
)Arguments
- name
Symbol, name of the target whose workspace to download.
- script
Character string, file path to the
_targets.Rfile defining the pipeline. Must be configured with the rightawsandrepository_metaoptions (intar_option_set()) to support downloading workspaces from the cloud.- store
Character of length 1, path to the
targetsdata store. Defaults totar_config_get("store"), which in turn defaults to_targets/. When you set this argument, the value oftar_config_get("store")is temporarily changed for the current function call. Seetar_config_get()andtar_config_set()for details about how to set the data store path persistently for a project.- verbose
TRUEto print an informative message describing the download,FALSEto stay silent.
Details
If tar_option_get("repository_meta") is "aws" or "gcp", then
tar_make() uploads workspaces to the bucket and prefix provided.
Download one of these workspaces with tar_workspace_download().
Downloaded workspaces can be loaded the usual way with
tar_workspace(), and you should see them in
character vector returned by tar_workspaces().
See also
Other debug:
tar_load_globals(),
tar_traceback(),
tar_workspace(),
tar_workspaces()
Examples
if (identical(Sys.getenv("TAR_EXAMPLES"), "true")) { # for CRAN
tar_dir({ # tar_dir() runs code from a temp dir for CRAN.
tmp <- sample(1)
tar_script({
library(targets)
library(tarchetypes)
tar_option_set(
resources = tar_resources(
tar_resources_aws(
bucket = "YOUR_AWS_BUCKET",
prefix = "_targets"
)
),
repository = "aws",
repository_meta = "aws"
)
list(
tar_target(x, stop("this is an error and thus triggers a workspace"))
)
}, ask = FALSE)
# The following code throws an error for demonstration purposes.
try(tar_make())
# Say the workspace file for target x does not exist.
unlink("_targets/workspaces/x")
file.exists("_targets/workspaces/x")
# We can download it with tar_workspace_download()
tar_workspace_download(x)
file.exists("_targets/workspaces/x")
tar_workspace(x)
})
}