When contract enforcement is enabled (env DAF_ENFORCE_CONTRACTS=1
or options(dafr.enforce_contracts = TRUE)), returns a
ContractDaf that tracks access and rejects operations outside
contract. Otherwise returns daf unchanged.
Arguments
- computation
Name of the computation (character scalar).
- contract
A
Contract()describing expected inputs and outputs.- daf
- name
Optional name for the wrapper; defaults to
<daf-name>.<computation>.- overwrite
If
TRUE, pre-existingCreatedOutputproperties are allowed.
Value
daf itself, or a ContractDaf wrapping it.
Examples
withr::with_options(list(dafr.enforce_contracts = TRUE), {
c <- Contract(
axes = list(cell = list(RequiredInput, "per-cell axis")),
data = list(contract_vector("cell", "donor",
RequiredInput, "character", "donor id"))
)
d <- memory_daf()
add_axis(d, "cell", c("c1", "c2"))
set_vector(d, "cell", "donor", c("d1", "d2"))
cd <- contractor("demo", c, d)
class(cd)[[1]]
})
#> [1] "dafr::ContractDaf"