The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
{bakerrr} provides a clean, modern interface for running background parallel jobs using S7 classes, mirai daemon(s), and callr process management. Perfect for computationally intensive workflows that need robust error handling and progress monitoring.
You can install the development version of bakerrr from CRAN with:
install.packages("bakerrr")
# Define your function
<- function(x, y) {
compute_sum Sys.sleep(1) # Simulate work
+ y
x
}
# Create argument lists for each job
<- list(
args_list list(x = 1, y = 2),
list(x = 3, y = 4),
list(x = 5, y = 6),
list(x = 7, y = 8)
)
# Create and run bakerrr job
<- bakerrr::bakerrr(
job fun = compute_sum,
args_list = args_list,
n_daemons = 2
|>
) ::run_jobs(wait_for_results = TRUE)
bakerrr
# Check results
@results
job#> [[1]]
#> [1] 3
#>
#> [[2]]
#> [1] 7
#>
#> [[3]]
#> [1] 11
#>
#> [[4]]
#> [1] 15
print(job)
#> [01] function (x, y) { Sys.sleep(1) x + y }
#> [02] function (x, y) { Sys.sleep(1) x + y }
#> [03] function (x, y) { Sys.sleep(1) x + y }
#> [04] function (x, y) { Sys.sleep(1) x + y }
# Function that may fail
<- function(x) {
risky_function if (x == "error") stop("Intentional error")
* 2
x
}
<- list(
args_list list(x = 5),
list(x = "error"), # This will fail gracefully
list(x = 10)
)
<- bakerrr::bakerrr(risky_function, args_list) |>
job ::run_jobs(wait_for_results = FALSE)
bakerrr@results
job#> [1] "running"
#> [[1]] [1] 10
#> [[2]] [1] "Error in purrr::in_parallel: Intentional error"
#> [[3]] [1] 20
# Custom logging and process options
<- function(x, y) {
compute_sum Sys.sleep(1) # Simulate work
+ y
x
}
# Create argument lists for each job
<- list(
args_list list(x = 1, y = 2),
list(x = 3, y = 4),
list(x = 5, y = 6),
list(x = 7, y = 8)
)<- bakerrr::bakerrr(
job fun = compute_sum,
args_list = args_list,
bg_args = list(
stdout = "job_output.log",
stderr = "job_errors.log",
supervise = TRUE
)|>
) ::run_jobs(wait_for_results = FALSE) bakerrr
<- function() {
long_running_function Sys.sleep(5)
}# Start job without waiting
<- bakerrr::bakerrr(long_running_function, args_list) |>
job ::run_jobs(wait_for_results = FALSE)
bakerrr
# Check status later
summary(job)
#> Length Class1 Class2 Mode
#> 1 bakerrr::bakerrr S7_object object
#> ⏳ BackgroundParallelJob [running] - 4 daemon(s), 10 jobs
# Get results when ready
if (!job@bg_job_status$is_alive()) {
<- job@results
results }
You can run multiple different functions, each with their own arguments, in parallel background jobs using {bakerrr}. Just supply a list of functions and a matching list of argument sets:
# List of functions with different logic
<- list(
fun_list function(x, y) x + y,
function(x, y) x * y,
function(x, y) x - y,
function(x, y) x / y,
function(x, y) x^y,
function(x, y) x %% y,
function(x, y) paste0(x, "-", y),
function(x, y) mean(c(x, y)),
function(x, y) max(x, y),
function(x, y) min(x, y)
)
# Corresponding list of argument sets
set.seed(1)
<- list(
args_list list(x = 3, y = 6),
list(x = "p", y = 2), # type error
list(x = 5, y = 8),
list(x = 10, y = 2),
list(x = 2, y = 5),
list(x = 13, y = 4),
list(x = "A", y = 7), # type error
list(x = 6, y = 9),
list(x = 3, y = 4),
list(x = 1, y = 2)
)
# Run jobs in parallel
<- bakerrr::bakerrr(
job fun = fun_list,
args_list = args_list,
n_daemons = 4
|> bakerrr::run_jobs(wait_for_results = TRUE)
)
# Inspect results and status
@results
job#> [[1]]
#> [1] 9
#>
#> [[2]]
#> Error in purrr::in_parallel: non-numeric argument to binary operator
#>
#> [[3]]
#> [1] -3
#>
#> [[4]]
#> [1] 5
#>
#> [[5]]
#> [1] 32
#>
#> [[6]]
#> [1] 1
#>
#> [[7]]
#> [1] "A-7"
#>
#> [[8]]
#> [1] 7.5
#>
#> [[9]]
#> [1] 4
#>
#> [[10]]
#> [1] 1
print(job)
#> [01] function (x, y) x + y
#> [02] function (x, y) x * y
#> [03] function (x, y) x - y
#> [04] function (x, y) x/y
#> [05] function (x, y) x^y
#> [06] function (x, y) x%%y
#> [07] function (x, y) paste0(x, "-", y)
#> [08] function (x, y) mean(c(x, y))
#> [09] function (x, y) max(x, y)
#> [10] function (x, y) min(x, y)
summary(job)
#> Length Class1 Class2 Mode
#> 1 bakerrr::bakerrr S7_object object
::status(job)
bakerrr#> [1] "done"
citation("bakerrr")
#> To cite package 'bakerrr' in publications use:
#>
#> Shaw A (2025). _bakerrr: Background-Parallel Jobs_. R package version
#> 0.2.0, <https://github.com/anirbanshaw24/bakerrr>.
#>
#> A BibTeX entry for LaTeX users is
#>
#> @Manual{,
#> title = {bakerrr: Background-Parallel Jobs},
#> author = {Anirban Shaw},
#> year = {2025},
#> note = {R package version 0.2.0},
#> url = {https://github.com/anirbanshaw24/bakerrr},
#> }
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.