input4mips_validation.validation.tree#
input4mips_validation.validation.tree
#
Validation of a tree of files
TreeValidationResultsStore
#
Store of the results from validating a (directory) tree
Source code in src/input4mips_validation/validation/tree.py
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 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 353 354 355 | |
file_validation_results_stores: dict[Path, ValidationResultsStore] = field(factory=dict)
class-attribute
instance-attribute
#
Results of validation for each file
files_failing: dict[Path, ValidationResultsStore]
property
#
Files in our store which failed validation
files_passing: dict[Path, ValidationResultsStore]
property
#
Files in our store which passed validation
general_checks_failing: tuple[ValidationResult, ...]
property
#
General checks in our store which failed
general_checks_passing: tuple[ValidationResult, ...]
property
#
General checks in our store which passed
general_validation_results_store: ValidationResultsStore
instance-attribute
#
Results of general validation steps
tree_root: Path
instance-attribute
#
Root of the tree being validated
checks_summary_str(general, passing)
#
Get a summary of the checks we have performed
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
general
|
bool
|
Should we get a summary of general checks, or individual file checks? |
required |
passing
|
bool
|
Should we return the summary
as the number of checks
which are passing ( |
required |
Returns:
| Type | Description |
|---|---|
str
|
Summary of the checks |
Source code in src/input4mips_validation/validation/tree.py
raise_if_errors()
#
Raise a ValidationError if any of the validation steps failed
Raises:
| Type | Description |
|---|---|
ValidationError
|
One of the validation steps in |
Source code in src/input4mips_validation/validation/tree.py
to_html()
#
Generate an HTML representation of self
Source code in src/input4mips_validation/validation/tree.py
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 290 291 292 293 294 295 296 297 298 | |
TreeValidationResultsStoreError
#
Bases: ValueError
Raised to signal that an error occured during validation
Specifically, that a
TreeValidationResultsStore
object contains failed validation results.
Source code in src/input4mips_validation/validation/tree.py
__init__(tvrs)
#
Initialise the error
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tvrs
|
TreeValidationResultsStore
|
The validation results store that contains failures. |
required |
Source code in src/input4mips_validation/validation/tree.py
get_validate_tree_result(root, cv_source, cvs=None, xr_variable_processor=XRVariableHelper(), frequency_metadata_keys=FrequencyMetadataKeys(), bounds_info=None, time_dimension='time', rglob_input='*.nc', allow_cf_checker_warnings=False)
#
Get the result of validating a (directory) tree
This checks that:
- all files in the tree can be loaded with standard libraries
- all files in the tree pass metadata and data checks
- all files in the tree are correctly written according to the data reference syntax
- all references to external variables (like cell areas) can be resolved
- all files have a unique tracking ID
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Path
|
Root of the tree to validate |
required |
cv_source
|
str | None
|
Source from which to load the CVs Only required if For full details on options for loading CVs,
see
|
required |
cvs
|
Input4MIPsCVs | None
|
CVs to use when validating the file. If these are passed, then |
None
|
xr_variable_processor
|
XRVariableProcessorLike
|
Helper to use for processing the variables in xarray objects. |
XRVariableHelper()
|
frequency_metadata_keys
|
FrequencyMetadataKeys
|
Metadata definitions for frequency information |
FrequencyMetadataKeys()
|
bounds_info
|
BoundsInfo | None
|
Metadata definitions for bounds handling If |
None
|
time_dimension
|
str
|
The time dimension of the data |
'time'
|
rglob_input
|
str
|
String to use when applying Path.rglob to find input files. This helps us only select relevant files to check. |
'*.nc'
|
allow_cf_checker_warnings
|
bool
|
Should warnings from the CF-checker be allowed? In otherwise, is a file allowed to pass validation, even if there are warnings from the CF-checker? |
False
|
Returns:
| Type | Description |
|---|---|
TreeValidationResultsStore
|
The validation results store. |
Source code in src/input4mips_validation/validation/tree.py
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 | |
validate_tracking_ids_are_unique(files)
#
Validate that tracking IDs in all files are unique
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
files
|
Collection[Path]
|
Files to check |
required |
Raises:
| Type | Description |
|---|---|
NonUniqueError
|
Not all the tracking IDs are unique |