Set up targets
for an existing project.
Usage
use_targets(
script = targets::tar_config_get("script"),
scheduler = targets::use_targets_scheduler(),
open = interactive(),
overwrite = FALSE,
job_name = targets::tar_random_name()
)
Arguments
- script
Character of length 1, where to write the target script file. Defaults to
tar_config_get("script")
, which in turn defaults to_targets.R
.- scheduler
Character of length 1, type of scheduler for parallel computing. See <books.ropensci.org/targets/hpc.html> for details. The default is automatically detected from your system (but PBS and Torque cannot be distinguished from SGE, and SGE is the default among the three). Possible values:
"multicore"
: local forked processes on Linux-like systems (but same as"multiprocess"
fortar_make_future()
options)."multiprocess"
: local platform-independent and multi-process."slurm"
: SLURM clusters."sge"
: Sun Grid Engine clusters."lsf"
: LSF clusters."pbs"
: PBS clusters. (batchtools
template file not available.)"torque"
: Torque clusters.
- open
Logical, whether to open the file for editing in the RStudio IDE.
- overwrite
Logical of length 1, whether to overwrite the targets file and supporting files if they already exist.
- job_name
Character of length 1, job name to supply to schedulers like SLURM.
Details
To set up a project-oriented function-oriented
workflow for targets
, use_targets()
writes:
A target script
_targets.R
tailored to your system.Template files
"clustermq.tmpl"
and"future.tmpl"
to configuretar_make_clustermq()
andtar_make_future()
to a resource manager if detected on your system. They should work out of the box on most systems, but you may need to modify them by hand if you encounter errors.Script
run.R
to conveniently execute the pipeline usingtar_make()
. You can change this totar_make_clustermq()
ortar_make_future()
and supply theworkers
argument to either.Script
run.sh
to conveniently callrun.R
in a persistent background process. Enter./run.sh
in the shell to run it.If you have a high-performance computing scheduler like Sun Grid Engine (SGE) (or select one using the
scheduler
argument ofuse_targets()
), then scriptjob.sh
is created.job.sh
conveniently executesrun.R
as a job on a cluster. For example, to run the pipeline as a job on an SGE cluster, enterqsub job.sh
in the terminal.job.sh
should work out of the box on most systems, but you may need to modify it by hand if you encounter errors.
After you call use_targets()
, there is still configuration left to do:
Open
_targets.R
and edit by hand. Follow the comments to write any options, packages, and target definitions that your pipeline requires.Edit
run.R
and choose which pipeline function to execute (tar_make()
,tar_make_clustermq()
, ortar_make_future()
).If applicable, edit
clustermq.tmpl
and/orfuture.tmpl
to configure settings for your resource manager.If applicable, configure
job.sh
,"clustermq.tmpl"
, and/or"future.tmpl"
for your resource manager.
After you finished configuring your project, follow the steps at https://books.ropensci.org/targets/walkthrough.html#inspect-the-pipeline: # nolint
Run
tar_glimpse()
andtar_manifest()
to check that the targets in the pipeline are defined correctly.Run the pipeline. You may wish to call a
tar_make*()
function directly, or you may runrun.R
orrun.sh
.Inspect the target output using
tar_read()
and/ortar_load()
.Develop the pipeline as needed by manually editing
_targets.R
and the scripts inR/
and repeating steps (1) through (3).
See also
Other help:
tar_reprex()
,
targets-package
,
use_targets_rmd()
Examples
if (identical(Sys.getenv("TAR_INTERACTIVE_EXAMPLES"), "true")) {
tar_dir({ # tar_dir() runs code from a temp dir for CRAN.
use_targets(open = FALSE)
})
}