generated from openclimatefix/ocf-template
-
-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
bugSomething isn't workingSomething isn't working
Description
The validate() function in validate.py contains a critical error message bug that causes the function to crash with an AttributeError instead of providing a helpful validation error when a dataset doesn't have the required dimensions.
To Reproduce
Steps to reproduce the behavior:
- Create or use a zarr dataset that lacks the required
x_geostationaryandy_geostationarydimensions - Call the
validate()function on this dataset:validate(src="path/to/invalid/dataset.zarr") - The function attempts to validate the dimensions
- See error:
AttributeError: 'DataArray' object has no attribute 'data_vars'
Expected behavior
The function should raise a clear ValidationError with a properly formatted message showing:
- The actual file path being validated
- The expected dimensions that are missing
- The actual dimensions found in the dataset
Additional context
Location: validate.py, lines 51-56
Root cause: The error message has three issues:
- Missing
fprefix for string formatting ({src}prints literally instead of the variable value) - Wrong variable reference (
ds.data_vars['data'].dimsshould beda.dims) - Incorrect attribute access (
dais a DataArray, not a Dataset, so it doesn't havedata_vars)
Current problematic code:
raise ValidationError(
"Cannot validate dataset at path {src}. "
"Expected dimensions ['x_geostationary', 'y_geostationary'] not present. "
"Got: {list(ds.data_vars['data'].dims)}",
)Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working