climate_ref_core.regression.capture
#
Capture of regression baselines from a diagnostic execution.
Capture operates on the curated subset of files persisted for an execution, not the raw output in the "scratch" directory. This avoids the need to maintain a separate ignore list for regression captures.
It produces two things:
- the small committed bundle
(
series.json/diagnostic.json/output.json) written into the test caseregression/directory, sanitised text-only for portability and tracked in git - a native snapshot: a
{relpath: NativeEntry}map recording the sha256 digest and size of every persisted native file, for the manifest and the object store.
build_native_snapshot(base_dir, relpaths)
#
Record a sha256 + size snapshot of each persisted native file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_dir
|
Path
|
The per-execution results directory the relpaths are resolved against. |
required |
relpaths
|
list[Path]
|
The persisted files (relative to |
required |
Returns:
| Type | Description |
|---|---|
dict[str, NativeEntry]
|
Mapping of POSIX relpath -> :class: |
Source code in packages/climate-ref-core/src/climate_ref_core/regression/capture.py
materialise_native(native, store, dest)
#
Materialise a native snapshot from a store into a destination directory.
For each (relpath, entry) the blob is fetched from store (keyed by its
sha256 digest) to dest / relpath, creating parent directories as needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
native
|
dict[str, NativeEntry]
|
Mapping of relpath -> :class: |
required |
store
|
NativeStore
|
A content-addressed :class: |
required |
dest
|
Path
|
The destination directory the snapshot is materialised into. |
required |
Source code in packages/climate-ref-core/src/climate_ref_core/regression/capture.py
write_committed_bundle(source_dir, regression_dir, *, placeholders)
#
Write the sanitised committed CMEC bundle into regression_dir.
Copies each committed artefact present in source_dir into regression_dir,
rewrites absolute paths to portable placeholders in place
(:meth:~climate_ref_core.output_files.PlaceholderMap.sanitise),
then canonicalises every committed JSON file -- rounding floats and redacting host/user CMEC
provenance into a deterministic on-disk form (:func:_canonicalise_committed_bundle).
When a committed artefact is absent from source_dir,
any stale copy left in regression_dir from a previous capture is removed so it is not re-digested.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_dir
|
Path
|
Directory holding the freshly persisted CMEC artefacts (the per-execution results directory). |
required |
regression_dir
|
Path
|
The destination |
required |
placeholders
|
PlaceholderMap
|
The placeholder map for this execution, already bound to the output directory via
:meth: |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
The committed digests |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |