Add dataset validation utilities - #843
Open
tomvothecoder wants to merge 2 commits into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #843 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 18 19 +1
Lines 1993 2116 +123
==========================================
+ Hits 1993 2116 +123 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR introduces a new public validation API (xcdat.validate_dataset) that performs non-mutating, CF-aware preflight checks on datasets. It returns structured diagnostics (issues, warnings/errors) so users can identify CF axis/metadata and bounds problems before running downstream xCDAT operations.
Changes:
- Added
xcdat.validationmodule withvalidate_dataset(), structured issue/result types, and an aggregatedDatasetValidationError. - Implemented validation rules for CF axis mapping conflicts/ambiguity and coordinate bounds presence/shape/vertex checks.
- Exported the new API from the top level and documented it in the API reference + FAQ, with focused pytest coverage.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
xcdat/validation.py |
New validation implementation and public diagnostics types/errors. |
xcdat/__init__.py |
Re-exports validation API types and function at top-level xcdat.*. |
tests/test_validation.py |
Adds regression/unit tests for validation results, axis checks, bounds checks, and exports. |
docs/getting-started-guide/faqs.rst |
Documents how to run dataset validation and interpret results. |
docs/api.rst |
Adds validate_dataset to top-level API and documents validation-related public types. |
Comment on lines
+110
to
+123
| self._issues: dict[tuple[str, str, str], ValidationIssue] = {} | ||
|
|
||
| def add( | ||
| self, | ||
| code: str, | ||
| severity: _Severity, | ||
| variable: str, | ||
| problem: str, | ||
| operations: Iterable[str], | ||
| suggestion: str, | ||
| ) -> None: | ||
| key = (code, variable, problem) | ||
| current = self._issues.get(key) | ||
| operation_set = set(operations) |
Comment on lines
+14
to
+18
| _AFFECTED_OPERATIONS = ( | ||
| "spatial_average", | ||
| "temporal", | ||
| "horizontal_regrid", | ||
| "vertical_regrid", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
xcdat.validate_dataset()as a non-mutating preflight check for common CF axis and coordinate-bounds problems. This gives users structured, actionable diagnostics before downstream xCDAT operations fail.Closes #842
Checklist
If applicable: