Generate shared example data and write it to disk with a snapshot.json
describing the build.
Usage
build_testdata_bundle(
output_dir,
config = read_testdata_config(),
overwrite = FALSE,
allow_local = FALSE
)Arguments
- output_dir
Directory to write the bundle into. Created if needed.
- config
A config list or path to a YAML file; see
read_testdata_config(). Defaults to the checked-in config.- overwrite
If
FALSE(default), error whenoutput_direxists and is not empty. IfTRUE, replace the contents ofoutput_dir. The bundle is built in atempdir()subdirectory and copied intooutput_dironly once complete, so a failed build leaves the existing bundle untouched. Ifoutput_diristempdir()itself, the bundle is written tofile.path(tempdir(), "testdata-bundle")instead; ancestors oftempdir()are rejected.- allow_local
If
FALSE(default), error when any pipeline package lacks aRemoteSha(a local or uncommitted install). SetTRUEonly for local builds that won't be published.
Details
The pipeline is:
Simulate raw data with
create_longitudinal_study()using the config's seed and parameters.Set
Raw_SITE$site_statusto"Active"on every snapshot.Map each snapshot with
gsm.mapping::Ingest()and thegsm.mappingmapping workflows (configdomainsplusextra_mappings).Run every
gsm.krimetric workflow, including inactive ones (so the example reports show them), and thegsm.qtlmetrics.Run the
gsm.reportingworkflows, then stampSnapshotDatefromsnapshot_datesontoReporting_ResultsandReporting_Bounds.Combine reporting tables across snapshots and split them by group level.
Write CSVs of the
kri0001andcou0001analytics (Analysis_InputandAnalysis_Summary) from the final snapshot and of the 12reporting*tables.Write RDS files of
lSource(the final raw snapshot) and of 14 tables read back from those CSVs.
Rows are sorted on explicit keys so identical inputs always produce byte-identical files.
Local test data builder
This function is also gsm.core's local test data builder. When installed gsm
packages don't match a published build and at least one is local, gsm.core
calls build_testdata_bundle(output_dir, overwrite = TRUE, allow_local = TRUE) via the gsm.testdata_builder option and caches the result. Run
use_gsm_datasim() to set that option in your .Rprofile.
Snapshot
snapshot.json uses gsm.core's refresh snapshot format (version 2), written
by gsm.core::write_snapshot_json(): refresh_snapshot, key
("sha256:<fingerprint>"), created, objects (each .rds file with the
gsm.core::fresh_digest() of its R object), and packages (installed
version and remote_sha of each pipeline package, including gsm.core).
gsm-specific details live under metadata: fingerprint, inputs_hash,
simulation, r_version, and size. CSVs are a convenience copy: they
stay in the bundle (always written with LF line endings) but are not in
objects or the fingerprint.
The bundle records only what built it, not when or where it was built or how it is published; release tags and run provenance belong to the release.
fingerprintisgsm.core::fresh_fingerprint()of the object digests, so two builds with identical data share a fingerprint (andkey) regardless of build time, origin, R version, or RDS compression.inputs_hashisgsm.core::fresh_inputs_hash()ofpackages: the SHA-256 of the UTF-8 text formed by one"<package> <version> <remote_sha>"line per entry (a missingremote_shawritten asNA), sorted by package name in C-locale order and joined with"\n"(no trailing newline). Consumers can compute it from their installed packages to look up the matching bundle.