Title: Background-Parallel Jobs
Version: 0.1.0
Description: Easily launch, track, and control functions as background-parallel jobs. Includes robust utilities for job status, error handling, resource monitoring, and result collection. Designed for scalable workflows in interactive and automated settings (local or remote). Integrates with multiple backends; supports flexible automation pipelines and live job tracking. For more information, see https://anirbanshaw24.github.io/bakerrr/.
License: MIT + file LICENSE
URL: https://github.com/anirbanshaw24/bakerrr
BugReports: https://github.com/anirbanshaw24/bakerrr/issues
Depends: R (≥ 4.1.0)
Imports: callr, carrier, cli, config, fs, glue, mirai, purrr, S7
Suggests: covr, DT, htmltools, knitr, lintr, qpdf, rmarkdown, spelling, testthat (≥ 3.0.0)
VignetteBuilder: knitr
Config/testthat/edition: 3
Encoding: UTF-8
Language: en-US
RoxygenNote: 7.3.3
NeedsCompilation: no
Packaged: 2025-09-25 10:40:26 UTC; shawa11
Author: Anirban Shaw ORCID iD [aut, cre]
Maintainer: Anirban Shaw <anirbanshaw24@gmail.com>
Repository: CRAN
Date/Publication: 2025-10-01 07:40:02 UTC

S7 bakerrr class for job orchestration and background processing

Description

Defines the bakerrr S7 class for parallel and background job execution. Stores the function to run (fun), argument lists (args_list), background job arguments (bg_args), job objects, results, and runtime properties. Supports retrieval of job status/results and validation of provided properties.

Usage

bakerrr(
  fun,
  args_list,
  bg_args = list(),
  n_daemons = ceiling(parallel::detectCores()/5),
  cleanup = TRUE
)

Arguments

fun

Function to be executed for each job.

args_list

List of argument sets for each job.

bg_args

List of arguments passed to background job handler.

n_daemons

Number of parallel workers (default: ceiling of cores/5).

cleanup

Logical; whether to clean up jobs after execution (default: TRUE).

Value

An S7 bakerrr class object with job orchestration methods and properties.

Examples

# Create a bakerrr object to process jobs in parallel
bakerrr::bakerrr(fun = sum, args_list = list(list(1:10), list(10:20)))


Background parallel processing of jobs using purrr and tryCatch

Description

Executes a list of job specifications in parallel, applies the given function with error handling, and collects the results or error messages.

Usage

bg_func(jobs, n_daemons)

Arguments

jobs

A list of job specifications, each containing a function (fun) and arguments (args).

n_daemons

Number of parallel workers

Value

A list of results, with error messages in case of failure.


Print method for bakerrr S7 job objects

Description

Displays a concise summary of the bakerrr job object, including current status, function name, number of argument sets, daemon count, cleanup setting, process status, and result summary. Outputs a status icon and key runtime information for quick inspection.

Arguments

x

A bakerrr S7 job object.

...

Additional arguments (currently ignored).

Value

The input x, invisibly, after printing the summary.


Generic for running background jobs in bakerrr

Description

Initiates background execution for a bakerrr job object, launching jobs via callr::r_bg. Stores process status in bg_job_status.

Usage

run_bg(x, ...)

Arguments

x

A bakerrr S7 job object.

...

Not used. For future expansion.

Value

The input x, invisibly, after launching background jobs.


Run bakerrr jobs and wait for completion

Description

Launches the parallel jobs, manages daemon setup (mirai::daemons), initiates background jobs, provides a console spinner for progress, and optionally waits for results. Cleans up daemons after execution.

Usage

run_jobs(job, wait_for_results, ...)

Arguments

job

A bakerrr S7 job object.

wait_for_results

Logical; whether to block and wait for completion (default: TRUE).

...

Not used. For future expansion.

Value

The updated bakerrr job object, invisibly.


Status method for bakerrr S7 job objects

Description

Returns job status as "waiting", "running", or "done".

Usage

status(x, ...)

Arguments

x

A bakerrr S7 job object.

...

Further arguments (ignored).

Value

One of "waiting", "running", "done".


Summary method for bakerrr S7 job objects

Description

Provides a one-line summary of a bakerrr job object, indicating the status, function name, number of worker daemons, and total jobs. Prints a status icon and brief job info.

Usage

summary(x, ...)

Arguments

x

A bakerrr S7 job object.

...

Additional arguments (currently ignored).

Value

The input x, invisibly, after printing the summary.