Learn R Programming

PubChemR (version 3.0.0)

pc_batch: Batch-Orchestrate PubChem Workflows

Description

Splits identifier vectors into chunks, applies a worker function per chunk, and records per-chunk success and error metadata.

Usage

pc_batch(
  ids,
  fn,
  chunk_size = 100,
  parallel = FALSE,
  workers = NULL,
  checkpoint_dir = NULL,
  checkpoint_id = NULL,
  resume = FALSE,
  rerun_failed = TRUE,
  ...
)

Value

A typed `PubChemBatchResult` object.

Arguments

ids

Identifier vector.

fn

Function to run on each chunk of `ids`.

chunk_size

Chunk size.

parallel

Logical; use parallel execution.

workers

Number of workers.

checkpoint_dir

Optional directory to persist per-chunk checkpoint files.

checkpoint_id

Optional checkpoint run id. If `NULL`, a deterministic id is generated.

resume

Logical; resume from an existing checkpoint manifest.

rerun_failed

Logical; when resuming, rerun chunks previously marked as failed.

...

Additional arguments passed into `fn`.

Details

Checkpoint files can be written to disk and resumed later. Parallel execution is available on supported platforms when checkpointing is disabled.

Examples

Run this code
batch <- pc_batch(
  ids = 1:6,
  fn = function(chunk_ids, ...) sum(chunk_ids),
  chunk_size = 2
)
length(batch$results)

Run the code above in your browser using DataLab