Skip to content

Commit 27c9b0f

Browse files
committed
Fix #1426
1 parent 364a3c3 commit 27c9b0f

File tree

7 files changed

+40
-39
lines changed

7 files changed

+40
-39
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Changes to default settings
44

55
* In `tar_option_get()`, set `repository_meta` to `"local"` by default, regardless of `repository` (#1427).
6+
* In `tar_option_get()`, set `storage = "worker"`, `retrieval = "worker"`, and `memory = "tranisient"` by default (#1426).
67

78
## Other changes
89

R/class_options.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ options_class <- R6::R6Class(
312312
self$error %|||% "stop"
313313
},
314314
get_memory = function() {
315-
self$memory %|||% "auto"
315+
self$memory %|||% "transient"
316316
},
317317
get_garbage_collection = function() {
318318
self$garbage_collection %|||% 1000L
@@ -330,10 +330,10 @@ options_class <- R6::R6Class(
330330
self$resources %|||% list()
331331
},
332332
get_storage = function() {
333-
self$storage %|||% "main"
333+
self$storage %|||% "worker"
334334
},
335335
get_retrieval = function() {
336-
self$retrieval %|||% "main"
336+
self$retrieval %|||% "worker"
337337
},
338338
get_cue = function() {
339339
self$cue %|||% tar_cue()

R/tar_target.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,15 +277,15 @@
277277
#' to learn how to debug targets using saved workspaces.)
278278
#' @param memory Character of length 1, memory strategy. Possible values:
279279
#'
280+
#' * `"transient"` (default): the target gets unloaded
281+
#' after every new target completes.
282+
#' Either way, the target gets automatically loaded into memory
283+
#' whenever another target needs the value.
280284
#' * `"persistent"`: the target stays in memory
281285
#' until the end of the pipeline (unless `storage` is `"worker"`,
282286
#' in which case `targets` unloads the value from memory
283287
#' right after storing it in order to avoid sending
284288
#' copious data over a network).
285-
#' * `"transient"`: the target gets unloaded
286-
#' after every new target completes.
287-
#' Either way, the target gets automatically loaded into memory
288-
#' whenever another target needs the value.
289289
#' * `"auto"`: new in `targets` version 1.8.0.9011, `memory = "auto"`
290290
#' is equivalent to `memory = "transient"` for dynamic branching
291291
#' (a non-null `pattern` argument) and `memory = "persistent"`
@@ -331,9 +331,9 @@
331331
#' is saved to storage. Only relevant when using `targets`
332332
#' with parallel workers (<https://books.ropensci.org/targets/crew.html>).
333333
#' Must be one of the following values:
334+
#' * `"worker"` (default): the worker saves/uploads the value.
334335
#' * `"main"`: the target's return value is sent back to the
335336
#' host machine and saved/uploaded locally.
336-
#' * `"worker"`: the worker saves/uploads the value.
337337
#' * `"none"`: `targets` makes no attempt to save the result
338338
#' of the target to storage in the location where `targets`
339339
#' expects it to be. Saving to storage is the responsibility
@@ -344,9 +344,9 @@
344344
#' depends on.) Only relevant when using `targets`
345345
#' with parallel workers (<https://books.ropensci.org/targets/crew.html>).
346346
#' Must be one of the following values:
347+
#' * `"worker"` (default): the worker loads the target's dependencies.
347348
#' * `"main"`: the target's dependencies are loaded on the host machine
348349
#' and sent to the worker before the target runs.
349-
#' * `"worker"`: the worker loads the target's dependencies.
350350
#' * `"none"`: `targets` makes no attempt to load its
351351
#' dependencies. With `retrieval = "none"`, loading dependencies
352352
#' is the responsibility of the user. Use with caution.

man/tar_option_set.Rd

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/tar_target.Rd

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-class_options.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,11 @@ tar_test("deprecated error = \"workspace\"", {
260260

261261
tar_test("memory", {
262262
x <- options_init()
263-
expect_equal(x$get_memory(), "auto")
264-
x$set_memory("transient")
265263
expect_equal(x$get_memory(), "transient")
264+
x$set_memory("persistent")
265+
expect_equal(x$get_memory(), "persistent")
266266
x$reset()
267-
expect_equal(x$get_memory(), "auto")
267+
expect_equal(x$get_memory(), "transient")
268268
expect_error(x$set_memory("invalid"), class = "tar_condition_validate")
269269
})
270270

@@ -339,21 +339,21 @@ tar_test("resources", {
339339

340340
tar_test("storage", {
341341
x <- options_init()
342-
expect_equal(x$get_storage(), "main")
343-
x$set_storage("worker")
344342
expect_equal(x$get_storage(), "worker")
345-
x$reset()
343+
x$set_storage("main")
346344
expect_equal(x$get_storage(), "main")
345+
x$reset()
346+
expect_equal(x$get_storage(), "worker")
347347
expect_error(x$set_storage("invalid"), class = "tar_condition_validate")
348348
})
349349

350350
tar_test("retrieval", {
351351
x <- options_init()
352-
expect_equal(x$get_retrieval(), "main")
353-
x$set_retrieval("worker")
354352
expect_equal(x$get_retrieval(), "worker")
355-
x$reset()
353+
x$set_retrieval("main")
356354
expect_equal(x$get_retrieval(), "main")
355+
x$reset()
356+
expect_equal(x$get_retrieval(), "worker")
357357
expect_error(x$set_retrieval("invalid"), class = "tar_condition_validate")
358358
})
359359

tests/testthat/test-tar_option_set.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ tar_test("deprecated error = \"workspace\"", {
153153
})
154154

155155
tar_test("memory", {
156-
expect_equal(tar_option_get("memory"), "auto")
157-
tar_option_set(memory = "transient")
158156
expect_equal(tar_option_get("memory"), "transient")
157+
tar_option_set(memory = "persistent")
158+
expect_equal(tar_option_get("memory"), "persistent")
159159
tar_option_reset()
160-
expect_equal(tar_option_get("memory"), "auto")
160+
expect_equal(tar_option_get("memory"), "transient")
161161
expect_error(
162162
tar_option_set(memory = "invalid"),
163163
class = "tar_condition_validate"
@@ -255,23 +255,23 @@ tar_test("resources", {
255255
})
256256

257257
tar_test("storage", {
258-
expect_equal(tar_option_get("storage"), "main")
259-
tar_option_set(storage = "worker")
260258
expect_equal(tar_option_get("storage"), "worker")
261-
tar_option_reset()
259+
tar_option_set(storage = "main")
262260
expect_equal(tar_option_get("storage"), "main")
261+
tar_option_reset()
262+
expect_equal(tar_option_get("storage"), "worker")
263263
expect_error(
264264
tar_option_set(storage = "invalid"),
265265
class = "tar_condition_validate"
266266
)
267267
})
268268

269269
tar_test("retrieval", {
270-
expect_equal(tar_option_get("retrieval"), "main")
271-
tar_option_set(retrieval = "worker")
272270
expect_equal(tar_option_get("retrieval"), "worker")
273-
tar_option_reset()
271+
tar_option_set(retrieval = "main")
274272
expect_equal(tar_option_get("retrieval"), "main")
273+
tar_option_reset()
274+
expect_equal(tar_option_get("retrieval"), "worker")
275275
expect_error(
276276
tar_option_set(retrieval = "invalid"),
277277
class = "tar_condition_validate"

0 commit comments

Comments
 (0)