If you set error = "save"
in tar_option_set()
or tar_target()
, then if that target throws an error
in tar_make()
, it will save its workspace to a compressed file
in _targets/workspaces/
. The workspace includes the
target's required packages, the
global objects at the time tar_make()
was called, the
dependency targets, the random number generator seed
(assigned to .targets$seed
and set with set.seed()
)
and the traceback of the error (assigned to .targets$traceback
).
tar_workspace()
loads the packages, populates the environment
with the objects, and sets the seed to the seed of the target.
Workspace files can be large sometimes, so it is good practice to
remove them with tar_undebug()
when you are done debugging.
Although useful, this behavior does not perfectly replicate
what tar_make()
does to set up the runtime environment
for a target. tar_make()
creates a formal hierarchy of
environments that inherit from one another in order to
organize data and contain side effects.
In addition, sometimes, you may not be able to debug with
error = "save"
. Workspace files are saved with qs::qsave()
,
so if one of your dependencies cannot be properly serialized this way
(e.g. Keras models you store with format = "keras"
)
then the workspace cannot be saved properly. If this happens to you,
either avoid non-exportable objects or use interactive debugging.
(See the debug
argument of tar_option_set()
.)