tar_path_target {targets} | R Documentation |
Identify the file path where a target will be stored.
Description
Identify the file path where a target will be stored after the target finishes running in the pipeline.
Usage
tar_path_target(
name = NULL,
default = NA_character_,
create_dir = FALSE,
store = targets::tar_config_get("store")
)
Arguments
name |
Symbol, name of a target.
If |
default |
Character, value to return if |
create_dir |
Logical of length 1,
whether to create |
store |
Character of length 1,
path to the data store if |
Value
Character, file path of the return value of the target.
If not called from inside a running target,
tar_path_target(name = your_target)
just returns
_targets/objects/your_target
, the file path where your_target
will be saved unless format
is equal to "file"
or any of the
supported cloud-based storage formats.
For non-cloud storage formats, if you call tar_path_target()
with no arguments while target x
is running, the name
argument defaults to the name of the running target,
so tar_path_target()
returns _targets/objects/x
.
For cloud-backed formats, tar_path_target()
returns the
path to the staging file in _targets/scratch/
.
That way, even if you select a cloud repository
(e.g. tar_target(..., repository = "aws", storage = "none")
)
then you can still manually write to
tar_path_target(create_dir = TRUE)
and the targets
package will automatically hash it and
upload it to the AWS S3 bucket. This does not apply to
format = "file"
, where you would never need storage = "none"
anyway.
See Also
Other utilities:
tar_active()
,
tar_backoff()
,
tar_call()
,
tar_cancel()
,
tar_definition()
,
tar_described_as()
,
tar_envir()
,
tar_group()
,
tar_name()
,
tar_path()
,
tar_path_script()
,
tar_path_script_support()
,
tar_path_store()
,
tar_source()
,
tar_store()
Examples
tar_path_target()
tar_path_target(your_target)
if (identical(Sys.getenv("TAR_EXAMPLES"), "true")) { # for CRAN
tar_dir({ # tar_dir() runs code from a temp dir for CRAN.
tar_script(tar_target(returns_path, tar_path_target()), ask = FALSE)
tar_make()
tar_read(returns_path)
})
}