Skip to content

Add dataset validation utilities - #843

Open
tomvothecoder wants to merge 2 commits into
mainfrom
feature/842-xcdat-validation
Open

Add dataset validation utilities#843
tomvothecoder wants to merge 2 commits into
mainfrom
feature/842-xcdat-validation

Conversation

@tomvothecoder

@tomvothecoder tomvothecoder commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

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

  • Add structured validation issues, results, and aggregate error reporting
  • Detect missing, conflicting, and ambiguous CF axis metadata
  • Validate bounds references, dimensions, and vertex counts
  • Export and document the public API, with focused regression coverage

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

If applicable:

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass with my changes (locally and CI/CD build)
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have noted that this is a breaking change for a major release (fix or feature that would cause existing functionality to not work as expected)

@github-actions github-actions Bot added type: docs Updates to documentation type: enhancement New enhancement request labels Jul 23, 2026
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (23bc25d) to head (f93ddc4).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tomvothecoder
tomvothecoder marked this pull request as ready for review July 23, 2026 23:00
@tomvothecoder
tomvothecoder requested a review from Copilot July 31, 2026 18:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.validation module with validate_dataset(), structured issue/result types, and an aggregated DatasetValidationError.
  • 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 thread xcdat/validation.py
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 thread xcdat/validation.py
Comment on lines +14 to +18
_AFFECTED_OPERATIONS = (
"spatial_average",
"temporal",
"horizontal_regrid",
"vertical_regrid",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: docs Updates to documentation type: enhancement New enhancement request

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

[Enhancement]: Add dataset validation utilities for CF metadata, axes, and bounds

2 participants