View source: R/tar_load_globals.R
tar_load_globals | R Documentation |
Load user-defined packages, functions, global objects, and
settings defined in the target script file (default: _targets.R
).
This function is for debugging, testing, and prototyping only.
It is not recommended for use inside a serious pipeline
or to report the results of a serious pipeline.
tar_load_globals(
envir = parent.frame(),
script = targets::tar_config_get("script")
)
envir |
Environment to source the target script (default: |
script |
Character of length 1, path to the target script file
that defines the pipeline ( |
This function first sources the target script file
(default: _targets.R
)
to loads all user-defined functions, global objects, and settings
into the current R process. Then, it loads all the packages defined
in tar_option_get("packages")
(default: (.packages())
)
using library()
with lib.loc
defined in tar_option_get("library")
(default: NULL
).
NULL
(invisibly).
Several functions like tar_make()
, tar_read()
, tar_load()
,
tar_meta()
, and tar_progress()
read or modify
the local data store of the pipeline.
The local data store is in flux while a pipeline is running,
and depending on how distributed computing or cloud computing is set up,
not all targets can even reach it. So please do not call these
functions from inside a target as part of a running
pipeline. The only exception is literate programming
target factories in the tarchetypes
package such as tar_render()
and tar_quarto()
.
Other debug:
tar_traceback()
,
tar_workspace()
,
tar_workspaces()
if (identical(Sys.getenv("TAR_EXAMPLES"), "true")) { # for CRAN
tar_dir({ # tar_dir() runs code from a temp dir for CRAN.
tar_script({
library(targets)
library(tarchetypes)
tar_option_set(packages = "callr")
analyze_data <- function(data) {
summary(data)
}
list(
tar_target(x, 1 + 1),
tar_target(y, 1 + 1)
)
}, ask = FALSE)
tar_load_globals()
print(analyze_data)
print("callr" %in% (.packages()))
})
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.