Skip to contents

Filters the original mask of r0 down to the cases for which success == FALSE and re-runs genproc() on that subset. Useful when a transient external problem caused some cases to fail and the user has fixed the cause: rather than re-running the whole mask, only the failed cases are refreshed.

Usage

rerun_failed(
  r0,
  f,
  parallel = NULL,
  nonblocking = NULL,
  track_inputs = TRUE,
  input_cols = NULL,
  skip_input_cols = NULL
)

Arguments

r0

A genproc_result produced by genproc(). Its $reproducibility$mask_snapshot provides the original mask.

f

A function. Typically the same function passed to the original genproc() call. The result object does not store f, so it must be supplied here. If the previous failures were caused by a bug in f, pass the corrected version.

parallel, nonblocking, track_inputs, input_cols, skip_input_cols

Forwarded to genproc() for the re-run.

Value

A new genproc_result covering only the failed cases. Its case_ids are local to the subset (re-numbered starting at case_0001); the link back to the original r0 is via the matching rows of r0$reproducibility$mask_snapshot. If r0 has zero failed cases, the function returns NULL with a message — there is nothing to re-run.

Examples

r0 <- genproc(
  f = function(x) if (x %% 2 == 0) stop("even") else x,
  mask = data.frame(x = 1:6)
)
# 3 cases failed (the even ones). After fixing f, retry only those:
# \donttest{
  r1 <- rerun_failed(r0, f = function(x) abs(x))
  r1$log
#>     case_id x success error_message traceback duration_secs
#> 1 case_0001 2    TRUE          <NA>      <NA>             0
#> 2 case_0002 4    TRUE          <NA>      <NA>             0
#> 3 case_0003 6    TRUE          <NA>      <NA>             0
# }