climate_ref_core.regression.report_store
#
Named-key store for hosted baseline diff reports.
A diff report is a small static site, so its objects are addressed by path rather than by digest.
That is the one thing it does not share with :class:~climate_ref_core.regression.store.NativeStore,
which is content-addressed and must stay that way.
Everything below the key (where the store lives, how it authenticates, preflight, putting a file)
is the shared transport in :mod:~climate_ref_core.regression.store.
Reports live in their own public bucket, served at {url}/{key}.
Write credentials are resolved from the following in order:
REF_REPORT_STORE_ACCESS_KEY_ID/REF_REPORT_STORE_SECRET_ACCESS_KEY,REF_REPORT_STORE_PROFILE,- boto3's default chain
ReportStore
#
Named-key store for hosted baseline diff reports.
A local store (a file:// URL or a bare path) writes under its root and needs no credentials.
A remote store writes through an :class:S3WriteConfig and is served at {url}/{key}.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
Where reports are served from: an |
required | |
write
|
The S3 endpoint, bucket and credentials a remote store writes with.
|
required |
Source code in packages/climate-ref-core/src/climate_ref_core/regression/report_store.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 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 | |
root = field(init=False)
class-attribute
instance-attribute
#
The local store root, or None when this store is remote.
preflight()
#
Verify the store is reachable and usable before uploading to it.
Raises:
| Type | Description |
|---|---|
NativeStoreUnavailableError
|
If the store cannot be reached or used, with an operator-facing message. |
Source code in packages/climate-ref-core/src/climate_ref_core/regression/report_store.py
put(key, path, content_type)
#
Store path under key, overwriting whatever was there.
Reports are rewritten whenever a pull request is re-minted, so a put always replaces.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key to store under, relative and slash-separated. |
required |
path
|
Path
|
The local file to store. |
required |
content_type
|
str
|
The MIME type the object is served with. A browser will not render an uploaded page without it, since R2 defaults to a binary type. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The URL the key is served at. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the key is not a safe relative path. |
NotImplementedError
|
If this is an anonymous remote store, which cannot write. |
Source code in packages/climate-ref-core/src/climate_ref_core/regression/report_store.py
url_for(key)
#
Return the public URL a key is served at.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key, relative and slash-separated. |
required |
Returns:
| Type | Description |
|---|---|
str
|
An |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the key is not a safe relative path. |
Source code in packages/climate-ref-core/src/climate_ref_core/regression/report_store.py
build_report_store(config, *, writable)
#
Build a :class:ReportStore from a report-store config object.
With writable=False the returned store is anonymous and credential-free.
With writable=True and a remote URL the S3 endpoint and bucket come from the config,
and authentication is read from the environment
(REF_REPORT_STORE_ACCESS_KEY_ID / REF_REPORT_STORE_SECRET_ACCESS_KEY,
else REF_REPORT_STORE_PROFILE, else boto3's default chain),
so secrets never live in the persisted config.
A local store is always readable and writable, so writable makes no difference to it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
_StoreConfigProtocol
|
A config object providing |
required |
writable
|
bool
|
Whether the store must be able to write. |
required |
Returns:
| Type | Description |
|---|---|
ReportStore
|
The configured store. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the URL scheme is unrecognised, or a writable remote store is requested without an S3 endpoint / bucket configured. |