Skip to contents

Creates the record of one analysis run (rmoriebricklayer::mkmnf()), adds a cross-check per row of checks (rmoriebricklayer::recrd(): PASS within tol, DIFFER outside it, INFO on synthetic data), and writes it as JSON when path is given (rmoriebricklayer::wrmnfjs()). morie_capsule_verify() re-checks the recorded verdicts, morie_capsule_compare() recomputes the numbers, and morie_capsule_sign() / morie_capsule_bundle() sign it.

Usage

morie_capsule_manifest(
  meta = list(),
  checks = NULL,
  path = NULL,
  env = TRUE,
  canonical = FALSE
)

Arguments

meta

A named list of run metadata (project, author, ...).

checks

NULL, or a data frame with one cross-check per row: name, observed, expected and optionally tol (absolute; default 1e-4) and group (default "general").

path

Where to write the manifest as JSON, or NULL to write nothing.

env

Record the R environment.

canonical

Write the one-line canonical form (keys sorted, what the digest is taken over) rather than pretty JSON.

Value

The manifest: a list with meta, results and, with env = TRUE, environment. When path is given it is returned invisibly, with the path as attribute "path".

Details

With env = TRUE the R version, platform and package versions are recorded. The package versions are kept as a named list rather than the named vector mkmnf() returns, so the manifest's digest is the same after it is written and read back.

Errors: meta not a list; checks not a data frame with columns name, observed and expected, or with a repeated name; path not one string; env or canonical not TRUE or FALSE.

Examples

checks <- data.frame(name = c("n", "mean_x"), observed = c(10, 5.5),
                     expected = c(10, 5.5))
man <- suppressMessages(morie_capsule_manifest(list(project = "demo"),
                                               checks, env = FALSE))
vapply(man$results, `[[`, "", "status")
#>      n mean_x 
#> "PASS" "PASS" 
path <- tempfile(fileext = ".json")
suppressMessages(morie_capsule_manifest(list(project = "demo"), checks,
                                        path = path, env = FALSE))
file.exists(path)
#> [1] TRUE
try(morie_capsule_manifest(list(), data.frame(name = "n")))
#> Error : `checks` must be a data frame with columns name, observed and expected