-
Notifications
You must be signed in to change notification settings - Fork 74
/
Copy pathtar_load_globals.Rd
86 lines (83 loc) · 2.89 KB
/
tar_load_globals.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tar_load_globals.R
\name{tar_load_globals}
\alias{tar_load_globals}
\title{Load globals for debugging, testing, and prototyping}
\usage{
tar_load_globals(
envir = parent.frame(),
script = targets::tar_config_get("script")
)
}
\arguments{
\item{envir}{Environment to source the target script (default: \verb{_targets.R}).
Defaults to the calling environment.}
\item{script}{Character of length 1, path to the target script file
that defines the pipeline (\verb{_targets.R} by default).
This path should be either
an absolute path or a path relative to the project root where you will
call \code{\link[=tar_make]{tar_make()}} and other functions. When \code{\link[=tar_make]{tar_make()}} and friends
run the script from the current working directory.
If the argument \code{NULL}, the setting is not modified.
Use \code{\link[=tar_config_unset]{tar_config_unset()}} to delete a setting.}
}
\value{
\code{NULL} (invisibly).
}
\description{
Load user-defined packages, functions, global objects, and
settings defined in the target script file (default: \verb{_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.
}
\details{
This function first sources the target script file
(default: \verb{_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 \code{tar_option_get("packages")} (default: \code{(.packages())})
using \code{library()} with \code{lib.loc} defined in \code{tar_option_get("library")}
(default: \code{NULL}).
}
\section{Storage access}{
Several functions like \code{tar_make()}, \code{tar_read()}, \code{tar_load()},
\code{tar_meta()}, and \code{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 \code{tarchetypes} package such as \code{tar_render()}
and \code{tar_quarto()}.
}
\examples{
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()))
})
}
}
\seealso{
Other debug:
\code{\link{tar_traceback}()},
\code{\link{tar_workspace}()},
\code{\link{tar_workspace_download}()},
\code{\link{tar_workspaces}()}
}
\concept{debug}