climate_ref.baseline_report.collect
#
Read the baselines either side of a base ref and pair up everything that moved.
Collection reads only the repository, both the manifests and the committed bundle they track.
Fetching native blobs from the store and building diffs is
:mod:~climate_ref.baseline_report.analyse's job.
IMAGE_SUFFIXES = frozenset({'.png', '.jpg', '.jpeg', '.gif', '.svg'})
module-attribute
#
Extensions rendered as a two-up image comparison.
NETCDF_SUFFIXES = frozenset({'.nc'})
module-attribute
#
Extensions reported as a size delta and a link rather than a content diff.
TEXT_SUFFIXES = frozenset({'.json', '.csv', '.yml', '.yaml', '.html', '.txt', '.md', '.log'})
module-attribute
#
Extensions whose blobs are worth fetching and diffing line by line.
CaseChange
#
Everything that changed for a single test case.
Source code in packages/climate-ref/src/climate_ref/baseline_report/collect.py
base
instance-attribute
#
The manifest on the base ref, or None when the case is new.
committed
instance-attribute
#
Committed artefacts whose digest moved, in name order.
files
instance-attribute
#
Every native file that moved, in name order.
head
instance-attribute
#
The manifest on HEAD, or None when the case was removed.
is_new
property
#
Whether the whole test case is new on this branch.
is_removed
property
#
Whether the whole test case was deleted on this branch.
label
instance-attribute
#
provider/diagnostic/test-case.
metadata
instance-attribute
#
Scalar manifest fields that moved, described one per entry.
rel_path
instance-attribute
#
Repo-relative path of the case's manifest.json.
CommittedChange
#
One committed regression artefact whose digest moved.
Unlike a native output these bytes are tracked in git, so both sides are read from the repository rather than fetched from the store.
Source code in packages/climate-ref/src/climate_ref/baseline_report/collect.py
name
instance-attribute
#
Path of the artefact relative to the test case's regression/ directory.
new
instance-attribute
#
The digest on HEAD, or None when the artefact was removed.
new_text
instance-attribute
#
The artefact's content on HEAD, or None when it could not be read.
old
instance-attribute
#
The digest on the base ref, or None when the artefact is new.
old_text
instance-attribute
#
The artefact's content on the base ref, or None when it could not be read.
rel_path
instance-attribute
#
Repo-relative path of the artefact, which is where it appears in the pull request.
status
property
#
added, removed or changed.
FileChange
#
One native output file that was added, removed, or changed by the mint.
Source code in packages/climate-ref/src/climate_ref/baseline_report/collect.py
kind
instance-attribute
#
How the file should be rendered.
name
instance-attribute
#
Path of the file relative to the test case's native output directory.
new
instance-attribute
#
The manifest entry on HEAD, or None when the file was removed.
old
instance-attribute
#
The manifest entry on the base ref, or None when the file is new.
status
property
#
added, removed or changed.
FileKind
#
Bases: Enum
How a native output file should be presented in the report.
Source code in packages/climate-ref/src/climate_ref/baseline_report/collect.py
Report
#
Every test case whose baseline moved on this branch.
Source code in packages/climate-ref/src/climate_ref/baseline_report/collect.py
build_case_change(repo, base, rel_path)
#
Collect every change to one test case.
A case deleted on this branch has no head manifest. It is still reported, as a removal, because dropping a test case is a baseline change a reviewer needs to see.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo
|
Repo
|
The repository to read from. |
required |
base
|
str
|
The git ref to compare against. |
required |
rel_path
|
str
|
Repo-relative path of the case's manifest. |
required |
Returns:
| Type | Description |
|---|---|
CaseChange | None
|
The case's changes, or |
Source code in packages/climate-ref/src/climate_ref/baseline_report/collect.py
case_label(rel_path)
#
Derive a provider/diagnostic/test-case label from a manifest path.
packages/climate-ref-pmp/tests/test-data/annual-cycle/cmip6-ts/manifest.json
becomes pmp/annual-cycle/cmip6-ts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rel_path
|
str
|
Repo-relative path of the manifest. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The label. |
Source code in packages/climate-ref/src/climate_ref/baseline_report/collect.py
change_status(old, new)
#
Describe which sides of the change an entry is present on.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
old
|
str | NativeEntry | None
|
The entry on the base ref, or |
required |
new
|
str | NativeEntry | None
|
The entry on HEAD, or |
required |
Returns:
| Type | Description |
|---|---|
str
|
|
Source code in packages/climate-ref/src/climate_ref/baseline_report/collect.py
changed_manifests(repo, base)
#
Return the repo-relative paths of every test-case manifest that differs from base.
Uses the merge-base (base...HEAD) so commits landing on the base branch after the
feature branch forked are not misreported as baseline changes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo
|
Repo
|
The repository to diff in. |
required |
base
|
str
|
The git ref to compare against. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
The manifest paths, sorted. |
Source code in packages/climate-ref/src/climate_ref/baseline_report/collect.py
classify(name)
#
Classify a native output file by its extension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The file's path relative to the test case's native output directory. |
required |
Returns:
| Type | Description |
|---|---|
FileKind
|
The kind that decides how the file is rendered. |
Source code in packages/climate-ref/src/climate_ref/baseline_report/collect.py
collect(repo, base)
#
Collect every baseline change on this branch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo
|
Repo
|
The repository to read from. |
required |
base
|
str
|
The git ref to compare against. |
required |
Returns:
| Type | Description |
|---|---|
Report
|
The report, with cases in label order. |
Source code in packages/climate-ref/src/climate_ref/baseline_report/collect.py
load_at_ref(repo, ref, rel_path)
#
Load a manifest as it exists at ref, or None when absent there.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo
|
Repo
|
The repository to read from. |
required |
ref
|
str
|
The git ref to read the manifest at. |
required |
rel_path
|
str
|
Repo-relative path of the manifest. |
required |
Returns:
| Type | Description |
|---|---|
Manifest | None
|
The parsed manifest, or |
Source code in packages/climate-ref/src/climate_ref/baseline_report/collect.py
show_at_ref(repo, ref, rel_path)
#
Read a file's content as it exists at ref, or None when it cannot be read there.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo
|
Repo
|
The repository to read from. |
required |
ref
|
str
|
The git ref to read the file at. |
required |
rel_path
|
str
|
Repo-relative path of the file. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The file's text, or |