climate_ref_core.regression.capture
#
Capture of regression baselines from a diagnostic execution.
Capture reuses :func:climate_ref_core.output_files.copy_execution_outputs,
so the captured native set is identical to what REF actually persists when handling an execution.
Note that this is not the raw output from an execution (the "scratch" directory), but the curated subset of files copied into the "results" directory for persistence and comparison. 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
capture_execution(scratch_directory, results_directory, fragment, result, *, regression_dir, output_dir, test_data_dir, include_log=False)
#
Persist a successful execution and capture its committed bundle + native snapshot.
Copies the curated output set from scratch to results via
:func:~climate_ref_core.output_files.copy_execution_outputs
(the production persistence path),
then writes the committed bundle and snapshots every persisted native file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scratch_directory
|
Path
|
Base scratch directory the diagnostic wrote into. |
required |
results_directory
|
Path
|
Base results directory to persist the curated subset into. |
required |
fragment
|
Path | str
|
The per-execution fragment under both base directories. |
required |
result
|
ExecutionResult
|
The successful execution result (must carry a metric bundle filename). |
required |
regression_dir
|
Path
|
The test case |
required |
output_dir
|
Path
|
The absolute execution output directory, for path substitution. |
required |
test_data_dir
|
Path
|
The absolute provider test-data directory, for path substitution. |
required |
include_log
|
bool
|
If True, the execution log is included in the persisted/native set. Defaults to False, matching the behaviour of
:func: |
False
|
Returns:
| Type | Description |
|---|---|
tuple[dict[str, str], dict[str, NativeEntry]]
|
A |
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, *, output_dir, test_data_dir)
#
Write the sanitised committed CMEC bundle into regression_dir.
Copies each committed artefact present in source_dir into regression_dir,
then rewrites absolute paths to portable placeholders in place
(:func:~climate_ref_core.output_files.to_placeholders).
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 |
output_dir
|
Path
|
The absolute execution output directory, for path substitution. |
required |
test_data_dir
|
Path
|
The absolute provider test-data directory, for path substitution. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
The committed digests |