@@ -59,10 +59,6 @@ IAS_process <- function(env_file = ".env", n_cores = 6L, overwrite = TRUE) {
59
59
60
60
rm(AllArgs , envir = environment())
61
61
62
- withr :: local_options(
63
- future.globals.maxSize = 8000 * 1024 ^ 2 , future.gc = TRUE ,
64
- future.seed = TRUE )
65
-
66
62
# # ..................................................................... ###
67
63
68
64
# Avoid "no visible binding for global variable" message
@@ -167,21 +163,8 @@ IAS_process <- function(env_file = ".env", n_cores = 6L, overwrite = TRUE) {
167
163
.StartTimeDist <- lubridate :: now(tzone = " CET" )
168
164
169
165
# # Prepare working on parallel -----
170
- IASDT.R :: cat_time(
171
- paste0(" Prepare working on parallel using " , n_cores , " cores" ),
172
- level = 1 )
173
-
174
- if (n_cores == 1 ) {
175
- future :: plan(" future::sequential" , gc = TRUE )
176
- } else {
177
- withr :: local_options(
178
- future.globals.maxSize = 8000 * 1024 ^ 2 , future.gc = TRUE ,
179
- future.seed = TRUE )
180
- c1 <- snow :: makeSOCKcluster(n_cores )
181
- on.exit(try(snow :: stopCluster(c1 ), silent = TRUE ), add = TRUE )
182
- future :: plan(" future::cluster" , workers = c1 , gc = TRUE )
183
- withr :: defer(future :: plan(" future::sequential" , gc = TRUE ))
184
- }
166
+ IASDT.R :: set_parallel(n_cores = n_cores , level = 1 )
167
+ withr :: defer(future :: plan(" future::sequential" , gc = TRUE ))
185
168
186
169
# # .................................... ###
187
170
@@ -199,18 +182,15 @@ IAS_process <- function(env_file = ".env", n_cores = 6L, overwrite = TRUE) {
199
182
future.packages = c(
200
183
" dplyr" , " lubridate" , " IASDT.R" , " purrr" , " stringr" , " readr" , " fs" ,
201
184
" sf" , " terra" , " readxl" , " tidyr" , " tidyselect" , " ggplot2" , " ggtext" ,
202
- " grid" , " tidyterra" , " cowplot" , " scales" ),
185
+ " grid" , " tidyterra" , " cowplot" , " scales" , " tibble" , " magrittr" , " ragg" ,
186
+ " grDevices" ),
203
187
future.globals = c(" env_file" , " overwrite" )) %> %
204
188
dplyr :: bind_rows()
205
189
206
190
# # .................................... ###
207
191
208
192
# # Stopping cluster ----
209
- IASDT.R :: cat_time(" Stopping cluster" , level = 1 )
210
- if (n_cores > 1 ) {
211
- snow :: stopCluster(c1 )
212
- future :: plan(" future::sequential" , gc = TRUE )
213
- }
193
+ IASDT.R :: set_parallel(stop = TRUE , level = 2 )
214
194
215
195
IASDT.R :: cat_diff(
216
196
init_time = .StartTimeDist ,
0 commit comments