feat: Add explicit input validation with clear error messages for model inputs#210
Open
Raakshass wants to merge 2 commits intoopenclimatefix:mainfrom
Open
feat: Add explicit input validation with clear error messages for model inputs#210Raakshass wants to merge 2 commits intoopenclimatefix:mainfrom
Raakshass wants to merge 2 commits intoopenclimatefix:mainfrom
Conversation
…el inputs Addresses issue openclimatefix#190 - adds fail-fast input validation at the API boundary for model forward() methods. Changes: - Add graph_weather/models/validation.py with centralized validation utilities - Update GraphWeatherForecaster.forward() to validate input shape - Update GraphWeatherAssimilator.forward() to validate input shape - Add comprehensive unit tests in tests/test_input_validation.py Fixes openclimatefix#190
for more information, see https://pre-commit.ci
Author
|
The CI failure is due to pre-existing Ruff linting issues in files I didn't modify ( My changes to Happy to help fix these existing docstring issues in a separate PR if that would be helpful! |
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 explicit input validation with clear error messages for model inputs to address issue #190.
Previously, incorrect input tensor shapes caused cryptic runtime errors. This PR adds fail-fast validation at the API boundary for forward() methods using a new centralized validation utility.
Changes:
GraphWeatherForecaster.forward()to validate input shapeGraphWeatherAssimilator.forward()to validate input shapeFixes #190
How Has This Been Tested?
Added comprehensive unit tests in tests/test_input_validation.py that verify:
Valid 3D tensors pass validation
Invalid 2D/1D/4D tensors raise
ValueErrorwith clear messagesModel imports work correctly
Yes
Yes (validation logic is pure shape checking, no data processing changes)
Checklist: