Skip to content

targetfy v2.1

Latest

Choose a tag to compare

@Athospd Athospd released this 22 Nov 21:15

v2.1 adds the targets tools deferred from v2, and tests the paths v2 couldn't run: crew workers, Quarto, torch, keras and web inputs.

New

Scripts that render documents. A script that calls rmarkdown::render() or quarto::quarto_render() now converts to tar_render() or tar_quarto(). A loop that renders a document once per parameter set converts to tar_render_rep() or tar_quarto_rep().

  • Your document is never edited: a copy reads Targets with tar_read().
  • Tested with both R Markdown and Quarto, three reports each.

Data targets can't see change. Database and API reads (dbGetQuery(), dbReadTable(), req_perform(), GET()...) are flagged, with two options:

  • tar_change(), which reruns the read when a cheap check changes, such as a row count or max(updated_at);
  • tar_age(), which reruns it once the result is older than a set time.

The input-change check now also changes local SQLite files. With tar_change() the Pipeline passes; with a plain Target, an untracked database read fails as a hidden dependency.

renv. When the project has an renv.lock, the check lists the packages the Pipeline uses that the lockfile doesn't record. renv misses packages named as strings, as in tar_option_set(packages = "dplyr"). Two new Enhancements:

  • tar_renv(), so the next renv::snapshot() records those packages;
  • tar_github_actions(), which runs the Pipeline on GitHub on every push.

Now tested

Path Result
crew workers with tar_hook_before(): equivalent. With options() only above list(), 3 Targets mismatch, because workers never run that line
torch, keras tar_format() works. With plain RDS, the model breaks as soon as a Target reads it back from the store
format = "url" equivalent against a real URL, and not out of date right after the build. URLs are listed as inputs the input-change check can't test
Quarto tar_quarto_rep() is equivalent to a quarto_render() loop

Fixes

  • A Pipeline that fails to build now names each failing Target and its error, not just targets' generic debugging advice.
  • A document copy for a targets_<name>.R Pipeline must read from that Pipeline's store: tar_read(x, store = "_targets_<name>").
  • Quarto's <document>_files/ folder no longer counts as a mismatched output.
  • tar_render_rep(report, ...) creates a Target named report_params, so no helper may take that name.
  • Calls like knitr::opts_chunk$set() are no longer reported as display-only.

Setup notes (Windows)

  • Quarto: an app started before Quarto was installed won't see it on the PATH until it restarts.
  • keras: build r-keras from a python.org or winget Python. R can't load the Microsoft Store Python's DLL ("Access is denied"), and reticulate may pick that one on its own. install_keras() defaults to Python 3.9–3.11.
  • crew: with crew 1.3, use targets 1.9 or later.

Full test suite: 239 tests.