From a02baace1fcea12141a5715821f3ff8c69394a9d Mon Sep 17 00:00:00 2001 From: mutlusun Date: Sat, 12 Oct 2024 20:03:30 +0200 Subject: [PATCH 01/17] fix(quarto-files): correctly detect source files Previously, all input files were regarded as source files. However, this might be wrong: In quarto, other files can be imported via `{< inlucde file.qmd >}`. Thus, these file don't have to contain code cells. In addition, included files that contained code cells were not added to the list of source files (even though the might contain `tar_read` statements). --- R/tar_quarto_files.R | 73 +++++++++++++--- tests/testthat/test-tar_quarto_files.R | 114 +++++++++++++++++++++++-- 2 files changed, 168 insertions(+), 19 deletions(-) diff --git a/R/tar_quarto_files.R b/R/tar_quarto_files.R index ad6cef8..116c97a 100644 --- a/R/tar_quarto_files.R +++ b/R/tar_quarto_files.R @@ -59,7 +59,33 @@ tar_quarto_files <- function(path = ".", profile = NULL) { tar_quarto_files_document <- function(path) { info <- quarto::quarto_inspect(input = path) - out <- list(sources = path) + out <- list() + + # Collect data about source files. `fileInformation` contains the main file + # and the respective `codeCells` entry contains all code cells from the files. + for (myfile in names(info$fileInformation)) { + df <- info$fileInformation[[myfile]]$codeCells + + # If `codeCells` is empty, we get an empty list. + if (!is.data.frame(df)) { + next + } + + # Check whether the codecells in `df` contain either `tar_read` or + # `tar_load`. + relevant_lines <- c( + grep("tar_read", df$source, fixed = TRUE), + grep("tar_load", df$source, fixed = TRUE) + ) |> + unique() + + # Select corresponding files. + # codeCells paths are always absolute. + out$sources <- c( + out$sources, + df[relevant_lines, "file"] + ) + } # Collect data about output files. for (format in info$formats) { @@ -97,16 +123,41 @@ tar_quarto_files_project <- function(path) { ) ) - # Detect source files. - sources <- info$files$input[file.exists(info$files$input)] + out <- list(output = file.path(path, info$config$project$`output-dir`)) + + # Collect data about source files. `fileInformation` contains the main file + # and the respective `codeCells` entry contains all code cells from the files. + for (myfile in names(info$fileInformation)) { + df <- info$fileInformation[[myfile]]$codeCells + + # If `codeCells` is empty, we get an empty list. + if (!is.data.frame(df)) { + next + } + + # Check whether the codecells in `df` contain either `tar_read` or + # `tar_load`. + relevant_lines <- c( + grep("tar_read", df$source, fixed = TRUE), + grep("tar_load", df$source, fixed = TRUE) + ) |> + unique() + + # Select corresponding files. + # codeCells paths are always absolute. + out$sources <- c( + out$sources, + df[relevant_lines, "file"] + ) + } # Detect input files. - input <- info$files - input <- unlist(input) - input <- input[file.exists(input)] + out$input <- info$files + out$input <- unlist(out$input) + out$input <- out$input[file.exists(out$input)] for (myfile in names(info$fileInformation)) { - input <- c( - input, + out$input <- c( + out$input, # `myfile` is an absolute path. myfile, # `includeMap` files are relative starting from `myfile`. @@ -117,9 +168,5 @@ tar_quarto_files_project <- function(path) { ) } - list( - sources = sources, - output = file.path(path, info$config$project$`output-dir`), - input = input - ) + out } diff --git a/tests/testthat/test-tar_quarto_files.R b/tests/testthat/test-tar_quarto_files.R index 271c8e6..b53c079 100644 --- a/tests/testthat/test-tar_quarto_files.R +++ b/tests/testthat/test-tar_quarto_files.R @@ -14,7 +14,7 @@ targets::tar_test("tar_quarto_files() single Rmd/qmd", { path <- file.path("x", paste0("report", ext)) writeLines(lines, path) out <- tar_quarto_files(path) - expect_equal(out$sources, file.path("x", paste0("report", ext))) + expect_equal(out$sources, character(0)) expect_equal(out$output, file.path("x", "report.html")) expect_equal(out$input, file.path("x", paste0("report", ext))) } @@ -106,9 +106,9 @@ targets::tar_test("tar_quarto_files() detects non-code dependencies", { "Some text here." ) writeLines(lines, file.path("report", "subdir", "text2.qmd")) - out <- tar_quarto_files("report/main.qmd") - expect_equal(out$sources, "report/main.qmd") - expect_equal(out$output, "report/main.html") + out <- tar_quarto_files(file.path("report", "main.qmd")) + expect_equal(out$sources, character(0)) + expect_equal(out$output, file.path("report", "main.html")) expect_equal( sort(out$input), sort( @@ -129,14 +129,116 @@ targets::tar_test("tar_quarto_files() detects non-code dependencies", { writeLines(lines, file.path("report", "_quarto.yml")) out <- tar_quarto_files("report/") if (identical(tolower(Sys.info()[["sysname"]]), "windows")) { - expect_equal(basename(out$sources), "main.qmd") + expect_equal(basename(out$sources), character(0)) + expect_equal(basename(out$output), "myoutdir") + expect_equal( + sort(basename(out$input)), + sort(c("_quarto.yml", "main.qmd", "text1.qmd", "text2.qmd")) + ) + } else { + expect_equal(out$sources, character(0)) + expect_equal(out$output, file.path("report", "myoutdir")) + expect_equal( + sort(out$input), + sort( + c( + file.path( + "report", + c("_quarto.yml", "main.qmd", "text1.qmd") + ), + file.path("report", "subdir", "text2.qmd") + ) + ) + ) + } +}) + +targets::tar_test("tar_quarto_files() detects custom output file", { + skip_quarto() + lines <- c( + "---", + "title: source file", + "format:", + " html:", + " output-file: custom.html", + "---", + "Assume these lines are in report.qmd.", + "```{r}", + "1 + 1", + "```" + ) + writeLines(lines, "report.qmd") + out <- tar_quarto_files("report.qmd") + expect_equal(out$sources, character(0)) + expect_equal(out$output, "custom.html") + expect_equal(out$input, "report.qmd") +}) + +targets::tar_test("tar_quarto_files() detects code dependencies", { + skip_quarto() + fs::dir_create("report") + fs::dir_create(file.path("report", "subdir")) + lines <- c( + "---", + "title: main", + "output_format: html", + "---", + "", + "{{< include \"text1.qmd\" >}}", + "", + "{{< include \"subdir/text2.qmd\" >}}" + ) + writeLines(lines, file.path("report", "main.qmd")) + lines <- c( + "# First File", + "", + "Contains a code cell.", + "", + "```{r}", + "1 + 1", + "```" + ) + writeLines(lines, file.path("report", "text1.qmd")) + lines <- c( + "# Second File", + "", + "Contains a code cell with a call to `tar_read`.", + "", + "```{r}", + "targets::tar_read(mytarget)", + "```" + ) + writeLines(lines, file.path("report", "subdir", "text2.qmd")) + out <- tar_quarto_files("report/main.qmd") + expect_equal(out$sources, file.path("report", "subdir", "text2.qmd")) + expect_equal(out$output, file.path("report", "main.html")) + expect_equal( + sort(out$input), + sort( + c( + file.path("report", c("main.qmd", "text1.qmd")), + file.path("report", "subdir", "text2.qmd") + ) + ) + ) + # Check whether we get the same result when calling via a project. + lines <- c( + "project:", + " output-dir: myoutdir", + " render:", + " - main.qmd" + ) + writeLines(lines, file.path("report", "_quarto.yml")) + out <- tar_quarto_files("report/") + if (identical(tolower(Sys.info()[["sysname"]]), "windows")) { + expect_equal(basename(out$sources), "text2.qmd") expect_equal(basename(out$output), "myoutdir") expect_equal( sort(basename(out$input)), sort(c("_quarto.yml", "main.qmd", "text1.qmd", "text2.qmd")) ) } else { - expect_equal(out$sources, file.path("report", "main.qmd")) + expect_equal(out$sources, file.path("report", "subdir", "text2.qmd")) expect_equal(out$output, file.path("report", "myoutdir")) expect_equal( sort(out$input), From f3491ce94491bd18842cb2699b773a4014ff7392 Mon Sep 17 00:00:00 2001 From: mutlusun Date: Sat, 12 Oct 2024 21:00:44 +0200 Subject: [PATCH 02/17] refactor(quarto-files): deduplicate code and move code into its own function. --- R/tar_quarto_files.R | 87 ++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 48 deletions(-) diff --git a/R/tar_quarto_files.R b/R/tar_quarto_files.R index 116c97a..7e8efae 100644 --- a/R/tar_quarto_files.R +++ b/R/tar_quarto_files.R @@ -61,31 +61,8 @@ tar_quarto_files_document <- function(path) { info <- quarto::quarto_inspect(input = path) out <- list() - # Collect data about source files. `fileInformation` contains the main file - # and the respective `codeCells` entry contains all code cells from the files. - for (myfile in names(info$fileInformation)) { - df <- info$fileInformation[[myfile]]$codeCells - - # If `codeCells` is empty, we get an empty list. - if (!is.data.frame(df)) { - next - } - - # Check whether the codecells in `df` contain either `tar_read` or - # `tar_load`. - relevant_lines <- c( - grep("tar_read", df$source, fixed = TRUE), - grep("tar_load", df$source, fixed = TRUE) - ) |> - unique() - - # Select corresponding files. - # codeCells paths are always absolute. - out$sources <- c( - out$sources, - df[relevant_lines, "file"] - ) - } + # Collect data about source files. + out$sources <- tar_quarto_files_get_source_files(info$fileInformation) # Collect data about output files. for (format in info$formats) { @@ -125,10 +102,41 @@ tar_quarto_files_project <- function(path) { out <- list(output = file.path(path, info$config$project$`output-dir`)) - # Collect data about source files. `fileInformation` contains the main file - # and the respective `codeCells` entry contains all code cells from the files. + # Collect data about source files. + out$sources <- tar_quarto_files_get_source_files(info$fileInformation) + + # Detect input files. + out$input <- info$files + out$input <- unlist(out$input) + out$input <- out$input[file.exists(out$input)] for (myfile in names(info$fileInformation)) { - df <- info$fileInformation[[myfile]]$codeCells + out$input <- c( + out$input, + # `myfile` is an absolute path. + myfile, + # `includeMap` files are relative starting from `myfile`. + file.path( + dirname(myfile), + info$fileInformation[[myfile]]$includeMap$target + ) + ) + } + + out +} + +#' Get Source Files From Quarto Inspect +#' +#' @description Collects files with `tar_read` or `tar_load` from the +#' `fileInformation` field. +#' +#' @details `fileInformation` contains the input files and the respective +#' `codeCells` entry contains all code cells with corresponding included files. +tar_quarto_files_get_source_files <- function(file_information) { + ret <- character(0) + + for (myfile in names(file_information)) { + df <- file_information[[myfile]]$codeCells # If `codeCells` is empty, we get an empty list. if (!is.data.frame(df)) { @@ -145,28 +153,11 @@ tar_quarto_files_project <- function(path) { # Select corresponding files. # codeCells paths are always absolute. - out$sources <- c( - out$sources, + ret <- c( + ret, df[relevant_lines, "file"] ) } - # Detect input files. - out$input <- info$files - out$input <- unlist(out$input) - out$input <- out$input[file.exists(out$input)] - for (myfile in names(info$fileInformation)) { - out$input <- c( - out$input, - # `myfile` is an absolute path. - myfile, - # `includeMap` files are relative starting from `myfile`. - file.path( - dirname(myfile), - info$fileInformation[[myfile]]$includeMap$target - ) - ) - } - - out + ret } From e5fb3bf273bbd2e6cb40a9c3228923b18a753073 Mon Sep 17 00:00:00 2001 From: mutlusun Date: Sat, 12 Oct 2024 21:01:56 +0200 Subject: [PATCH 03/17] fix(quarto-files): simplify input file detection In the project case, the config file is the only missing file in `fileInformation`. Thus, we can simplify the code and only add the config file to the `source` vector. All other files are handled via the `fileInformation` loop. --- R/tar_quarto_files.R | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/R/tar_quarto_files.R b/R/tar_quarto_files.R index 7e8efae..a5ac5d6 100644 --- a/R/tar_quarto_files.R +++ b/R/tar_quarto_files.R @@ -106,9 +106,7 @@ tar_quarto_files_project <- function(path) { out$sources <- tar_quarto_files_get_source_files(info$fileInformation) # Detect input files. - out$input <- info$files - out$input <- unlist(out$input) - out$input <- out$input[file.exists(out$input)] + out$input <- info$files$config for (myfile in names(info$fileInformation)) { out$input <- c( out$input, From bbf96f6d3993d3002fb1e78675963d881a23edea Mon Sep 17 00:00:00 2001 From: mutlusun Date: Sun, 13 Oct 2024 07:47:03 +0200 Subject: [PATCH 04/17] test(quarto-files): fix failing test on windows --- tests/testthat/test-tar_quarto_files.R | 27 +++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/tests/testthat/test-tar_quarto_files.R b/tests/testthat/test-tar_quarto_files.R index b53c079..4a1fb70 100644 --- a/tests/testthat/test-tar_quarto_files.R +++ b/tests/testthat/test-tar_quarto_files.R @@ -210,17 +210,26 @@ targets::tar_test("tar_quarto_files() detects code dependencies", { ) writeLines(lines, file.path("report", "subdir", "text2.qmd")) out <- tar_quarto_files("report/main.qmd") - expect_equal(out$sources, file.path("report", "subdir", "text2.qmd")) - expect_equal(out$output, file.path("report", "main.html")) - expect_equal( - sort(out$input), - sort( - c( - file.path("report", c("main.qmd", "text1.qmd")), - file.path("report", "subdir", "text2.qmd") + if (identical(tolower(Sys.info()[["sysname"]]), "windows")) { + expect_equal(basename(out$sources), "text2.qmd") + expect_equal(basename(out$output), "main.html") + expect_equal( + sort(basename(out$input)), + sort(c("main.qmd", "text1.qmd", "text2.qmd")) + ) + } else { + expect_equal(out$sources, file.path("report", "subdir", "text2.qmd")) + expect_equal(out$output, file.path("report", "main.html")) + expect_equal( + sort(out$input), + sort( + c( + file.path("report", c("main.qmd", "text1.qmd")), + file.path("report", "subdir", "text2.qmd") + ) ) ) - ) + } # Check whether we get the same result when calling via a project. lines <- c( "project:", From 2379445d60910c8b9e21fa5031235d2b2dd8842e Mon Sep 17 00:00:00 2001 From: mutlusun Date: Sun, 13 Oct 2024 07:48:06 +0200 Subject: [PATCH 05/17] test(quarto): extend tests for quarto --- tests/testthat/test-tar_quarto.R | 108 +++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/tests/testthat/test-tar_quarto.R b/tests/testthat/test-tar_quarto.R index f4a8654..02540d9 100644 --- a/tests/testthat/test-tar_quarto.R +++ b/tests/testthat/test-tar_quarto.R @@ -482,3 +482,111 @@ targets::tar_test("tar_quarto() creates custom output file", { expect_false(file.exists(file.path("report.html"))) expect_true(file.exists(file.path("test.html"))) }) + +targets::tar_test("tar_quarto() reruns if target changes in included file", { + skip_quarto() + lines <- c( + "---", + "title: main", + "output_format: html", + "---", + "", + "{{< include \"file1.qmd\" >}}" + ) + writeLines(lines, "main.qmd") + lines <- c( + "# First File", + "", + "Contains a code cell with a target.", + "", + "```{r}", + "targets::tar_read(data)", + "```" + ) + writeLines(lines, "file1.qmd") + targets::tar_script({ + library(tarchetypes) + list( + tar_target(data, data.frame(x = seq_len(26L), y = letters)), + tar_quarto(report, path = "main.qmd") + ) + }) + # First run. + suppressMessages(targets::tar_make(callr_function = NULL)) + progress <- targets::tar_progress() + progress <- progress[progress$progress != "skipped", ] + expect_equal(sort(progress$name), sort(c("data", "report"))) + out <- targets::tar_read(report) + out <- setdiff(out, "main_files") + expect_equal(sort(basename(out)), sort(c("main.html", "main.qmd", "file1.qmd"))) + # Should not rerun the report. + suppressMessages(targets::tar_make(callr_function = NULL)) + progress <- targets::tar_progress() + progress <- progress[progress$progress != "skipped", ] + expect_equal(nrow(progress), 0L) + # Should rerun the report. + targets::tar_script({ + library(tarchetypes) + list( + tar_target(data, data.frame(x = rev(seq_len(26L)), y = letters)), + tar_quarto(report, path = "main.qmd") + ) + }) + suppressMessages(targets::tar_make(callr_function = NULL)) + expect_equal(sort(targets::tar_progress()$name), sort(c("data", "report"))) +}) + +targets::tar_test("tar_quarto() reruns if an included file changes", { + skip_quarto() + lines <- c( + "---", + "title: main", + "output_format: html", + "---", + "", + "{{< include \"file1.qmd\" >}}" + ) + writeLines(lines, "main.qmd") + lines <- c( + "# First File", + "", + "Includes another file.", + "", + "{{< include \"file2.qmd\" >}}" + ) + writeLines(lines, "file1.qmd") + lines <- c( + "# Second File", + "", + "Does not include another file." + ) + writeLines(lines, "file2.qmd") + targets::tar_script({ + library(tarchetypes) + list( + tar_quarto(report, path = "main.qmd") + ) + }) + # First run. + suppressMessages(targets::tar_make(callr_function = NULL)) + progress <- targets::tar_progress() + progress <- progress[progress$progress != "skipped", ] + expect_equal(sort(progress$name), sort(c("report"))) + out <- targets::tar_read(report) + out <- setdiff(out, "main_files") + expect_equal(sort(basename(out)), sort(c("main.html", "main.qmd", "file1.qmd", "file2.qmd"))) + # Should not rerun the report. + suppressMessages(targets::tar_make(callr_function = NULL)) + progress <- targets::tar_progress() + progress <- progress[progress$progress != "skipped", ] + expect_equal(nrow(progress), 0L) + # Should rerun the report. + lines <- c( + "# Second File", + "", + "A change to the second file." + ) + writeLines(lines, "file2.qmd") + suppressMessages(targets::tar_make(callr_function = NULL)) + expect_equal(sort(targets::tar_progress()$name), sort(c("report"))) +}) From 153e9ff8fa8fccd4c199cdc89150e4e87eb6a1ad Mon Sep 17 00:00:00 2001 From: mutlusun Date: Mon, 14 Oct 2024 07:23:39 +0200 Subject: [PATCH 06/17] docs(quarto): extend comments in quarto files --- R/tar_quarto_files.R | 8 ++++++-- tests/testthat/test-tar_quarto_files.R | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/R/tar_quarto_files.R b/R/tar_quarto_files.R index a5ac5d6..5b7b8c8 100644 --- a/R/tar_quarto_files.R +++ b/R/tar_quarto_files.R @@ -72,13 +72,17 @@ tar_quarto_files_document <- function(path) { ) } - # Collect data about input files. + # Collect data about input files. It seems that quarto only puts the main + # rendering file (in this case `path`) into `fileInformation`. Even though + # included files might include other files, they still appear in + # `includeMap$target` and not as an own `fileInformation` entry. for (myfile in names(info$fileInformation)) { out$input <- c( out$input, # `myfile` are relative paths starting from `path`. myfile, - # `includeMap` contains relative paths starting from `myfile`. + # `includeMap` contains relative paths starting from `myfile`. We can use + # `dirname(path)` here as this is the directory of `myfile`. file.path( dirname(path), info$fileInformation[[myfile]]$includeMap$target diff --git a/tests/testthat/test-tar_quarto_files.R b/tests/testthat/test-tar_quarto_files.R index 4a1fb70..63d766f 100644 --- a/tests/testthat/test-tar_quarto_files.R +++ b/tests/testthat/test-tar_quarto_files.R @@ -89,15 +89,15 @@ targets::tar_test("tar_quarto_files() detects non-code dependencies", { "output_format: html", "---", "", - "{{< include \"text1.qmd\" >}}", - "", - "{{< include \"subdir/text2.qmd\" >}}" + "{{< include \"text1.qmd\" >}}" ) writeLines(lines, file.path("report", "main.qmd")) lines <- c( "# First File", "", - "Some text here." + "Some text here.", + "", + "{{< include \"subdir/text2.qmd\" >}}" ) writeLines(lines, file.path("report", "text1.qmd")) lines <- c( From c750cc4eb2104dd18c6250ca179755d54e246f75 Mon Sep 17 00:00:00 2001 From: mutlusun Date: Tue, 29 Oct 2024 10:51:09 +0100 Subject: [PATCH 07/17] fix(quarto/files): try to identify duplicates in files --- R/tar_quarto_files.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/tar_quarto_files.R b/R/tar_quarto_files.R index 5b7b8c8..284bbbb 100644 --- a/R/tar_quarto_files.R +++ b/R/tar_quarto_files.R @@ -51,8 +51,8 @@ tar_quarto_files <- function(path = ".", profile = NULL) { tar_quarto_files_document(path) ) for (field in c("sources", "output", "input")) { - out[[field]] <- sort(fs::path_rel(unique(as.character(out[[field]])))) - out[[field]] <- as.character(out[[field]]) + out[[field]] <- as.character(fs::path_rel(out[[field]])) + out[[field]] <- unique(sort(out[[field]])) } out } From 0d0fe300d437dd0fa192d2c4a0349550c68595d4 Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 30 Oct 2024 21:26:50 +0100 Subject: [PATCH 08/17] test(quarto): fix ci running on windows --- tests/testthat/test-tar_quarto.R | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-tar_quarto.R b/tests/testthat/test-tar_quarto.R index 02540d9..dd3ba59 100644 --- a/tests/testthat/test-tar_quarto.R +++ b/tests/testthat/test-tar_quarto.R @@ -518,7 +518,19 @@ targets::tar_test("tar_quarto() reruns if target changes in included file", { expect_equal(sort(progress$name), sort(c("data", "report"))) out <- targets::tar_read(report) out <- setdiff(out, "main_files") - expect_equal(sort(basename(out)), sort(c("main.html", "main.qmd", "file1.qmd"))) + if (identical(tolower(Sys.info()[["sysname"]]), "windows")) { + expect_equal( + # On the windows CI, there seems to be issues and `fs::path_rel`. Because + # of that, `file1.qmd` is returned twice and we use `unique` here. On + # other platforms this issue does not exist. + # + # See https://github.com/ropensci/tarchetypes/pull/200 for a discussion. + sort(unique(basename(out))), + sort(c("main.html", "main.qmd", "file1.qmd")) + ) + } else { + expect_equal(sort(basename(out)), sort(c("main.html", "main.qmd", "file1.qmd"))) + } # Should not rerun the report. suppressMessages(targets::tar_make(callr_function = NULL)) progress <- targets::tar_progress() From 79de6ebf9a0a5e1cd64c0ed792154770edf1ff8b Mon Sep 17 00:00:00 2001 From: mutlusun Date: Tue, 5 Nov 2024 09:09:53 +0100 Subject: [PATCH 09/17] fix(quarto/files): remove native pipe usage --- R/tar_quarto_files.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/tar_quarto_files.R b/R/tar_quarto_files.R index 284bbbb..739bcd5 100644 --- a/R/tar_quarto_files.R +++ b/R/tar_quarto_files.R @@ -150,8 +150,8 @@ tar_quarto_files_get_source_files <- function(file_information) { relevant_lines <- c( grep("tar_read", df$source, fixed = TRUE), grep("tar_load", df$source, fixed = TRUE) - ) |> - unique() + ) + relevant_lines <- unique(relevant_lines) # Select corresponding files. # codeCells paths are always absolute. From 0dd95689eeb12821891f8972199534322aca3925 Mon Sep 17 00:00:00 2001 From: mutlusun Date: Tue, 5 Nov 2024 09:26:56 +0100 Subject: [PATCH 10/17] format(tests/quarto): fix lintr lints regarding line length --- tests/testthat/test-tar_quarto.R | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-tar_quarto.R b/tests/testthat/test-tar_quarto.R index dd3ba59..3b90dee 100644 --- a/tests/testthat/test-tar_quarto.R +++ b/tests/testthat/test-tar_quarto.R @@ -529,7 +529,10 @@ targets::tar_test("tar_quarto() reruns if target changes in included file", { sort(c("main.html", "main.qmd", "file1.qmd")) ) } else { - expect_equal(sort(basename(out)), sort(c("main.html", "main.qmd", "file1.qmd"))) + expect_equal( + sort(basename(out)), + sort(c("main.html", "main.qmd", "file1.qmd")) + ) } # Should not rerun the report. suppressMessages(targets::tar_make(callr_function = NULL)) @@ -586,7 +589,10 @@ targets::tar_test("tar_quarto() reruns if an included file changes", { expect_equal(sort(progress$name), sort(c("report"))) out <- targets::tar_read(report) out <- setdiff(out, "main_files") - expect_equal(sort(basename(out)), sort(c("main.html", "main.qmd", "file1.qmd", "file2.qmd"))) + expect_equal( + sort(basename(out)), + sort(c("main.html", "main.qmd", "file1.qmd", "file2.qmd")) + ) # Should not rerun the report. suppressMessages(targets::tar_make(callr_function = NULL)) progress <- targets::tar_progress() From 6108ec076a7f43e404a34537c3a7c663a6d7dcd8 Mon Sep 17 00:00:00 2001 From: mutlusun Date: Fri, 8 Nov 2024 13:03:48 +0100 Subject: [PATCH 11/17] fix(quarto/files): correctly detect source files --- R/tar_quarto_files.R | 45 ++++++------ tests/testthat/test-tar_quarto_files.R | 97 +++++++++++++++++++++----- 2 files changed, 101 insertions(+), 41 deletions(-) diff --git a/R/tar_quarto_files.R b/R/tar_quarto_files.R index 739bcd5..37302d9 100644 --- a/R/tar_quarto_files.R +++ b/R/tar_quarto_files.R @@ -129,37 +129,38 @@ tar_quarto_files_project <- function(path) { #' Get Source Files From Quarto Inspect #' -#' @description Collects files with `tar_read` or `tar_load` from the -#' `fileInformation` field. +#' @description Collects all files from the +#' `fileInformation` field that are used in the current report. #' -#' @details `fileInformation` contains the input files and the respective -#' `codeCells` entry contains all code cells with corresponding included files. +#' @details `fileInformation` contains a list of files. Each file entry contains +#' two data frames. The first, `includeMap`, contains a `source` column (files +#' that include other files, e.g. the main report file) and a `target` column +#' (files that get included by the `source` files). The `codeCells` data frame +#' contains all code cells from the files represented in `includeMap`. tar_quarto_files_get_source_files <- function(file_information) { ret <- character(0) for (myfile in names(file_information)) { - df <- file_information[[myfile]]$codeCells - - # If `codeCells` is empty, we get an empty list. - if (!is.data.frame(df)) { - next - } - - # Check whether the codecells in `df` contain either `tar_read` or - # `tar_load`. - relevant_lines <- c( - grep("tar_read", df$source, fixed = TRUE), - grep("tar_load", df$source, fixed = TRUE) - ) - relevant_lines <- unique(relevant_lines) - - # Select corresponding files. - # codeCells paths are always absolute. + # Collect relevant source files. The files in `includeMap$target` are always + # relative to the main entry point of the report. Thus, we need to add the + # corresponding paths to the entries. + # + # We don't need to include the `source` column as all files are also present + # in `target` or are `myfile`. ret <- c( ret, - df[relevant_lines, "file"] + myfile, + file.path( + dirname(myfile), + file_information[[myfile]]$includeMap$target + ) ) } + # Check that these files actually exist. + ret <- ret[file.exists(ret)] + + # We don't need to call `unique` here on `ret` as this happens on the main + # function. ret } diff --git a/tests/testthat/test-tar_quarto_files.R b/tests/testthat/test-tar_quarto_files.R index 63d766f..3f5136b 100644 --- a/tests/testthat/test-tar_quarto_files.R +++ b/tests/testthat/test-tar_quarto_files.R @@ -56,21 +56,14 @@ targets::tar_test("tar_quarto_files() project", { ) writeLines(lines, file.path("x", "r2.qmd")) info <- tar_quarto_files("x") + expect_equal(info$sources, character()) if (identical(tolower(Sys.info()[["sysname"]]), "windows")) { - expect_equal( - sort(basename(info$sources)), - sort(c("index.qmd", "r2.qmd")) - ) expect_equal(basename(info$output), "_book") expect_equal( sort(basename(info$input)), sort(c("_quarto.yml", "index.qmd", "r2.qmd")) ) } else { - expect_equal( - sort(info$sources), - sort(file.path("x", c("index.qmd", "r2.qmd"))) - ) expect_equal(info$output, file.path("x", "_book")) expect_equal( sort(info$input), @@ -83,6 +76,7 @@ targets::tar_test("tar_quarto_files() detects non-code dependencies", { skip_quarto() fs::dir_create("report") fs::dir_create(file.path("report", "subdir")) + fs::dir_create(file.path("report", "subdir", "b")) lines <- c( "---", "title: main", @@ -103,40 +97,83 @@ targets::tar_test("tar_quarto_files() detects non-code dependencies", { lines <- c( "# Second File", "", - "Some text here." + "Some text here.", + "", + "{{< include \"subdir/b/text3.qmd\" >}}" ) writeLines(lines, file.path("report", "subdir", "text2.qmd")) + lines <- c( + "# Third File", + "", + "Some text here." + ) + writeLines(lines, file.path("report", "subdir", "b", "text3.qmd")) + lines <- c( + "# Fourth File", + "", + "Some text here." + ) + writeLines(lines, file.path("report", "subdir", "b", "text4.qmd")) out <- tar_quarto_files(file.path("report", "main.qmd")) - expect_equal(out$sources, character(0)) + expect_equal( + sort(out$sources), + sort( + c( + file.path("report", "text1.qmd"), + file.path("report", "subdir", "text2.qmd"), + file.path("report", "subdir", "b", "text3.qmd") + ) + ) + ) expect_equal(out$output, file.path("report", "main.html")) expect_equal( sort(out$input), sort( c( file.path("report", c("main.qmd", "text1.qmd")), - file.path("report", "subdir", "text2.qmd") + file.path("report", "subdir", "text2.qmd"), + file.path("report", "subdir", "b", "text3.qmd") ) ) ) # Check whether we get the same result with a reference to the directory - # instead of the file. + # instead of the file (render a project). lines <- c( "project:", " output-dir: myoutdir", " render:", - " - main.qmd" + " - main.qmd", + " - subdir/b/text4.qmd" ) writeLines(lines, file.path("report", "_quarto.yml")) out <- tar_quarto_files("report/") if (identical(tolower(Sys.info()[["sysname"]]), "windows")) { - expect_equal(basename(out$sources), character(0)) + expect_equal( + basename(out$sources), + sort( + c( + file.path("report", "text1.qmd"), + file.path("report", "subdir", "text2.qmd"), + file.path("report", "subdir", "b", "text3.qmd") + ) + ) + ) expect_equal(basename(out$output), "myoutdir") expect_equal( sort(basename(out$input)), sort(c("_quarto.yml", "main.qmd", "text1.qmd", "text2.qmd")) ) } else { - expect_equal(out$sources, character(0)) + expect_equal( + out$sources, + sort( + c( + file.path("report", "text1.qmd"), + file.path("report", "subdir", "text2.qmd"), + file.path("report", "subdir", "b", "text3.qmd") + ) + ) + ) expect_equal(out$output, file.path("report", "myoutdir")) expect_equal( sort(out$input), @@ -211,14 +248,25 @@ targets::tar_test("tar_quarto_files() detects code dependencies", { writeLines(lines, file.path("report", "subdir", "text2.qmd")) out <- tar_quarto_files("report/main.qmd") if (identical(tolower(Sys.info()[["sysname"]]), "windows")) { - expect_equal(basename(out$sources), "text2.qmd") + expect_equal( + sort(basename(out$sources)), + sort("text1.qmd", "text2.qmd") + ) expect_equal(basename(out$output), "main.html") expect_equal( sort(basename(out$input)), sort(c("main.qmd", "text1.qmd", "text2.qmd")) ) } else { - expect_equal(out$sources, file.path("report", "subdir", "text2.qmd")) + expect_equal( + out$sources, + sort( + c( + file.path("report", "text1.qmd"), + file.path("report", "subdir", "text2.qmd") + ) + ) + ) expect_equal(out$output, file.path("report", "main.html")) expect_equal( sort(out$input), @@ -240,14 +288,25 @@ targets::tar_test("tar_quarto_files() detects code dependencies", { writeLines(lines, file.path("report", "_quarto.yml")) out <- tar_quarto_files("report/") if (identical(tolower(Sys.info()[["sysname"]]), "windows")) { - expect_equal(basename(out$sources), "text2.qmd") + expect_equal( + sort(basename(out$sources)), + sort("text1.qmd", "text2.qmd") + ) expect_equal(basename(out$output), "myoutdir") expect_equal( sort(basename(out$input)), sort(c("_quarto.yml", "main.qmd", "text1.qmd", "text2.qmd")) ) } else { - expect_equal(out$sources, file.path("report", "subdir", "text2.qmd")) + expect_equal( + out$sources, + sort( + c( + file.path("report", "text1.qmd"), + file.path("report", "subdir", "text2.qmd") + ) + ) + ) expect_equal(out$output, file.path("report", "myoutdir")) expect_equal( sort(out$input), From 154b86fd9943535452d61825aa2372e6d3cd95ee Mon Sep 17 00:00:00 2001 From: mutlusun Date: Fri, 8 Nov 2024 13:57:42 +0100 Subject: [PATCH 12/17] fix(quarto/files): detect input files correctly --- R/tar_quarto_files.R | 46 ++++------- tests/testthat/test-tar_quarto_files.R | 101 ++++++++----------------- 2 files changed, 46 insertions(+), 101 deletions(-) diff --git a/R/tar_quarto_files.R b/R/tar_quarto_files.R index 37302d9..81ea5b6 100644 --- a/R/tar_quarto_files.R +++ b/R/tar_quarto_files.R @@ -11,7 +11,7 @@ #' * `output`: output files that will be generated during #' `quarto::quarto_render()`. #' * `input`: pre-existing files required to render the project or document, -#' such as `_quarto.yml`. +#' such as `_quarto.yml` and quarto extensions. #' @param path Character of length 1, either the file path #' to a Quarto source document or the directory path #' to a Quarto project. Defaults to the Quarto project in the @@ -72,22 +72,13 @@ tar_quarto_files_document <- function(path) { ) } - # Collect data about input files. It seems that quarto only puts the main - # rendering file (in this case `path`) into `fileInformation`. Even though - # included files might include other files, they still appear in - # `includeMap$target` and not as an own `fileInformation` entry. - for (myfile in names(info$fileInformation)) { - out$input <- c( - out$input, - # `myfile` are relative paths starting from `path`. - myfile, - # `includeMap` contains relative paths starting from `myfile`. We can use - # `dirname(path)` here as this is the directory of `myfile`. - file.path( - dirname(path), - info$fileInformation[[myfile]]$includeMap$target - ) - ) + # Collect data about input files. As this is not a project, there doesn't + # exist the `info$files` key. However, we can include resources if present. + if (length(info$resources) > 0) { + out$input <- info$resources + out$input <- out$input[file.exists(out$input)] + } else { + out$input <- character() } out @@ -109,20 +100,15 @@ tar_quarto_files_project <- function(path) { # Collect data about source files. out$sources <- tar_quarto_files_get_source_files(info$fileInformation) - # Detect input files. - out$input <- info$files$config - for (myfile in names(info$fileInformation)) { - out$input <- c( - out$input, - # `myfile` is an absolute path. - myfile, - # `includeMap` files are relative starting from `myfile`. - file.path( - dirname(myfile), - info$fileInformation[[myfile]]$includeMap$target - ) + # Detect input files like the config file (`_quarto.yml`) and resources like + # quarto extensions. Make sure in the end that these files exist. + out$input <- unlist( + c( + info$files$config, + info$files$resources ) - } + ) + out$input <- out$input[file.exists(out$input)] out } diff --git a/tests/testthat/test-tar_quarto_files.R b/tests/testthat/test-tar_quarto_files.R index 3f5136b..35a8db0 100644 --- a/tests/testthat/test-tar_quarto_files.R +++ b/tests/testthat/test-tar_quarto_files.R @@ -14,9 +14,9 @@ targets::tar_test("tar_quarto_files() single Rmd/qmd", { path <- file.path("x", paste0("report", ext)) writeLines(lines, path) out <- tar_quarto_files(path) - expect_equal(out$sources, character(0)) + expect_equal(out$sources, file.path("x", paste0("report", ext))) expect_equal(out$output, file.path("x", "report.html")) - expect_equal(out$input, file.path("x", paste0("report", ext))) + expect_equal(out$input, character(0)) } }) @@ -56,19 +56,20 @@ targets::tar_test("tar_quarto_files() project", { ) writeLines(lines, file.path("x", "r2.qmd")) info <- tar_quarto_files("x") - expect_equal(info$sources, character()) if (identical(tolower(Sys.info()[["sysname"]]), "windows")) { - expect_equal(basename(info$output), "_book") expect_equal( - sort(basename(info$input)), - sort(c("_quarto.yml", "index.qmd", "r2.qmd")) + sort(basename(info$sources)), + sort(c("index.qmd", "r2.qmd")) ) + expect_equal(basename(info$output), "_book") + expect_equal(basename(info$input), "_quarto.yml") } else { - expect_equal(info$output, file.path("x", "_book")) expect_equal( - sort(info$input), - sort(file.path("x", c("_quarto.yml", "index.qmd", "r2.qmd"))) + sort(info$sources), + sort(file.path("x", c("index.qmd", "r2.qmd"))) ) + expect_equal(info$output, file.path("x", "_book")) + expect_equal(info$input, file.path("x", "_quarto.yml")) } }) @@ -117,17 +118,6 @@ targets::tar_test("tar_quarto_files() detects non-code dependencies", { out <- tar_quarto_files(file.path("report", "main.qmd")) expect_equal( sort(out$sources), - sort( - c( - file.path("report", "text1.qmd"), - file.path("report", "subdir", "text2.qmd"), - file.path("report", "subdir", "b", "text3.qmd") - ) - ) - ) - expect_equal(out$output, file.path("report", "main.html")) - expect_equal( - sort(out$input), sort( c( file.path("report", c("main.qmd", "text1.qmd")), @@ -136,6 +126,8 @@ targets::tar_test("tar_quarto_files() detects non-code dependencies", { ) ) ) + expect_equal(out$output, file.path("report", "main.html")) + expect_equal(out$input, character()) # Check whether we get the same result with a reference to the directory # instead of the file (render a project). lines <- c( @@ -152,40 +144,30 @@ targets::tar_test("tar_quarto_files() detects non-code dependencies", { basename(out$sources), sort( c( - file.path("report", "text1.qmd"), - file.path("report", "subdir", "text2.qmd"), - file.path("report", "subdir", "b", "text3.qmd") + "main.qmd", + "text1.qmd", + "text2.qmd", + "text3.qmd" ) ) ) expect_equal(basename(out$output), "myoutdir") - expect_equal( - sort(basename(out$input)), - sort(c("_quarto.yml", "main.qmd", "text1.qmd", "text2.qmd")) - ) + expect_equal(basename(out$input), "_quarto.yml") } else { expect_equal( out$sources, sort( c( - file.path("report", "text1.qmd"), + file.path("report", c("main.qmd", "text1.qmd")), file.path("report", "subdir", "text2.qmd"), - file.path("report", "subdir", "b", "text3.qmd") + file.path("report", "subdir", "b", c("text3.qmd", "text4.qmd")) ) ) ) expect_equal(out$output, file.path("report", "myoutdir")) expect_equal( - sort(out$input), - sort( - c( - file.path( - "report", - c("_quarto.yml", "main.qmd", "text1.qmd") - ), - file.path("report", "subdir", "text2.qmd") - ) - ) + out$input, + file.path("report", "_quarto.yml") ) } }) @@ -206,9 +188,9 @@ targets::tar_test("tar_quarto_files() detects custom output file", { ) writeLines(lines, "report.qmd") out <- tar_quarto_files("report.qmd") - expect_equal(out$sources, character(0)) + expect_equal(out$sources, "report.qmd") expect_equal(out$output, "custom.html") - expect_equal(out$input, "report.qmd") + expect_equal(out$input, character(0)) }) targets::tar_test("tar_quarto_files() detects code dependencies", { @@ -253,31 +235,19 @@ targets::tar_test("tar_quarto_files() detects code dependencies", { sort("text1.qmd", "text2.qmd") ) expect_equal(basename(out$output), "main.html") - expect_equal( - sort(basename(out$input)), - sort(c("main.qmd", "text1.qmd", "text2.qmd")) - ) } else { expect_equal( out$sources, sort( c( - file.path("report", "text1.qmd"), + file.path("report", c("text1.qmd", "main.qmd")), file.path("report", "subdir", "text2.qmd") ) ) ) expect_equal(out$output, file.path("report", "main.html")) - expect_equal( - sort(out$input), - sort( - c( - file.path("report", c("main.qmd", "text1.qmd")), - file.path("report", "subdir", "text2.qmd") - ) - ) - ) } + expect_equal(out$input, character()) # Check whether we get the same result when calling via a project. lines <- c( "project:", @@ -290,35 +260,24 @@ targets::tar_test("tar_quarto_files() detects code dependencies", { if (identical(tolower(Sys.info()[["sysname"]]), "windows")) { expect_equal( sort(basename(out$sources)), - sort("text1.qmd", "text2.qmd") + sort("main.qmd", "text1.qmd", "text2.qmd") ) expect_equal(basename(out$output), "myoutdir") - expect_equal( - sort(basename(out$input)), - sort(c("_quarto.yml", "main.qmd", "text1.qmd", "text2.qmd")) - ) + expect_equal(basename(out$input), "_quarto.yml") } else { expect_equal( out$sources, sort( c( - file.path("report", "text1.qmd"), + file.path("report", c("text1.qmd", "main.qmd")), file.path("report", "subdir", "text2.qmd") ) ) ) expect_equal(out$output, file.path("report", "myoutdir")) expect_equal( - sort(out$input), - sort( - c( - file.path( - "report", - c("_quarto.yml", "main.qmd", "text1.qmd") - ), - file.path("report", "subdir", "text2.qmd") - ) - ) + out$input, + file.path("report", "_quarto.yml") ) } }) From f1fdf0a9a346fdf2ca286defe57fe37f0336e89f Mon Sep 17 00:00:00 2001 From: mutlusun Date: Fri, 8 Nov 2024 14:03:09 +0100 Subject: [PATCH 13/17] test(quarto/files): remove redundant test --- tests/testthat/test-tar_quarto_files.R | 109 +------------------------ 1 file changed, 4 insertions(+), 105 deletions(-) diff --git a/tests/testthat/test-tar_quarto_files.R b/tests/testthat/test-tar_quarto_files.R index 35a8db0..3034ddf 100644 --- a/tests/testthat/test-tar_quarto_files.R +++ b/tests/testthat/test-tar_quarto_files.R @@ -73,7 +73,7 @@ targets::tar_test("tar_quarto_files() project", { } }) -targets::tar_test("tar_quarto_files() detects non-code dependencies", { +targets::tar_test("tar_quarto_files() detects nested dependencies", { skip_quarto() fs::dir_create("report") fs::dir_create(file.path("report", "subdir")) @@ -109,12 +109,6 @@ targets::tar_test("tar_quarto_files() detects non-code dependencies", { "Some text here." ) writeLines(lines, file.path("report", "subdir", "b", "text3.qmd")) - lines <- c( - "# Fourth File", - "", - "Some text here." - ) - writeLines(lines, file.path("report", "subdir", "b", "text4.qmd")) out <- tar_quarto_files(file.path("report", "main.qmd")) expect_equal( sort(out$sources), @@ -134,8 +128,7 @@ targets::tar_test("tar_quarto_files() detects non-code dependencies", { "project:", " output-dir: myoutdir", " render:", - " - main.qmd", - " - subdir/b/text4.qmd" + " - main.qmd" ) writeLines(lines, file.path("report", "_quarto.yml")) out <- tar_quarto_files("report/") @@ -143,12 +136,7 @@ targets::tar_test("tar_quarto_files() detects non-code dependencies", { expect_equal( basename(out$sources), sort( - c( - "main.qmd", - "text1.qmd", - "text2.qmd", - "text3.qmd" - ) + c("main.qmd", "text1.qmd", "text2.qmd", "text3.qmd") ) ) expect_equal(basename(out$output), "myoutdir") @@ -160,7 +148,7 @@ targets::tar_test("tar_quarto_files() detects non-code dependencies", { c( file.path("report", c("main.qmd", "text1.qmd")), file.path("report", "subdir", "text2.qmd"), - file.path("report", "subdir", "b", c("text3.qmd", "text4.qmd")) + file.path("report", "subdir", "b", "text3.qmd") ) ) ) @@ -192,92 +180,3 @@ targets::tar_test("tar_quarto_files() detects custom output file", { expect_equal(out$output, "custom.html") expect_equal(out$input, character(0)) }) - -targets::tar_test("tar_quarto_files() detects code dependencies", { - skip_quarto() - fs::dir_create("report") - fs::dir_create(file.path("report", "subdir")) - lines <- c( - "---", - "title: main", - "output_format: html", - "---", - "", - "{{< include \"text1.qmd\" >}}", - "", - "{{< include \"subdir/text2.qmd\" >}}" - ) - writeLines(lines, file.path("report", "main.qmd")) - lines <- c( - "# First File", - "", - "Contains a code cell.", - "", - "```{r}", - "1 + 1", - "```" - ) - writeLines(lines, file.path("report", "text1.qmd")) - lines <- c( - "# Second File", - "", - "Contains a code cell with a call to `tar_read`.", - "", - "```{r}", - "targets::tar_read(mytarget)", - "```" - ) - writeLines(lines, file.path("report", "subdir", "text2.qmd")) - out <- tar_quarto_files("report/main.qmd") - if (identical(tolower(Sys.info()[["sysname"]]), "windows")) { - expect_equal( - sort(basename(out$sources)), - sort("text1.qmd", "text2.qmd") - ) - expect_equal(basename(out$output), "main.html") - } else { - expect_equal( - out$sources, - sort( - c( - file.path("report", c("text1.qmd", "main.qmd")), - file.path("report", "subdir", "text2.qmd") - ) - ) - ) - expect_equal(out$output, file.path("report", "main.html")) - } - expect_equal(out$input, character()) - # Check whether we get the same result when calling via a project. - lines <- c( - "project:", - " output-dir: myoutdir", - " render:", - " - main.qmd" - ) - writeLines(lines, file.path("report", "_quarto.yml")) - out <- tar_quarto_files("report/") - if (identical(tolower(Sys.info()[["sysname"]]), "windows")) { - expect_equal( - sort(basename(out$sources)), - sort("main.qmd", "text1.qmd", "text2.qmd") - ) - expect_equal(basename(out$output), "myoutdir") - expect_equal(basename(out$input), "_quarto.yml") - } else { - expect_equal( - out$sources, - sort( - c( - file.path("report", c("text1.qmd", "main.qmd")), - file.path("report", "subdir", "text2.qmd") - ) - ) - ) - expect_equal(out$output, file.path("report", "myoutdir")) - expect_equal( - out$input, - file.path("report", "_quarto.yml") - ) - } -}) From 7f918f41957e8ba6ebff28c2611c2f634388b21d Mon Sep 17 00:00:00 2001 From: wlandau-lilly Date: Mon, 11 Nov 2024 05:03:32 -0500 Subject: [PATCH 14/17] versions --- .github/workflows/check.yaml | 2 +- R/tar_quarto_files.R | 2 +- tests/testthat/helper-utils.R | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 3eedf6a..45420ca 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -31,7 +31,7 @@ jobs: - uses: r-lib/actions/setup-pandoc@v2 - - uses: quarto-dev/quarto-actions/setup@v2 + - uses: quarto-dev/quarto-actions/setup@v2.1.6 - name: Install Mac system dependencies if: runner.os == 'macOS' diff --git a/R/tar_quarto_files.R b/R/tar_quarto_files.R index 81ea5b6..601d1d6 100644 --- a/R/tar_quarto_files.R +++ b/R/tar_quarto_files.R @@ -78,7 +78,7 @@ tar_quarto_files_document <- function(path) { out$input <- info$resources out$input <- out$input[file.exists(out$input)] } else { - out$input <- character() + out$input <- character(0L) } out diff --git a/tests/testthat/helper-utils.R b/tests/testthat/helper-utils.R index 7d86d66..d9444c8 100644 --- a/tests/testthat/helper-utils.R +++ b/tests/testthat/helper-utils.R @@ -6,9 +6,12 @@ expect_equiv <- function(object, expected, ...) { skip_quarto <- function() { skip_pandoc() - skip_if_not_installed("quarto") - if (is.null(quarto::quarto_path())) { - skip("Quarto not found.") + skip_if_not_installed("quarto", minimum_version = "1.4.4") + quarto_version <- as.character(quarto::quarto_version()) + no_quarto <- is.null(quarto::quarto_path()) || + utils::compareVersion(quarto_version, "1.6.33") < 0L + if (no_quarto) { + skip("Quarto >= 1.6.33 not found.") } } From 4d069e44f638e409f21f330fd66203567dd4d79c Mon Sep 17 00:00:00 2001 From: wlandau Date: Mon, 11 Nov 2024 05:23:50 -0500 Subject: [PATCH 15/17] news, docs, and fixes --- NEWS.md | 1 + R/tar_quarto_files.R | 15 ++++++------ R/tar_quarto_raw.R | 2 +- R/tar_quarto_rep_raw.R | 5 +++- man/tar_age.Rd | 32 ++++++++++++++++++++------ man/tar_change.Rd | 32 ++++++++++++++++++++------ man/tar_combine.Rd | 32 ++++++++++++++++++++------ man/tar_download.Rd | 32 ++++++++++++++++++++------ man/tar_file_read.Rd | 32 ++++++++++++++++++++------ man/tar_files.Rd | 32 ++++++++++++++++++++------ man/tar_files_input.Rd | 32 ++++++++++++++++++++------ man/tar_force.Rd | 32 ++++++++++++++++++++------ man/tar_formats.Rd | 32 ++++++++++++++++++++------ man/tar_formats_superseded.Rd | 32 ++++++++++++++++++++------ man/tar_group_by.Rd | 32 ++++++++++++++++++++------ man/tar_group_count.Rd | 32 ++++++++++++++++++++------ man/tar_group_select.Rd | 32 ++++++++++++++++++++------ man/tar_group_size.Rd | 32 ++++++++++++++++++++------ man/tar_knit.Rd | 32 ++++++++++++++++++++------ man/tar_map2.Rd | 32 ++++++++++++++++++++------ man/tar_map2_count.Rd | 32 ++++++++++++++++++++------ man/tar_map2_size.Rd | 32 ++++++++++++++++++++------ man/tar_map_rep.Rd | 32 ++++++++++++++++++++------ man/tar_quarto.Rd | 32 ++++++++++++++++++++------ man/tar_quarto_files.Rd | 6 +++-- man/tar_quarto_rep.Rd | 32 ++++++++++++++++++++------ man/tar_render.Rd | 32 ++++++++++++++++++++------ man/tar_render_rep.Rd | 32 ++++++++++++++++++++------ man/tar_rep.Rd | 32 ++++++++++++++++++++------ man/tar_rep2.Rd | 32 ++++++++++++++++++++------ man/tar_rep_map.Rd | 32 ++++++++++++++++++++------ man/tar_rep_map_raw.Rd | 32 ++++++++++++++++++++------ man/tar_skip.Rd | 32 ++++++++++++++++++++------ tests/testthat/test-tar_quarto_files.R | 17 ++++---------- 34 files changed, 722 insertions(+), 220 deletions(-) diff --git a/NEWS.md b/NEWS.md index 46d9942..b1065ad 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,7 @@ * Detect child quarto documents (#199, @mutlusun). * Improve reporting of static branch names from `tar_map()` and `tar_map_rep()` (#201, @kkmann). * Ensure compatibility with `targets` after https://github.com/ropensci/targets/issues/1368. +* Improve detection of Quarto files in `tar_quarto_inspect()` (#200, @multusun). # tarchetypes 0.10.0 diff --git a/R/tar_quarto_files.R b/R/tar_quarto_files.R index 601d1d6..3e63dd7 100644 --- a/R/tar_quarto_files.R +++ b/R/tar_quarto_files.R @@ -12,6 +12,7 @@ #' `quarto::quarto_render()`. #' * `input`: pre-existing files required to render the project or document, #' such as `_quarto.yml` and quarto extensions. +#' @inheritParams quarto::quarto_render #' @param path Character of length 1, either the file path #' to a Quarto source document or the directory path #' to a Quarto project. Defaults to the Quarto project in the @@ -33,7 +34,7 @@ #' writeLines(lines, path) #' # If Quarto is installed, run: #' # tar_quarto_files(path) -tar_quarto_files <- function(path = ".", profile = NULL) { +tar_quarto_files <- function(path = ".", profile = NULL, quiet = TRUE) { assert_quarto() targets::tar_assert_scalar(path) targets::tar_assert_chr(path) @@ -47,8 +48,8 @@ tar_quarto_files <- function(path = ".", profile = NULL) { } out <- if_any( fs::is_dir(path), - tar_quarto_files_project(path), - tar_quarto_files_document(path) + tar_quarto_files_project(path, quiet), + tar_quarto_files_document(path, quiet) ) for (field in c("sources", "output", "input")) { out[[field]] <- as.character(fs::path_rel(out[[field]])) @@ -57,8 +58,8 @@ tar_quarto_files <- function(path = ".", profile = NULL) { out } -tar_quarto_files_document <- function(path) { - info <- quarto::quarto_inspect(input = path) +tar_quarto_files_document <- function(path, quiet) { + info <- quarto::quarto_inspect(input = path, quiet = quiet) out <- list() # Collect data about source files. @@ -84,8 +85,8 @@ tar_quarto_files_document <- function(path) { out } -tar_quarto_files_project <- function(path) { - info <- quarto::quarto_inspect(input = path) +tar_quarto_files_project <- function(path, quiet) { + info <- quarto::quarto_inspect(input = path, quiet) targets::tar_assert_nonempty( info$config$project$`output-dir`, paste( diff --git a/R/tar_quarto_raw.R b/R/tar_quarto_raw.R index 618fff9..588e661 100644 --- a/R/tar_quarto_raw.R +++ b/R/tar_quarto_raw.R @@ -58,7 +58,7 @@ tar_quarto_raw <- function( targets::tar_assert_scalar(profile %|||% ".") targets::tar_assert_chr(profile %|||% ".") targets::tar_assert_nzchar(profile %|||% ".") - info <- tar_quarto_files(path = path, profile = profile) + info <- tar_quarto_files(path = path, profile = profile, quiet = quiet) sources <- info$sources output <- info$output if (!is.null(output_file)) { diff --git a/R/tar_quarto_rep_raw.R b/R/tar_quarto_rep_raw.R index e6624c4..dca78da 100644 --- a/R/tar_quarto_rep_raw.R +++ b/R/tar_quarto_rep_raw.R @@ -59,7 +59,10 @@ tar_quarto_rep_raw <- function( rep_workers <- as.integer(rep_workers) name_params <- paste0(name, "_params") sym_params <- as.symbol(name_params) - default_output_file <- utils::head(tar_quarto_files(path)$output, n = 1L) + default_output_file <- utils::head( + tar_quarto_files(path, quiet = quiet)$output, + n = 1L + ) default_output_file <- default_output_file %||% fs::path_ext_set(path, "html") target_params <- targets::tar_target_raw( diff --git a/man/tar_age.Rd b/man/tar_age.Rd index 1759b18..75e98c5 100644 --- a/man/tar_age.Rd +++ b/man/tar_age.Rd @@ -90,7 +90,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -109,19 +111,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -129,8 +138,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/man/tar_change.Rd b/man/tar_change.Rd index 529512e..a6ac6b9 100644 --- a/man/tar_change.Rd +++ b/man/tar_change.Rd @@ -125,7 +125,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -144,19 +146,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -164,8 +173,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/man/tar_combine.Rd b/man/tar_combine.Rd index fd8b49a..a4d486c 100644 --- a/man/tar_combine.Rd +++ b/man/tar_combine.Rd @@ -150,7 +150,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -169,19 +171,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -189,8 +198,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/man/tar_download.Rd b/man/tar_download.Rd index 0563ed8..1efaeb5 100644 --- a/man/tar_download.Rd +++ b/man/tar_download.Rd @@ -111,7 +111,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -130,19 +132,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -150,8 +159,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/man/tar_file_read.Rd b/man/tar_file_read.Rd index 4d2e330..0794a6d 100644 --- a/man/tar_file_read.Rd +++ b/man/tar_file_read.Rd @@ -109,7 +109,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -128,19 +130,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -148,8 +157,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/man/tar_files.Rd b/man/tar_files.Rd index 2325d1f..d1490b1 100644 --- a/man/tar_files.Rd +++ b/man/tar_files.Rd @@ -129,7 +129,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -148,19 +150,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -168,8 +177,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/man/tar_files_input.Rd b/man/tar_files_input.Rd index 48bf6fd..ec6e627 100644 --- a/man/tar_files_input.Rd +++ b/man/tar_files_input.Rd @@ -95,7 +95,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -114,19 +116,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -134,8 +143,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{priority}{Numeric of length 1 between 0 and 1. Controls which targets get deployed first when multiple competing targets are ready diff --git a/man/tar_force.Rd b/man/tar_force.Rd index 31ad30f..f932fe9 100644 --- a/man/tar_force.Rd +++ b/man/tar_force.Rd @@ -126,7 +126,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -145,19 +147,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -165,8 +174,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/man/tar_formats.Rd b/man/tar_formats.Rd index b00118b..bf4cb4e 100644 --- a/man/tar_formats.Rd +++ b/man/tar_formats.Rd @@ -396,7 +396,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -415,19 +417,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -435,8 +444,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/man/tar_formats_superseded.Rd b/man/tar_formats_superseded.Rd index 6883809..68d9c5b 100644 --- a/man/tar_formats_superseded.Rd +++ b/man/tar_formats_superseded.Rd @@ -350,7 +350,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -369,19 +371,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -389,8 +398,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/man/tar_group_by.Rd b/man/tar_group_by.Rd index 08d7d02..0518e00 100644 --- a/man/tar_group_by.Rd +++ b/man/tar_group_by.Rd @@ -106,7 +106,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -125,19 +127,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -145,8 +154,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/man/tar_group_count.Rd b/man/tar_group_count.Rd index 4fd8b90..281f8cb 100644 --- a/man/tar_group_count.Rd +++ b/man/tar_group_count.Rd @@ -106,7 +106,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -125,19 +127,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -145,8 +154,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/man/tar_group_select.Rd b/man/tar_group_select.Rd index 808009c..440ec31 100644 --- a/man/tar_group_select.Rd +++ b/man/tar_group_select.Rd @@ -107,7 +107,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -126,19 +128,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -146,8 +155,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/man/tar_group_size.Rd b/man/tar_group_size.Rd index d170282..67fae2a 100644 --- a/man/tar_group_size.Rd +++ b/man/tar_group_size.Rd @@ -107,7 +107,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -126,19 +128,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -146,8 +155,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/man/tar_knit.Rd b/man/tar_knit.Rd index e8ae7d8..243d8cc 100644 --- a/man/tar_knit.Rd +++ b/man/tar_knit.Rd @@ -87,7 +87,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -106,19 +108,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -126,8 +135,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/man/tar_map2.Rd b/man/tar_map2.Rd index b9f596d..f5dfbb1 100644 --- a/man/tar_map2.Rd +++ b/man/tar_map2.Rd @@ -203,7 +203,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -222,19 +224,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -242,8 +251,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/man/tar_map2_count.Rd b/man/tar_map2_count.Rd index 9d0acd7..29e1167 100644 --- a/man/tar_map2_count.Rd +++ b/man/tar_map2_count.Rd @@ -210,7 +210,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -229,19 +231,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -249,8 +258,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/man/tar_map2_size.Rd b/man/tar_map2_size.Rd index 8bfe52e..cb5ad82 100644 --- a/man/tar_map2_size.Rd +++ b/man/tar_map2_size.Rd @@ -210,7 +210,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -229,19 +231,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -249,8 +258,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/man/tar_map_rep.Rd b/man/tar_map_rep.Rd index 34001e4..539be1b 100644 --- a/man/tar_map_rep.Rd +++ b/man/tar_map_rep.Rd @@ -176,7 +176,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -195,19 +197,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -215,8 +224,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/man/tar_quarto.Rd b/man/tar_quarto.Rd index 58297f8..fc086f2 100644 --- a/man/tar_quarto.Rd +++ b/man/tar_quarto.Rd @@ -143,7 +143,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -162,19 +164,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -182,8 +191,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/man/tar_quarto_files.Rd b/man/tar_quarto_files.Rd index edcc39e..acd15cb 100644 --- a/man/tar_quarto_files.Rd +++ b/man/tar_quarto_files.Rd @@ -4,7 +4,7 @@ \alias{tar_quarto_files} \title{Quarto file detection} \usage{ -tar_quarto_files(path = ".", profile = NULL) +tar_quarto_files(path = ".", profile = NULL, quiet = TRUE) } \arguments{ \item{path}{Character of length 1, either the file path @@ -15,6 +15,8 @@ current working directory.} \item{profile}{Character of length 1, Quarto profile. If \code{NULL}, the default profile will be used. Requires Quarto version 1.2 or higher. See \url{https://quarto.org/docs/projects/profiles.html} for details.} + +\item{quiet}{Suppress warning and other messages.} } \value{ A named list of important file paths in a Quarto project or document: @@ -24,7 +26,7 @@ dependencies in code chunks using \code{tar_load()}/\code{tar_read()}. \item \code{output}: output files that will be generated during \code{quarto::quarto_render()}. \item \code{input}: pre-existing files required to render the project or document, -such as \verb{_quarto.yml}. +such as \verb{_quarto.yml} and quarto extensions. } } \description{ diff --git a/man/tar_quarto_rep.Rd b/man/tar_quarto_rep.Rd index 20e5ba6..1bbcd22 100644 --- a/man/tar_quarto_rep.Rd +++ b/man/tar_quarto_rep.Rd @@ -184,7 +184,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -203,19 +205,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -223,8 +232,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/man/tar_render.Rd b/man/tar_render.Rd index d063a9a..e2b16ab 100644 --- a/man/tar_render.Rd +++ b/man/tar_render.Rd @@ -86,7 +86,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -105,19 +107,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -125,8 +134,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/man/tar_render_rep.Rd b/man/tar_render_rep.Rd index 96412b2..03f9a90 100644 --- a/man/tar_render_rep.Rd +++ b/man/tar_render_rep.Rd @@ -129,7 +129,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -148,19 +150,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -168,8 +177,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/man/tar_rep.Rd b/man/tar_rep.Rd index fd31717..ad1b12d 100644 --- a/man/tar_rep.Rd +++ b/man/tar_rep.Rd @@ -153,7 +153,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -172,19 +174,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -192,8 +201,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/man/tar_rep2.Rd b/man/tar_rep2.Rd index ee9d1c4..c16c714 100644 --- a/man/tar_rep2.Rd +++ b/man/tar_rep2.Rd @@ -158,7 +158,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -177,19 +179,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -197,8 +206,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/man/tar_rep_map.Rd b/man/tar_rep_map.Rd index 1871b6d..58fd089 100644 --- a/man/tar_rep_map.Rd +++ b/man/tar_rep_map.Rd @@ -131,7 +131,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -150,19 +152,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -170,8 +179,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/man/tar_rep_map_raw.Rd b/man/tar_rep_map_raw.Rd index c1031b0..97c8ab3 100644 --- a/man/tar_rep_map_raw.Rd +++ b/man/tar_rep_map_raw.Rd @@ -132,7 +132,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -151,19 +153,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -171,8 +180,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/man/tar_skip.Rd b/man/tar_skip.Rd index a6e3a90..3736bbf 100644 --- a/man/tar_skip.Rd +++ b/man/tar_skip.Rd @@ -126,7 +126,9 @@ stops and throws an error. Options: \item \code{"continue"}: the whole pipeline keeps going. \item \code{"null"}: The errored target continues and returns \code{NULL}. The data hash is deliberately wrong so the target is not -up to date for the next run of the pipeline. +up to date for the next run of the pipeline. In addition, +as of version 1.8.0.9011, a value of \code{NULL} is given +to upstream dependencies with \code{error = "null"} if loading fails. \item \code{"abridge"}: any currently running targets keep running, but no new targets launch after that. \item \code{"trim"}: all currently running targets stay running. A queued @@ -145,19 +147,26 @@ to begin running. to learn how to debug targets using saved workspaces.) }} -\item{memory}{Character of length 1, memory strategy. -If \code{"persistent"}, the target stays in memory +\item{memory}{Character of length 1, memory strategy. Possible values: +\itemize{ +\item \code{"auto"}: new in \code{targets} version 1.8.0.9011, \code{memory = "auto"} +is equivalent to \code{memory = "transient"} for dynamic branching +(a non-null \code{pattern} argument) and \code{memory = "persistent"} +for targets that do not use dynamic branching. +\item \code{"persistent"}: the target stays in memory until the end of the pipeline (unless \code{storage} is \code{"worker"}, in which case \code{targets} unloads the value from memory right after storing it in order to avoid sending copious data over a network). -If \code{"transient"}, the target gets unloaded +\item \code{"transient"}: the target gets unloaded after every new target completes. Either way, the target gets automatically loaded into memory whenever another target needs the value. +} + For cloud-based dynamic files (e.g. \code{format = "file"} with \code{repository = "aws"}), -this memory strategy applies to the +the \code{memory} option applies to the temporary local copy of the file: \code{"persistent"} means it remains until the end of the pipeline and is then deleted, @@ -165,8 +174,17 @@ and \code{"transient"} means it gets deleted as soon as possible. The former conserves bandwidth, and the latter conserves local storage.} -\item{garbage_collection}{Logical, whether to run \code{base::gc()} -just before the target runs.} +\item{garbage_collection}{Logical: \code{TRUE} to run \code{base::gc()} +just before the target runs, +\code{FALSE} to omit garbage collection. +In the case of high-performance computing, +\code{gc()} runs both locally and on the parallel worker. +All this garbage collection is skipped if the actual target +is skipped in the pipeline. +Non-logical values of \code{garbage_collection} are converted to \code{TRUE} or +\code{FALSE} using \code{isTRUE()}. In other words, non-logical values are +converted \code{FALSE}. For example, \code{garbage_collection = 2} +is equivalent to \code{garbage_collection = FALSE}.} \item{deployment}{Character of length 1. If \code{deployment} is \code{"main"}, then the target will run on the central controlling R process. diff --git a/tests/testthat/test-tar_quarto_files.R b/tests/testthat/test-tar_quarto_files.R index 3034ddf..5d80049 100644 --- a/tests/testthat/test-tar_quarto_files.R +++ b/tests/testthat/test-tar_quarto_files.R @@ -99,24 +99,16 @@ targets::tar_test("tar_quarto_files() detects nested dependencies", { "# Second File", "", "Some text here.", - "", - "{{< include \"subdir/b/text3.qmd\" >}}" + "" ) writeLines(lines, file.path("report", "subdir", "text2.qmd")) - lines <- c( - "# Third File", - "", - "Some text here." - ) - writeLines(lines, file.path("report", "subdir", "b", "text3.qmd")) out <- tar_quarto_files(file.path("report", "main.qmd")) expect_equal( sort(out$sources), sort( c( file.path("report", c("main.qmd", "text1.qmd")), - file.path("report", "subdir", "text2.qmd"), - file.path("report", "subdir", "b", "text3.qmd") + file.path("report", "subdir", "text2.qmd") ) ) ) @@ -136,7 +128,7 @@ targets::tar_test("tar_quarto_files() detects nested dependencies", { expect_equal( basename(out$sources), sort( - c("main.qmd", "text1.qmd", "text2.qmd", "text3.qmd") + c("main.qmd", "text1.qmd", "text2.qmd") ) ) expect_equal(basename(out$output), "myoutdir") @@ -147,8 +139,7 @@ targets::tar_test("tar_quarto_files() detects nested dependencies", { sort( c( file.path("report", c("main.qmd", "text1.qmd")), - file.path("report", "subdir", "text2.qmd"), - file.path("report", "subdir", "b", "text3.qmd") + file.path("report", "subdir", "text2.qmd") ) ) ) From f92395411018af0cdca084601889d0e46a5d947f Mon Sep 17 00:00:00 2001 From: wlandau Date: Mon, 11 Nov 2024 05:24:30 -0500 Subject: [PATCH 16/17] add Rd file --- man/tar_quarto_files_get_source_files.Rd | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 man/tar_quarto_files_get_source_files.Rd diff --git a/man/tar_quarto_files_get_source_files.Rd b/man/tar_quarto_files_get_source_files.Rd new file mode 100644 index 0000000..cb21c8b --- /dev/null +++ b/man/tar_quarto_files_get_source_files.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/tar_quarto_files.R +\name{tar_quarto_files_get_source_files} +\alias{tar_quarto_files_get_source_files} +\title{Get Source Files From Quarto Inspect} +\usage{ +tar_quarto_files_get_source_files(file_information) +} +\description{ +Collects all files from the +\code{fileInformation} field that are used in the current report. +} +\details{ +\code{fileInformation} contains a list of files. Each file entry contains +two data frames. The first, \code{includeMap}, contains a \code{source} column (files +that include other files, e.g. the main report file) and a \code{target} column +(files that get included by the \code{source} files). The \code{codeCells} data frame +contains all code cells from the files represented in \code{includeMap}. +} From 95d4c9ec4edb092703098ff31d8b8edb46398fef Mon Sep 17 00:00:00 2001 From: wlandau Date: Mon, 11 Nov 2024 05:26:58 -0500 Subject: [PATCH 17/17] document function --- R/tar_quarto_files.R | 17 +++++++++-------- man/tar_quarto_files_get_source_files.Rd | 7 +++++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/R/tar_quarto_files.R b/R/tar_quarto_files.R index 3e63dd7..ca9891b 100644 --- a/R/tar_quarto_files.R +++ b/R/tar_quarto_files.R @@ -114,16 +114,17 @@ tar_quarto_files_project <- function(path, quiet) { out } -#' Get Source Files From Quarto Inspect -#' +#' @title Get Source Files From Quarto Inspect #' @description Collects all files from the -#' `fileInformation` field that are used in the current report. -#' +#' `fileInformation` field that are used in the current report. #' @details `fileInformation` contains a list of files. Each file entry contains -#' two data frames. The first, `includeMap`, contains a `source` column (files -#' that include other files, e.g. the main report file) and a `target` column -#' (files that get included by the `source` files). The `codeCells` data frame -#' contains all code cells from the files represented in `includeMap`. +#' two data frames. The first, `includeMap`, contains a `source` column (files +#' that include other files, e.g. the main report file) and a `target` column +#' (files that get included by the `source` files). The `codeCells` data frame +#' contains all code cells from the files represented in `includeMap`. +#' @return A character vector of Quarto source files. +#' @param file_information The `fileInformation` element of the list +#' returned by `quarto::quarto_inspect()`. tar_quarto_files_get_source_files <- function(file_information) { ret <- character(0) diff --git a/man/tar_quarto_files_get_source_files.Rd b/man/tar_quarto_files_get_source_files.Rd index cb21c8b..c5f6a99 100644 --- a/man/tar_quarto_files_get_source_files.Rd +++ b/man/tar_quarto_files_get_source_files.Rd @@ -6,6 +6,13 @@ \usage{ tar_quarto_files_get_source_files(file_information) } +\arguments{ +\item{file_information}{The \code{fileInformation} element of the list +returned by \code{quarto::quarto_inspect()}.} +} +\value{ +A character vector of Quarto source files. +} \description{ Collects all files from the \code{fileInformation} field that are used in the current report.