Skip to contents

Sequential batch runner with per-series status rows and a structured CSV log. Existing outputs can be skipped via resume = TRUE.

Usage

sa_batch_run(
  series,
  out_dir = "sa_reports",
  ids = NULL,
  resume = TRUE,
  timeout = Inf,
  report_fun = sa_report_html,
  log_file = NULL,
  ...
)

Arguments

series

A ts object or a non-empty list of series.

out_dir

Directory where HTML reports and _sa_run_log.csv are written.

ids

Optional character vector of IDs, same length as series.

resume

If TRUE, existing output files are skipped and logged as skipped.

timeout

Per-series timeout in seconds. Use Inf to run in the current R process without a timeout. Finite values require the suggested callr package and run each case in a clean subprocess.

report_fun

Report function to call per item. Defaults to sa_report_html().

log_file

Optional CSV log path. Defaults to _sa_run_log.csv in out_dir.

...

Additional arguments passed to report_fun.

Value

A tibble with one row per series: id, ok, status, reason, message, outfile, and elapsed_seconds.

Examples

fake_report <- function(y, outfile, ...) {
  writeLines("<html><body>ok</body></html>", outfile)
  list(report = outfile)
}
out <- sa_batch_run(
  series = list(series1 = AirPassengers),
  out_dir = tempdir(),
  report_fun = fake_report
)
out$status
#> [1] "ok"