climate_ref_core.regression.manifest
#
Manifest model and digest utilities for test case regression bundles.
The manifest (manifest.json) lives alongside a test case's regression data.
It records:
- schema: the manifest schema version (SCHEMA_VERSION).
- test_case_version: a monotonic, author-bumped integer coupling the committed
bundle to its native outputs.
- committed: sha256 digests of the committed regression JSON artefacts,
computed over the exact placeholder-substituted bytes as they sit on disk,
so that a CI recompute is deterministic.
- native: digests of the curated native output files, authored ONLY by mint.
Digests use sha256 throughout for hashing files.
COMMITTED_BUNDLE_FILES = ('series.json', 'diagnostic.json', 'output.json')
module-attribute
#
The committed CMEC artefacts tracked in git.
Their digests are tracked in :attr:Manifest.committed.
SCHEMA_VERSION = 1
module-attribute
#
Current manifest schema version.
Manifest
#
The on-disk manifest for a test case regression bundle.
Serialised as manifest.json with stable key ordering and a trailing newline,
so repeated dumps are byte-identical.
Source code in packages/climate-ref-core/src/climate_ref_core/regression/manifest.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |
catalog_hash = None
class-attribute
instance-attribute
#
Hash of the test case input catalog.yaml (its _metadata.hash) that produced this baseline.
This couples the baseline to its inputs.
The CI gate fails a case whose live catalog hash no longer matches this value.
committed
instance-attribute
#
Digests of committed regression JSON artefacts: {relpath: sha256}.
native
instance-attribute
#
Digests of curated native output files: {relpath: NativeEntry}.
schema
instance-attribute
#
Manifest schema version; equals :data:SCHEMA_VERSION for current manifests.
test_case_version
instance-attribute
#
Monotonic, author-bumped version coupling the bundle to its native outputs.
dump(path)
#
Write the manifest to manifest.json.
Keys are stably ordered (sort_keys=True) and a trailing newline is added,
so dump followed by load round-trips byte-identically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to write the manifest to. |
required |
Source code in packages/climate-ref-core/src/climate_ref_core/regression/manifest.py
load(path)
classmethod
#
Load a manifest from manifest.json.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to the manifest file. |
required |
Returns:
| Type | Description |
|---|---|
Manifest
|
The parsed manifest. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the manifest is missing required keys or has malformed native entries (e.g. hand-edited or written by an incompatible version). |
Source code in packages/climate-ref-core/src/climate_ref_core/regression/manifest.py
loads(text, *, source='<string>')
classmethod
#
Parse a manifest from its JSON text.
Used when the manifest does not live on disk at parse time,
e.g. when reading the base-branch copy via git show for the CI coupling gate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The manifest JSON. |
required |
source
|
str
|
A label for the text's origin, used in error messages. |
'<string>'
|
Returns:
| Type | Description |
|---|---|
Manifest
|
The parsed manifest. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the manifest is missing required keys or has malformed native entries (e.g. hand-edited or written by an incompatible version). |
Source code in packages/climate-ref-core/src/climate_ref_core/regression/manifest.py
seed_v1(committed_digests, catalog_hash=None)
classmethod
#
Create an initial manifest at test_case_version == 1 with no native outputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
committed_digests
|
dict[str, str]
|
Digests of the committed regression JSON artefacts. |
required |
catalog_hash
|
str | None
|
Hash of the input |
None
|
Returns:
| Type | Description |
|---|---|
Manifest
|
A fresh manifest with |
Source code in packages/climate-ref-core/src/climate_ref_core/regression/manifest.py
NativeEntry
#
A single curated native output file recorded in the manifest.
Source code in packages/climate-ref-core/src/climate_ref_core/regression/manifest.py
compute_committed_digests(regression_dir)
#
Compute sha256 digests of the committed regression JSON artefacts.
The digests are taken over the bytes exactly as they sit on disk (placeholder text included), so a CI recompute is deterministic. Only files that exist are included.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
regression_dir
|
Path
|
The test case |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Mapping of |
Source code in packages/climate-ref-core/src/climate_ref_core/regression/manifest.py
sha256_bytes(data)
#
sha256_file(path)
#
Compute the sha256 digest of a file.
Reuses :func:pooch.hashes.file_hash so the digest agrees with pooch elsewhere.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to the file to hash. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The hex-encoded sha256 digest. |
Source code in packages/climate-ref-core/src/climate_ref_core/regression/manifest.py
verify_committed_integrity(manifest, regression_dir)
#
Check that the committed regression artefacts match the manifest digests.
Used by the CI integrity check. An empty return value means the bundle is intact.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manifest
|
Manifest
|
The manifest holding the expected committed digests. |
required |
regression_dir
|
Path
|
The test case |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
A list of human-readable mismatch descriptions; empty when everything matches. |