future_cnd_map | R Documentation |
future_map
callsThese functions let you see the messages, warnings, and errors signalled in future_map
calls.
Currently, the only conditions (here meaning: messages, warnings,
and errors) that are kept in non-sequential future
plans are errors.
If you ran some complicated models on remote servers via future_map
,
and some of these models gave you important warnings, no functions outside of the future_map
call would ever 'know' about them.
Similar to the future_walk
series of functions, the future_cnd_map
functions will collect and preserve these conditions, but instead of converting them to strings and getting rid of the returned values, these functions will keep the conditions as S3 condition objects as well as returning the actual values in "value"
.
signal_fm_conditions
takes the result of these functions, signals all the conditions for each element (displaying them grouped together sequentially for easier reading), and returns the value of the map. evaluate_fm_results
does the same thing, but doesn't signal messages and warnings.
future_cnd_map(.x, .f, ..., .progress = FALSE,
.options = future_options())
future_cnd_imap(.x, .f, ..., .progress = FALSE,
.options = future_options())
future_cnd_map2(.x, .y, .f, ..., .progress = FALSE,
.options = future_options())
future_cnd_pmap(.l, .f, ..., .progress = FALSE,
.options = future_options())
evaluate_fm_results(future_cnd_map_results, signalErrors = TRUE)
signal_fm_conditions(future_cnd_map_results, displayErrors = TRUE)
.x |
A list or atomic vector. |
.f |
A function, formula, or atomic vector. If a function, it is used as is. If a formula, e.g.
This syntax allows you to create very compact anonymous functions. If character vector, numeric vector, or list, it
is converted to an extractor function. Character vectors index by name
and numeric vectors index by position; use a list to index by position
and name at different levels. Within a list, wrap strings in |
... |
Additional arguments passed on to |
.progress |
A logical, for whether or not to print a progress bar for multiprocess, multisession, and multicore plans. |
.options |
The |
.y |
Vectors of the same length. A vector of length 1 will be recycled. |
.l |
A list of lists. The length of |
future_cnd_map_results |
the output of one of the |
signalErrors |
whether to signal errors or ignore them. You probably should not ignore errors. |
displayErrors |
whether to display all the errors that happened in the call before signalling them. Helpful in seeing which elements went wrong. |
Like the future_walk
series of functions, the future_cnd_map
functions can be easily expanded with the future_map_maker
function. You simply need to pick the future_map
function you want to imitate and add the asStrings = FALSE
argument. For example, you could make a future_cnd_map_chr
function as easily as: future_cnd_map_chr <- future_map_maker(furrr::future_map_chr, asStrings = FALSE)
.
future_map_maker
future::plan(sequential) # other plans work fine as well
res <- future_cnd_map(1:3, function(i) {
message(i)
warning("Uh oh... ", i)
if (i==2)
warning("Additional warning!")
if (i==3)
stop("OH NO!")
i + 3
})
## Not run: signal_fm_conditions(res)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.