input4mips_validation.cvs.loading_raw#
input4mips_validation.cvs.loading_raw
#
Tools for loading the raw CVs
This allows us to access CVs defined locally as well as in remote sources, specifically on GitHub.
RawCVLoader
#
RawCVLoaderBaseURL
#
Loader of raw CV data from some base URL
Uses pooch.retrieve to manage downloading and storage of files.
Source code in src/input4mips_validation/cvs/loading_raw.py
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 | |
base_url: str = field(validator=attrs.validators.instance_of(str))
class-attribute
instance-attribute
#
Base URL from which to load files
The filename is simply appended to the end of the base URL to create the URL from which to request the file.
download_path: Path = HERE / 'user_cvs'
class-attribute
instance-attribute
#
Path in which to save downloaded files
Passed to pooch.retrieve.
Defaults to being inside the package so that downloaded files are removed when the package is removed.
force_download: bool = False
class-attribute
instance-attribute
#
Whether to force a new download of the file if it already exists
ends_with_forward_slash(attribute, value)
#
Assert that the value ends with a forward slash
Source code in src/input4mips_validation/cvs/loading_raw.py
load_raw(filename, downloader=None)
#
Load raw CV data
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Filename from which to load raw CV data |
required |
downloader
|
HTTPDownloader | None
|
Downloader to use when retrieving data with pooch. |
None
|
Returns:
| Type | Description |
|---|---|
Raw CV data
|
|
Source code in src/input4mips_validation/cvs/loading_raw.py
RawCVLoaderKnownRemoteRegistry
#
Loader of raw CV data from a known remote registry
Known remote registries are assumed to be represented as pooch.Pooch.
Source code in src/input4mips_validation/cvs/loading_raw.py
force_download: bool = False
class-attribute
instance-attribute
#
Whether to force a new download of the file if it already exists
registry: pooch.Pooch
instance-attribute
#
Pooch registry to use for retrieving and managing files
load_raw(filename, downloader=None)
#
Load raw CV data
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Filename from which to load raw CV data |
required |
downloader
|
HTTPDownloader | None
|
Downloader to use when fetching data with pooch. If not supplied, we use a basic default HTTP downloader. |
None
|
Returns:
| Type | Description |
|---|---|
Raw CV data
|
|
Source code in src/input4mips_validation/cvs/loading_raw.py
RawCVLoaderLocal
#
Loader of raw CV data from local data
Source code in src/input4mips_validation/cvs/loading_raw.py
root_dir: Path
instance-attribute
#
Root directory in which the raw CV data is stored
convert_force_download_from_env_to_bool(force_download_from_env)
#
Convert the value of force download retrieved from an environment variable to a bool
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force_download_from_env
|
str
|
Force download value retrieved from an environment variable |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Boolean equivalent of |
Source code in src/input4mips_validation/cvs/loading_raw.py
get_raw_cvs_loader(cv_source=None, force_download=None)
#
Get the raw CVs loader
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cv_source
|
None | str | Path
|
String identifying the source of the CVs. If not supplied, this is retrieved from the environment variable
If this environment variable is also not set,
we raise a If this starts with "gh:", we retrieve the data from PCMD's GitHub, using everything after the colon as the ID for the Git commit to use (where the ID can be a branch name, a tag or a commit ID). Otherwise we simply return the path as provided and use the validators package to decide if the source points to a URL or not. |
None
|
force_download
|
bool | None
|
If we are downloading from a remote source, should the raw CV loader be configured so that downloads are forced. If not supplied, this is retrieved from the environment variable
If this environment variable is also not set,
we assume |
None
|
Returns:
| Type | Description |
|---|---|
RawCVLoader
|
Raw CV loader |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
|
Source code in src/input4mips_validation/cvs/loading_raw.py
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 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | |