
Save and read staged Opal objects
opal_io.RdEvery stage is portable. Saved objects contain a checksum of the complete payload; their transient RTMB objective is never serialised. Reads verify the checksum and scientific contract. Legacy fits are converted with objective verification. No read operation optimises or samples.
Usage
opal_save(x, file, compress = "gzip", overwrite = FALSE)
opal_read(
file,
rebuild = FALSE,
strict = TRUE,
integrity = c("portable", "exact")
)Arguments
- x
An
opal_objor legacyopal_fitto save.- file
RDS path.
- compress
RDS compression.
- overwrite
Allow replacement of an existing file.
- rebuild
Rebuild a configured object's runtime after reading.
- strict
Reject incompatible scientific contracts. FALSE permits inspection only; runtime access still rejects an incompatible model.
- integrity
Verification mode for legacy files:
"portable"checks the rebuilt objective across R versions;"exact"also requires the original runtime checksum. New-format files always verify their payload checksum, independently of this legacy option.
Details
Assign the return value of opal_read() to resume work in another session.
Use rebuild = TRUE to verify runtime reconstruction immediately. Existing
files are protected by default; set overwrite = TRUE deliberately when
saving an updated assessment to the same path.
See also
Other assessment workflow:
opal_attach_fit(),
opal_attach_mcmc(),
opal_build(),
opal_check(),
opal_derived(),
opal_example_inputs(),
opal_fit(),
opal_from_fit(),
opal_mcmc(),
opal_obj(),
opal_posterior(),
opal_project(),
opal_report(),
opal_update()
Examples
inputs <- opaka_quickstart_inputs()
assessment <- opal_obj(inputs$data, inputs$parameters, inputs$map)
path <- tempfile(fileext = ".rds")
opal_save(assessment, path)
restored <- opal_read(path, rebuild = TRUE)
summary(restored)
#> <opal_obj> built
#> Active parameters: 127
#> Fit check: not run | MCMC check: not run
unlink(path)