batch: batch maps a function to a batched version of that function.

Description Usage Arguments Value Examples

Description

batch maps a function to a batched version of that function.

Usage

1
2
3
4
batch(batch_fn, keys, splitting_strategy = NULL,
  combination_strategy = batchman::combine, size = 50, trycatch = FALSE,
  batchman.verbose = isTRUE(interactive()), stop = FALSE, retry = 0,
  sleep = 0, ncores = parallel::detectCores(), parallel = FALSE)

Arguments

batch_fn

function. The method to batch over.

keys

vector. The names of the keys within the function to batch. Can be "..." if one is batching a splat function with no keys.

splitting_strategy

function. The strategy used to split up inputs. Leave NULL to use the versatile default splitting strategy.

combination_strategy

function. The strategy used to recombine batches. Defaults to class-agnostic combination.

size

numeric. The size of the packets. Default 50.

trycatch

logical. Whether to wrap the function in a tryCatch block. Can be used to store and retrieve partial progress on an error.

batchman.verbose

logical. Whether or not to announce progress by printing dots.

stop

logical. Whether trycatch should stop if an error is raised.

retry

integer. The number of times to retry on error. 0 for no retrying.

sleep

integer. Time in seconds to sleep between batches.

ncores

integer. Number of cores to use if parallel is set to true. Notice that it doesn't work on windows.

parallel

logical. Use parallel::mclapply to execute your batches. Incompatible with retry.

Value

a batched version of the passed function.

Examples

1
2
3
  batched_identity <- batch(identity, "x", combination_strategy = c, size = 10)
  batched_identity(seq(100))
  # Does identity, but in batches of 10.

peterhurford/batchman documentation built on March 18, 2021, 8:36 a.m.