build_setup_pipeline rewrites the remake.yml file to include new studies.

build_setup_pipeline(
  dataset_ids = dir("data"),
  method = "base",
  database_name = "database",
  template = select_pipeline_template(method),
  workers = 1
)

Arguments

dataset_ids

dataset_id's to include; by default includes all

method

Approach to use in build. "base" writes a plain build.R that rebuilds everything; "furrr" does the same in parallel; "remake" and "targets" write a pipeline that caches, so that editing one dataset rebuilds only that dataset. "targets" is the maintained, CRAN-available option of the two.

database_name

Name of database to be built

template

Template used to build

workers

Number of workers/parallel processes to use when using method = "furrr" or method = "targets"

Value

Updated pipeline file: build.R for "base" and "furrr", remake.yml for "remake", _targets.R for "targets"

Using the targets pipeline

method = "targets" writes _targets.R, and building from it is three steps rather than one. The other three methods return the database from a single call, so the habits they teach do not carry over:

build_setup_pipeline(method = "targets", database_name = "austraits")
targets::tar_make()                       # rebuild the compilation
austraits <- targets::tar_read(austraits) # load it into your session
build_export("austraits")                 # write export/data/curr

targets::tar_make() returns nothing. It builds into the _targets/ store and prints what it did, so the direct translation of austraits <- remake::make("austraits") leaves you holding NULL. Use targets::tar_read() to read the built compilation back.

tar_make() also does not write export/data/curr. That write is around a third of a one-dataset rebuild and is a publishing step rather than part of checking a dataset, so build_export() does it when it is wanted. Pass build_export() the same database_name given here.

tar_make() prints two lines per target, several hundred on a large compilation, and in the order its scheduler reaches them rather than alphabetically. Neither is adjustable: targets collapses only dynamic branches into a progress bar, and it deprecated target priorities in 1.10.1 when it moved to the current scheduler, so execution order is no longer controllable. targets::tar_make(reporter = "silent") builds quietly, and targets::tar_config_set(reporter_make = "silent") sets that for the repository.

Post-build step

Every pipeline calls build_post_process() after build_add_version() and before the database is saved. It runs post_build() from R/post_build.R if the repository has that file, and otherwise does nothing, so the call is written whether or not the file exists and adding one later needs no change to the pipeline. targets notices the file being added, edited or deleted. remake cannot depend on a file that may not exist, so it tracks R/post_build.R only if the file existed when the pipeline was set up: re-run build_setup_pipeline() after adding or removing it, as after adding a dataset.

Because it runs on every rebuild of the combined database, post_build() should be quick. Outputs wanted only when the database is published, such as a flattened copy or parquet files, go in post_export() in R/post_export.R, which no pipeline runs: build_post_export() runs it, from a repository's release script, and so does build_export() after a targets build.