A template calls this just before an expensive cache_fit(). In an
interactive session (the console, or running chunks one by one) with no
cached result yet, it stops and says to run the job with
submit_job instead, because a fit that runs for hours dies
with the session. A render, a cached result, or
options(hvtiRtemplates.allow_interactive_fit = TRUE) lets it pass.
Arguments
- name
Character(1). The
cache_fit()name; the cache file is<dir>/<name>.rds.- dir
Character(1). The
cache_fit()directory.- why
Character(1). Why the fit is long, shown in the error.
- refit
Logical(1).
TRUEwhen the job will recompute the fit even though a cached file exists (the template'sREFIT); the cached file then does not make the call safe, so it is refused too.
Examples
guard_long_fit("example-fit", dir = tempdir(), why = "it takes hours")