Skip to content

Commit 54c93d0

Browse files
committed
garbage collection integer
1 parent 9843fbd commit 54c93d0

26 files changed

+174
-178
lines changed

NEWS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
# targets 1.8.0.9003 (development)
1+
# targets 1.8.0.9004 (development)
22

33
* Un-break workflows that use `format = "file_fast"` (#1339, @koefoeden).
44
* Fix deadlock in `error = "trim"` (#1340, @koefoeden).
55
* Remove tailored debugging message (#1341, @koefoeden).
66
* Store warnings while writing to storage (#1345, @Aariq).
7+
* Deprecate the `garbage_collection` argument of `tar_make()`, `tar_make_future()`, and `tar_make_clusterm()` (#1351).
78

89
# targets 1.8.0
910

R/class_active.R

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ active_new <- function(
88
seconds_meta_append = NULL,
99
seconds_meta_upload = NULL,
1010
seconds_reporter = NULL,
11-
garbage_collection = NULL,
1211
envir = NULL
1312
) {
1413
active_class$new(
@@ -21,7 +20,6 @@ active_new <- function(
2120
seconds_meta_append = seconds_meta_append,
2221
seconds_meta_upload = seconds_meta_upload,
2322
seconds_reporter = seconds_reporter,
24-
garbage_collection = garbage_collection,
2523
envir = envir
2624
)
2725
}
@@ -32,7 +30,6 @@ active_class <- R6::R6Class(
3230
portable = FALSE,
3331
cloneable = FALSE,
3432
public = list(
35-
garbage_collection = NULL,
3633
envir = NULL,
3734
exports = NULL,
3835
process = NULL,
@@ -49,8 +46,7 @@ active_class <- R6::R6Class(
4946
seconds_meta_append = NULL,
5047
seconds_meta_upload = NULL,
5148
seconds_reporter = NULL,
52-
envir = NULL,
53-
garbage_collection = NULL
49+
envir = NULL
5450
) {
5551
super$initialize(
5652
pipeline = pipeline,
@@ -63,7 +59,6 @@ active_class <- R6::R6Class(
6359
seconds_meta_upload = seconds_meta_upload,
6460
seconds_reporter = seconds_reporter
6561
)
66-
self$garbage_collection <- garbage_collection
6762
self$envir <- envir
6863
},
6964
ensure_meta = function() {
@@ -229,9 +224,6 @@ active_class <- R6::R6Class(
229224
if (!is.null(self$process)) {
230225
self$process$validate()
231226
}
232-
tar_assert_lgl(self$garbage_collection)
233-
tar_assert_scalar(self$garbage_collection)
234-
tar_assert_none_na(self$garbage_collection)
235227
}
236228
)
237229
)

R/class_clustermq.R

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ clustermq_init <- function(
88
seconds_meta_append = 0,
99
seconds_meta_upload = 15,
1010
seconds_reporter = 0,
11-
garbage_collection = FALSE,
1211
envir = tar_option_get("envir"),
1312
workers = 1L,
1413
log_worker = FALSE
@@ -23,7 +22,6 @@ clustermq_init <- function(
2322
seconds_meta_append = seconds_meta_append,
2423
seconds_meta_upload = seconds_meta_upload,
2524
seconds_reporter = seconds_reporter,
26-
garbage_collection = garbage_collection,
2725
envir = envir,
2826
workers = as.integer(workers),
2927
log_worker = log_worker
@@ -40,7 +38,6 @@ clustermq_new <- function(
4038
seconds_meta_append = NULL,
4139
seconds_meta_upload = NULL,
4240
seconds_reporter = NULL,
43-
garbage_collection = NULL,
4441
envir = NULL,
4542
workers = NULL,
4643
log_worker = NULL
@@ -55,7 +52,6 @@ clustermq_new <- function(
5552
seconds_meta_append = seconds_meta_append,
5653
seconds_meta_upload = seconds_meta_upload,
5754
seconds_reporter = seconds_reporter,
58-
garbage_collection = garbage_collection,
5955
envir = envir,
6056
workers = workers,
6157
log_worker = log_worker
@@ -81,7 +77,6 @@ clustermq_class <- R6::R6Class(
8177
seconds_meta_append = NULL,
8278
seconds_meta_upload = NULL,
8379
seconds_reporter = NULL,
84-
garbage_collection = NULL,
8580
envir = NULL,
8681
workers = NULL,
8782
log_worker = NULL
@@ -96,7 +91,6 @@ clustermq_class <- R6::R6Class(
9691
seconds_meta_append = seconds_meta_append,
9792
seconds_meta_upload = seconds_meta_upload,
9893
seconds_reporter = seconds_reporter,
99-
garbage_collection = garbage_collection,
10094
envir = envir
10195
)
10296
self$workers <- as.integer(workers)
@@ -130,9 +124,6 @@ clustermq_class <- R6::R6Class(
130124
},
131125
run_worker = function(target) {
132126
builder_marshal_subpipeline(target)
133-
if (self$garbage_collection) {
134-
gc()
135-
}
136127
self$worker_list$send(
137128
cmd = targets::target_run_worker(
138129
target = target,
@@ -247,7 +238,6 @@ clustermq_class <- R6::R6Class(
247238
names = self$names,
248239
queue = self$queue,
249240
reporter = self$reporter,
250-
garbage_collection = self$garbage_collection,
251241
seconds_meta_append = self$seconds_meta_append,
252242
seconds_meta_upload = self$seconds_meta_upload,
253243
seconds_reporter = self$seconds_reporter,

R/class_crew.R

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ crew_init <- function(
88
seconds_meta_append = 0,
99
seconds_meta_upload = 15,
1010
seconds_reporter = 0,
11-
garbage_collection = FALSE,
1211
envir = tar_option_get("envir"),
1312
controller = NULL,
1413
terminate_controller = TRUE
@@ -23,7 +22,6 @@ crew_init <- function(
2322
seconds_meta_append = seconds_meta_append,
2423
seconds_meta_upload = seconds_meta_upload,
2524
seconds_reporter = seconds_reporter,
26-
garbage_collection = garbage_collection,
2725
envir = envir,
2826
controller = controller,
2927
terminate_controller = terminate_controller
@@ -40,7 +38,6 @@ crew_new <- function(
4038
seconds_meta_append = NULL,
4139
seconds_meta_upload = NULL,
4240
seconds_reporter = NULL,
43-
garbage_collection = NULL,
4441
envir = NULL,
4542
controller = NULL,
4643
terminate_controller = NULL
@@ -55,7 +52,6 @@ crew_new <- function(
5552
seconds_meta_append = seconds_meta_append,
5653
seconds_meta_upload = seconds_meta_upload,
5754
seconds_reporter = seconds_reporter,
58-
garbage_collection = garbage_collection,
5955
envir = envir,
6056
controller = controller,
6157
terminate_controller = terminate_controller
@@ -80,7 +76,6 @@ crew_class <- R6::R6Class(
8076
seconds_meta_append = NULL,
8177
seconds_meta_upload = NULL,
8278
seconds_reporter = NULL,
83-
garbage_collection = NULL,
8479
envir = NULL,
8580
controller = NULL,
8681
terminate_controller = NULL
@@ -95,7 +90,6 @@ crew_class <- R6::R6Class(
9590
seconds_meta_append = seconds_meta_append,
9691
seconds_meta_upload = seconds_meta_upload,
9792
seconds_reporter = seconds_reporter,
98-
garbage_collection = garbage_collection,
9993
envir = envir
10094
)
10195
self$controller <- controller
@@ -136,9 +130,6 @@ crew_class <- R6::R6Class(
136130
return()
137131
}
138132
# nocov end
139-
if (self$garbage_collection) {
140-
gc()
141-
}
142133
self$ensure_exports()
143134
command <- quote(
144135
targets::target_run_worker(
@@ -262,7 +253,6 @@ crew_class <- R6::R6Class(
262253
names = self$names,
263254
queue = self$queue,
264255
reporter = self$reporter,
265-
garbage_collection = self$garbage_collection,
266256
seconds_meta_append = self$seconds_meta_append,
267257
seconds_meta_upload = self$seconds_meta_upload,
268258
seconds_reporter = self$seconds_reporter,

R/class_local.R

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ local_init <- function(
2020
seconds_meta_append = seconds_meta_append,
2121
seconds_meta_upload = seconds_meta_upload,
2222
seconds_reporter = seconds_reporter,
23-
garbage_collection = FALSE,
2423
envir = envir
2524
)
2625
}
@@ -35,7 +34,6 @@ local_new <- function(
3534
seconds_meta_append = NULL,
3635
seconds_meta_upload = NULL,
3736
seconds_reporter = NULL,
38-
garbage_collection = NULL,
3937
envir = NULL
4038
) {
4139
local_class$new(
@@ -48,7 +46,6 @@ local_new <- function(
4846
seconds_meta_append = seconds_meta_append,
4947
seconds_meta_upload = seconds_meta_upload,
5048
seconds_reporter = seconds_reporter,
51-
garbage_collection = garbage_collection,
5249
envir = envir
5350
)
5451
}

R/class_options.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ options_class <- R6::R6Class(
317317
self$memory %|||% "persistent"
318318
},
319319
get_garbage_collection = function() {
320-
self$garbage_collection %|||% FALSE
320+
self$garbage_collection %|||% 0L
321321
},
322322
get_deployment = function() {
323323
self$deployment %|||% "worker"
@@ -407,7 +407,7 @@ options_class <- R6::R6Class(
407407
},
408408
set_garbage_collection = function(garbage_collection) {
409409
self$validate_garbage_collection(garbage_collection)
410-
self$garbage_collection <- garbage_collection
410+
self$garbage_collection <- as.integer(garbage_collection)
411411
},
412412
set_deployment = function(deployment) {
413413
self$validate_deployment(deployment)
@@ -523,8 +523,10 @@ options_class <- R6::R6Class(
523523
tar_assert_flag(memory, c("persistent", "transient"))
524524
},
525525
validate_garbage_collection = function(garbage_collection) {
526-
tar_assert_lgl(garbage_collection)
526+
tar_assert_dbl(garbage_collection)
527527
tar_assert_scalar(garbage_collection)
528+
tar_assert_none_na(garbage_collection)
529+
tar_assert_ge(garbage_collection, 0L)
528530
},
529531
validate_deployment = function(deployment) {
530532
tar_assert_flag(deployment, c("worker", "main"))

R/class_prelocal.R

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ prelocal_new <- function(
77
seconds_meta_append = NULL,
88
seconds_meta_upload = NULL,
99
seconds_reporter = NULL,
10-
garbage_collection = NULL,
1110
envir = NULL,
1211
scheduler = NULL
1312
) {
@@ -20,7 +19,6 @@ prelocal_new <- function(
2019
seconds_meta_append = seconds_meta_append,
2120
seconds_meta_upload = seconds_meta_upload,
2221
seconds_reporter = seconds_reporter,
23-
garbage_collection = garbage_collection,
2422
envir = envir,
2523
scheduler = scheduler
2624
)
@@ -41,7 +39,6 @@ prelocal_class <- R6::R6Class(
4139
seconds_meta_append = NULL,
4240
seconds_meta_upload = NULL,
4341
seconds_reporter = NULL,
44-
garbage_collection = NULL,
4542
envir = NULL,
4643
scheduler = NULL
4744
) {
@@ -54,7 +51,6 @@ prelocal_class <- R6::R6Class(
5451
seconds_meta_append = seconds_meta_append,
5552
seconds_meta_upload = seconds_meta_upload,
5653
seconds_reporter = seconds_reporter,
57-
garbage_collection = garbage_collection,
5854
envir = envir
5955
)
6056
self$scheduler <- scheduler

R/tar_config_get.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ tar_config_get_project <- function(name, yaml) {
8787
name,
8888
inherits = yaml$inherits,
8989
as_job = yaml$as_job %|||% FALSE,
90-
garbage_collection = yaml$garbage_collection %|||% FALSE,
90+
garbage_collection = yaml$garbage_collection,
9191
label = yaml$label %|||% "description",
9292
label_width = yaml$label_width %|||% 30L,
9393
level_separation = yaml$level_separation,
@@ -110,7 +110,7 @@ tar_config_get_convert <- function(name, value) {
110110
name,
111111
inherits = if_any(is.null(value), NULL, as.character(value)),
112112
as_job = as.logical(value),
113-
garbage_collection = as.logical(value),
113+
garbage_collection = if_any(is.null(value), NULL, as.logical(value)),
114114
label = as.character(value),
115115
label_width = if_any(is.null(value), NULL, as.integer(value)),
116116
level_separation = if_any(is.null(value), NULL, as.numeric(value)),

R/tar_config_set.R

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,11 @@
4242
#' `FALSE` to run as a `callr` process in the main R session
4343
#' (depending on the `callr_function` argument).
4444
#' If `as_job_` is `TRUE`, then the `rstudioapi` package must be installed.
45-
#' @param garbage_collection Logical of length 1, `garbage_collection`
46-
#' argument of [tar_make()] (if `crew` is enabled),
47-
#' [tar_make_clustermq()], and [tar_make_future()].
48-
#' Whether to run garbage collection on the main process
49-
#' before sending a target
50-
#' to a worker. For [tar_make()], this argument is
51-
#' ignored if `tar_option_get("controller")` is `NULL`.
52-
#' Independent from the `garbage_collection` argument of [tar_target()],
53-
#' which controls garbage collection on the worker.
45+
#' @param garbage_collection Deprecated. Use the `garbage_collection`
46+
#' argument of [tar_option_set()] instead to run garbage collection
47+
#' at regular intervals in a pipeline, or use the argument of the same
48+
#' name in [tar_target()] to activate garbage collection for
49+
#' a specific target.
5450
#' @param label Argument of [tar_glimpse()] and [tar_visnetwork()]
5551
#' to control node labels.
5652
#' @param label_width Argument of [tar_glimpse()] and [tar_visnetwork()]
@@ -274,6 +270,12 @@ tar_config_assert_garbage_collection <- function(garbage_collection) {
274270
if (is.null(garbage_collection)) {
275271
return()
276272
}
273+
tar_warn_deprecate(
274+
"The garbage_collection argument of tar_config_set() was deprecated ",
275+
"in version 1.8.0.9004 (2024-10-22). The garbage_collection ",
276+
"argument of tar_option_set() is more unified and featureful now. ",
277+
"Please have a look at its documentation."
278+
)
277279
tar_assert_lgl(garbage_collection)
278280
tar_assert_scalar(garbage_collection)
279281
tar_assert_none_na(garbage_collection)

0 commit comments

Comments
 (0)