You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
stop(FutureError(sprintf("Can not use %s in the future plan because it is on the list of future strategies that are not allow per option 'future.plan.disallow': %s", sQuote(clazz), commaq(noplans))))
12
+
}
13
+
}
14
+
15
+
16
+
evaluator_uses<-function(evaluator, strategy) {
17
+
if (!inherits(evaluator, strategy)) return(FALSE)
18
+
## NOTE: Yes, we are indeed inspecting the 'class' attribute itself
19
+
class<- class(evaluator)
20
+
if (class[1] ==strategy) return(TRUE)
21
+
if (length(class) ==1L) return(FALSE)
22
+
if (class[1] =="tweaked"&&class[2] ==strategy) return(TRUE)
23
+
## Special case for strategy == "multiprocess"
24
+
if (strategy=="multiprocess"&&class[length(class)] ==strategy) return(TRUE)
25
+
FALSE
26
+
}
27
+
28
+
29
+
warn_about_multicore<- local({
30
+
.warn<-TRUE
31
+
32
+
function(stack) {
33
+
if (!.warn) return()
34
+
35
+
## Is 'multicore' used despite not being supported on the current
stop(FutureError(sprintf("Can not use %s in the future plan because it is on the list of future strategies that are not allow per option 'future.plan.disallow': %s", sQuote(clazz), commaq(noplans))))
140
-
}
141
-
}
142
-
143
-
evaluator_uses<-function(evaluator, strategy) {
144
-
if (!inherits(evaluator, strategy)) return(FALSE)
145
-
## NOTE: Yes, we are indeed inspecting the 'class' attribute itself
146
-
class<- class(evaluator)
147
-
if (class[1] ==strategy) return(TRUE)
148
-
if (length(class) ==1L) return(FALSE)
149
-
if (class[1] =="tweaked"&&class[2] ==strategy) return(TRUE)
150
-
## Special case for strategy == "multiprocess"
151
-
if (strategy=="multiprocess"&&class[length(class)] ==strategy) return(TRUE)
152
-
FALSE
153
-
}
154
-
155
-
warn_about_multicore<- local({
156
-
.warn<-TRUE
157
-
158
-
function(stack) {
159
-
if (!.warn) return()
160
-
161
-
## Is 'multicore' used despite not being supported on the current
162
-
## platform?
163
-
for (kkin seq_along(stack)) {
164
-
if (evaluator_uses(stack[[kk]], "multicore")) {
165
-
supportsMulticore(warn=TRUE)
166
-
## Warn only once, if at all
167
-
.warn<<-FALSE
168
-
break
169
-
}
170
-
}
171
-
}
172
-
})
173
-
174
-
plan_cleanup<-function() {
175
-
evaluator<-stack[[1L]]
176
-
177
-
cleanup<- attr(evaluator, "cleanup", exact=TRUE)
178
-
if (!is.null(cleanup)) {
179
-
if (is.function(cleanup)) {
180
-
cleanup()
181
-
} else {
182
-
stop(FutureError(sprintf("Unknown type of 'cleanup' attribute on current future strategy: %s", commaq(class(cleanup)))))
183
-
}
184
-
} else {
185
-
## Backward compatibility for future (<= 1.33.2)
186
-
if (isTRUE(getOption("future.plan.cleanup.legacy"))) {
187
-
ClusterRegistry(action="stop")
188
-
}
189
-
}
190
-
} ## plan_cleanup()
191
-
192
-
plan_init<-function() {
193
-
evaluator<-stack[[1L]]
194
-
195
-
init<- attr(evaluator, "init", exact=TRUE)
196
-
if (identical(init, TRUE)) {
197
-
debug<- isTRUE(getOption("future.debug"))
198
-
if (debug) {
199
-
mdebugf("plan(): plan_init() of %s ...",
200
-
commaq(class(evaluator)))
201
-
mprint(evaluator)
202
-
}
203
-
204
-
## IMPORANT: Initiate only once. This avoids an infinite
205
-
## recursive loop caused by other plan() calls.
206
-
attr(evaluator, "init") <-"done"
207
-
stack[[1L]] <<-evaluator
208
-
209
-
## Create dummy future to trigger setup (minimum overhead)
210
-
f<- evaluator(NA, label="future-plan-test",
211
-
globals=FALSE, lazy=FALSE)
212
-
213
-
## Cleanup, by resolving it
214
-
## (otherwise the garbage collector would have to do it)
215
-
res<- tryCatch({
216
-
value(f)
217
-
}, FutureError=identity)
218
-
if (inherits(res, "FutureError")) {
219
-
res$message<- paste0(
220
-
"Initialization of plan() failed, because the test future used for validation failed. The reason was: ", conditionMessage(res))
221
-
stop(res)
222
-
}
223
-
224
-
if (!identical(res, NA)) {
225
-
res<-if (is.null(res)) {
226
-
"NULL"
227
-
} else {
228
-
commaq(res)
229
-
}
230
-
stop(FutureError(sprintf("Initialization of plan() failed, because the value of the test future is not NA as expected: %s", res)))
0 commit comments