Filters the original mask of r0 down to the cases that
referenced inputs reported as changed, removed, or added by
diff_inputs(), and re-runs genproc() on that subset.
Usage
rerun_affected(
r0,
diff,
f,
parallel = NULL,
nonblocking = NULL,
track_inputs = TRUE,
input_cols = NULL,
skip_input_cols = NULL
)Arguments
- r0
A
genproc_resultproduced bygenproc(). Its$reproducibility$mask_snapshotprovides the original mask; it must containtrack_inputs = TRUE(the default).- diff
A
genproc_input_diffproduced bydiff_inputs().- f
A function. Typically the same function passed to the original
genproc()call. The result object does not storef, so it must be supplied here.- parallel, nonblocking, track_inputs, input_cols, skip_input_cols
Forwarded to
genproc()for the re-run. By default, these inherit a sensible behaviour:track_inputs = TRUE(so the re-run is itself comparable), the other arguments default toNULL(sequential, blocking, automatic input tracking).
Value
A new genproc_result covering only the affected 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 diff
reports no affected cases, the function returns NULL with a
message — there is nothing to re-run.
Details
This is the actionable end of the reproducibility layer: when an
upstream file silently drifts, you do not need to re-run the
whole mask. rerun_affected() produces a smaller run that
refreshes only the impacted outputs.
Examples
# \donttest{
# Set up a tiny workspace with one tracked input file.
csv <- tempfile(fileext = ".csv")
write.csv(iris, csv, row.names = FALSE)
count_rows <- function(p) nrow(read.csv(p))
r0 <- genproc(count_rows, data.frame(p = csv))
# ... time passes, the upstream file is silently rewritten ...
write.csv(head(iris), csv, row.names = FALSE)
r1 <- genproc(count_rows, data.frame(p = csv))
d <- diff_inputs(r0, r1)
# d$cases_affected lists the case_ids whose inputs drifted.
refreshed <- rerun_affected(r0, d, f = count_rows)
refreshed$log
#> case_id p success error_message
#> 1 case_0001 /tmp/Rtmp7l8jH3/file19667d61fec9.csv TRUE <NA>
#> traceback duration_secs
#> 1 <NA> 0
# }