Manifest¶
A manifest.json is written next to every generated split, holding the seed,
the fold count, a SHA-256 per input file, record counts, and a fold_digest —
a hash over the whole record-to-fold mapping in canonical order, so two runs
agree if and only if they produced the same partition.
That is what makes the recipe distribution
of a restricted dataset's splits verifiable: verify_splits() compares your
local run against the reference manifest shipped in
ecgbench/data/manifests/<slug>.json and names the differing input file on
mismatch.
manifest
¶
Split manifests: how a split is reproduced when it cannot be published.
Fold CSVs are identifiers only, but for a credentialed or restricted dataset
those identifiers are still derived from data under a use agreement, and
ECGBench's HuggingFace repo is public and ungated. Such datasets set
publish_fold_csvs: false in their config and are distributed as a recipe
instead of as data: the user regenerates the split on their own copy, and this
manifest is what proves the result is the canonical one rather than merely
plausible.
A manifest records four things:
- the seed and fold count, read from the split result rather than assumed, so the partition is a pure function of documented inputs;
- a SHA-256 of every input file the split was computed from (the metadata
table, and the label source when it is a separate file). This is the part that
matters most in practice: a split is only reproducible if the input is
byte-identical, and local copies do get filtered. We hit exactly that with
MIMIC-IV-ECG, where a local
machine_measurements.csvhad been reduced to 789,481 of 800,035 rows — regenerating from it silently yields different folds; - the record counts for both versions;
- a fold digest — a SHA-256 over the whole
record_id,foldmapping in a canonical order. Two runs agree on this digest if and only if they produced the same partition, so a one-line comparison replaces trusting the procedure.
ecgbench splits writes manifest.json into the output directory for every
dataset. For datasets that ECGBench cannot publish, a reference copy is shipped
in the package under ecgbench/data/manifests/ so users can verify without
network access.
ManifestMismatchError
¶
Bases: RuntimeError
A locally generated split does not match the reference manifest.
fold_digest
¶
Return a SHA-256 over the record-to-fold mapping, order-independent.
Rows are sorted by record identifier and rendered as id,fold lines, so
the digest depends on the partition and nothing else — not on row order, not
on which columns happen to be present, and not on CSV formatting.
Source code in ecgbench/manifest.py
file_digest
¶
SHA-256 of a file, streamed so large metadata tables do not load fully.
Source code in ecgbench/manifest.py
input_digests
¶
input_digests(data_path: Path, config: DatasetConfig) -> dict[str, dict[str, Any]]
Checksum every input the split is computed from.
That is the dataset's metadata table plus, when the labels live in a separate file, the label source. Files that do not exist are recorded as absent rather than skipped, so a manifest never silently omits an input.
Source code in ecgbench/manifest.py
build_manifest
¶
build_manifest(config: DatasetConfig, data_path: Path, original_df: DataFrame, clean_df: DataFrame, n_folds: int, random_state: int | None) -> dict[str, Any]
Assemble the manifest for one ecgbench splits run.
Source code in ecgbench/manifest.py
load_reference_manifest
¶
Return the manifest shipped with the package for slug, if any.
Source code in ecgbench/manifest.py
verify_splits
¶
Check a locally generated split against the manifest shipped for slug.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slug
|
str
|
dataset slug, e.g. |
required |
output_dir
|
Path | str
|
the directory |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A report dict with |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
no reference manifest ships for this dataset, or the local run is missing. |
ManifestMismatchError
|
the local split differs from the canonical one. |